.ai-gen-page {
    overflow: hidden;
}

.ai-gen-page #aiGenTitle {
    font-size: 20px;
    font-weight: 600;
}

.ai-gen-page #aiGenDescription {
    max-width: 720px;
}

.ai-page-header-main {
    flex: 1 1 720px;
    min-width: 0;
}

.ai-title-meta-row {
    display: flex;
    align-items: stretch;
    gap: 16px;
    flex-wrap: wrap;
}

.ai-title-block {
    flex: 0 0 auto;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ai-gen-page .ai-header-actions {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.ai-gen-page .ai-meta-panel {
    flex: 1 1 640px;
    border-radius: 8px;
    background-color: #ffffff;
    align-self: stretch;
    overflow-x: auto;
}

.ai-gen-page .ai-meta-panel .row {
    flex-wrap: nowrap;
    min-height: 100%;
}

.ai-gen-page .ai-meta-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 104px;
    padding: 6px 10px;
    border-right: 1px solid #dee2e6;
}

.ai-gen-page .ai-meta-item:last-child {
    border-right: none;
}

.ai-gen-page .ai-meta-label {
    color: #6c757d;
    font-size: 11px;
    line-height: 1.2;
    margin-bottom: 3px;
    white-space: nowrap;
}

.ai-gen-page .ai-meta-value {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    color: #212529;
    white-space: nowrap;
}

.ai-gen-page .ai-meta-value .form-select {
    min-width: 96px;
    height: 28px;
    padding-top: 2px;
    padding-bottom: 2px;
    font-size: 12px;
    font-weight: 600;
}

.ai-debug-output {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 12px 14px;
    color: #495057;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 220px;
    overflow-y: auto;
}

.ai-content-tabs .nav-link {
    height: 40px;
    min-height: 40px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    font-size: 13px;
    line-height: 40px;
}

#aiListSections {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.ai-gen-page>section:not(.d-none) {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#aiListSections>section {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.ai-section-header {
    margin: 0;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    background-color: #DADADA;
}

.ai-table-section {
    flex: 1 1 auto;
    min-height: 0;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    background-color: #fff;
    overflow: hidden;
}

#aiTagSection .ai-table-section,
#aiModelApplySection .ai-table-section,
#aiHighRiskSection .ai-table-section {
    display: flex;
    flex-direction: column;
}

.ai-tab-section-body {
    gap: 12px;
    background-color: transparent;
    border-radius: 0;
    overflow: visible;
}

.ai-tab-section-body>.ai-modal-toolbar,
.ai-tab-section-body>.collapse,
#aiModelApplyReferencePanel .ai-modal-toolbar,
#aiModelApplyReferencePanel .collapse {
    flex: 0 0 auto;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
}

#aiModelApplyReferencePanel {
    flex: 0 0 auto;
    min-height: 0;
}

#aiModelApplyReferencePanel .model-reference-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-gen-page .ai-table-scroll {
    height: 100%;
    max-height: none;
    overflow-y: auto;
}

#aiTagSection .ai-tag-candidate-section {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

#aiTagSection .ai-tag-candidate-section .ai-table-scroll {
    flex: 1 1 auto;
    min-height: 0;
    background-color: #fff;
}

#aiHighRiskSection .ai-risk-user-section {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#aiModelApplyBody,
#aiBatchModelApplyBody {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.ai-status-section {
    flex: 0 0 auto;
}

.ai-gen-page .ai-data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: #f3f3f3;
    box-shadow: inset 0 -1px 0 #dee2e6;
}

.ai-gen-page .ai-data-table tbody td {
    background-color: #fff;
}

.ai-modal-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 52px;
    padding: 10px 12px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background-color: #f8f9fa;
    overflow-x: auto;
    overflow-y: visible;
}

.ai-gen-page .ai-modal-toolbar .ai-action-toolbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
}

.ai-gen-page .ai-modal-toolbar .ai-action-row {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 6px;
    white-space: nowrap;
}

.ai-gen-page .ai-modal-toolbar .ai-action-btn {
    white-space: nowrap;
}

.ai-gen-page .ai-modal-toolbar .ai-action-btn .ai-action-check {
    margin-left: 4px;
}

.ai-gen-page .ai-modal-toolbar .ai-debug-toggle-btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.ai-scroll-panel {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background-color: #f8f9fa;
    padding: 10px 12px;
}

.ai-debug-panel {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background-color: #fff;
    padding: 12px;
}

.ai-debug-scroll {
    background-color: #f8f9fa;
}

.ai-risk-list-panel {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
    background-color: #fff;
}

#aiHighRiskSection .ai-risk-list-panel {
    border: 0;
    border-radius: 0;
    padding: 0;
}

.ai-risk-list-panel>.table>thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: #f3f3f3;
    box-shadow: inset 0 -1px 0 #dee2e6;
}

.high-risk-introduction-cell,
.high-risk-feedback-cell {
    white-space: normal;
    word-break: break-word;
    text-align: left;
}

.high-risk-introduction-text {
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.45;
}

.high-risk-feedback-summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-risk-list-panel table.table tbody td.high-risk-feedback-cell {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
}

.high-risk-feedback-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.35;
}

.high-risk-feedback-stat .badge {
    min-width: 42px;
}

.high-risk-feedback-stat .feedback-badge {
    font-size: 10px;
    padding: 2px 6px;
    font-weight: bold;
}

.high-risk-feedback-stat .feedback-badge-like {
    background-color: #65BB56 !important;
    color: white !important;
}

.high-risk-feedback-stat .feedback-badge-normal {
    background-color: #CCCCCC !important;
    color: black !important;
}

.high-risk-feedback-stat .feedback-badge-dislike {
    background-color: #F23E3E !important;
    color: white !important;
}

.high-risk-feedback-stat .feedback-badge-late {
    background-color: #AA6549 !important;
    color: white !important;
}

.high-risk-feedback-stat .feedback-badge-noshow {
    background-color: #FFAB23 !important;
    color: white !important;
}

.high-risk-feedback-stat-value {
    font-weight: 600;
}

.high-risk-feedback-dislikes-wrap {
    margin-top: 6px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
}

.high-risk-feedback-dislikes-table {
    font-size: 12px;
    width: 100%;
    table-layout: fixed;
}

.high-risk-feedback-dislikes-table th,
.high-risk-feedback-dislikes-table td {
    padding: 3px 4px;
    vertical-align: top;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.ai-risk-list-panel .high-risk-feedback-dislikes-table tbody td {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.ai-risk-list-panel .high-risk-feedback-dislikes-table tbody td:last-child {
    width: auto;
}

.high-risk-feedback-dislikes-table th:first-child,
.high-risk-feedback-dislikes-table td:first-child {
    width: 64px;
    white-space: normal;
}

.high-risk-inline-loading {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
    min-width: max-content;
}

.high-risk-inline-loading .ai-status-text,
.high-risk-inline-loading .ai-status-dots,
.high-risk-inline-loading .ai-inline-spinner {
    flex: 0 0 auto;
}

.high-risk-inline-loading .ai-status-dots {
    width: 1.2em !important;
    text-align: left;
}

.high-risk-inline-loading .ai-inline-spinner {
    margin-left: 6px !important;
}

.high-risk-score-badge {
    font-size: 12px;
    line-height: 1.2;
    cursor: pointer;
}

.high-risk-score-badge:focus {
    outline: 2px solid rgba(13, 110, 253, 0.45);
    outline-offset: 2px;
}

.high-risk-detail-tooltip {
    min-width: 520px;
    pointer-events: none;
}

.high-risk-detail-tooltip .table-responsive {
    max-width: 680px;
}

@media (max-width: 991.98px) {
    .ai-page-header-main {
        flex-basis: 100%;
    }

    .ai-title-block,
    .ai-gen-page .ai-meta-panel {
        flex-basis: 100%;
    }

    .ai-gen-page .ai-header-actions {
        flex-basis: auto;
    }

    .ai-gen-page .ai-meta-item {
        border-right: 1px solid #dee2e6;
        border-bottom: none;
    }

    .ai-gen-page .ai-meta-item:last-child {
        border-right: none;
    }

    .ai-gen-page {
        overflow-y: auto;
    }

    #aiListSections,
    #aiListSections>section,
    .ai-gen-page>section:not(.d-none) {
        flex: 0 0 auto;
        min-height: initial;
    }

    .ai-gen-page .ai-table-section {
        flex: 0 0 auto;
    }

    .ai-tab-section-body {
        gap: 12px;
    }

    #aiTagSection .ai-tag-candidate-section,
    #aiModelApplyBody,
    #aiBatchModelApplyBody,
    .ai-risk-list-panel {
        flex: 0 0 auto;
        min-height: initial;
    }

    .ai-gen-page .ai-table-scroll {
        height: auto;
        max-height: 360px;
    }

    #aiModelApplyBody,
    #aiBatchModelApplyBody,
    .ai-risk-list-panel {
        max-height: 360px;
    }
}

@media (max-width: 768px) {
    .ai-title-meta-row {
        gap: 10px;
    }

    .ai-gen-page .ai-header-actions {
        align-items: stretch;
        width: 100%;
    }

    .ai-gen-page .ai-header-actions .btn {
        width: 100%;
    }

    .ai-gen-page .ai-meta-panel {
        overflow-x: hidden;
        width: 100%;
    }

    .ai-gen-page .ai-meta-panel .row {
        flex-wrap: wrap;
    }

    .ai-gen-page .ai-meta-item {
        border-bottom: 1px solid #dee2e6;
        border-right: none;
        flex: 0 0 50%;
        min-width: 0;
    }

    .ai-gen-page .ai-meta-item:last-child,
    .ai-gen-page .ai-meta-item:nth-last-child(2):nth-child(odd) {
        border-bottom: none;
    }

    .ai-gen-page .ai-meta-label,
    .ai-gen-page .ai-meta-value {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .ai-content-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .ai-content-tabs .nav-item,
    .ai-content-tabs .nav-link {
        flex: 0 0 auto;
    }

    .ai-modal-toolbar {
        overflow-x: hidden;
    }

    .ai-gen-page .ai-modal-toolbar .ai-action-toolbar,
    .batch-model-apply-actions {
        align-items: stretch;
        flex-direction: column;
        width: 100%;
    }

    .ai-gen-page .ai-modal-toolbar .ai-action-row,
    .ai-gen-page .ai-modal-toolbar .ai-action-btn,
    .ai-gen-page .ai-modal-toolbar .ai-debug-toggle-btn {
        width: 100%;
    }

    .ai-gen-page .ai-table-scroll,
    .ai-risk-list-panel,
    #aiModelApplyBody,
    #aiBatchModelApplyBody {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ai-data-table,
    .ai-risk-list-panel table {
        min-width: 760px;
    }
}

@media (max-width: 575.98px) {
    .ai-gen-page .ai-meta-item {
        flex-basis: 100%;
    }
}
