/* ============================================================
   ai-components.css  — v3
   Load SAU canvas-ai.css. File này KHÔNG định nghĩa lại bất kỳ
   class nào đã có trong canvas-ai.css — chỉ bổ sung những gì
   canvas-ai.css chưa có:
     • Status color variables (--ai-*)
     • Gallery: fullscreen, pending-canvas overlay, layout grid3,
       layout-switcher mới, detail image panel
     • Admin page: sidebar, topbar, summary cards, filter bar,
       layout list/grid/kanban, detail panel, badges
   ============================================================ */

/* ── Status color variables ─────────────────────────────────
   Dùng xuyên suốt cả 2 component, canvas-ai.css không có.
   ────────────────────────────────────────────────────────── */
:root {
    --ai-radius: 8px;
    --ai-radius-lg: 12px;
    --ai-pending: #f59e0b;
    --ai-pending-bg: #fef3c7;
    --ai-pending-text: #92400e;
    --ai-processing: #3b82f6;
    --ai-processing-bg: #eff6ff;
    --ai-processing-text: #1e40af;
    --ai-completed: #22c55e;
    --ai-completed-bg: #f0fdf4;
    --ai-completed-text: #166534;
    --ai-rejected: #ef4444;
    --ai-rejected-bg: #fef2f2;
    --ai-rejected-text: #991b1b;
    --ai-failed: #f97316;
    --ai-failed-bg: #fff7ed;
    --ai-failed-text: #9a3412;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ai-pending-bg: #451a03;
        --ai-pending-text: #fde68a;
        --ai-processing-bg: #1e3a5f;
        --ai-processing-text: #bfdbfe;
        --ai-completed-bg: #052e16;
        --ai-completed-text: #bbf7d0;
        --ai-rejected-bg: #450a0a;
        --ai-rejected-text: #fecaca;
        --ai-failed-bg: #431407;
        --ai-failed-text: #fed7aa;
    }
}

/* ============================================================
   GENERATE MODAL — phần canvas-ai.css CHƯA có
   (approval flow, submitted step, user info box, admin badge)
   ============================================================ */

.gen-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 16px;
}

@media (max-width: 600px) {
    .gen-body {
        grid-template-columns: 1fr;
    }
}

.gen-left, .gen-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Preview wrap (canvas-ai có gen-preview-img-wrap, đây khác — dùng aspect-ratio 1:1) */
.gen-preview-wrap {
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-secondary, #f3f4f6);
    border-radius: var(--ai-radius);
    overflow: hidden;
    border: 1px solid var(--border, #e5e7eb);
}

/* Model dot nhỏ (canvas-ai dùng gen-model-icon hình vuông lớn hơn) */
.gen-model-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

    .gen-model-dot.gemini {
        background: #4285f4;
    }

    .gen-model-dot.openai {
        background: #10a37f;
    }

/* Approval notice */
.gen-approval-notice {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
    background: var(--bg-secondary, #f3f4f6);
    border-radius: var(--ai-radius);
    padding: 10px 12px;
    margin-top: 4px;
    line-height: 1.5;
}

    .gen-approval-notice svg {
        flex-shrink: 0;
        margin-top: 1px;
        opacity: .7;
    }

/* Admin badge */
.gen-admin-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: #4338ca;
    background: #ede9fe;
    border-radius: var(--ai-radius);
    padding: 7px 11px;
    margin-top: 8px;
}

/* User info box */
.gen-user-info-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 20px 16px;
    background: var(--bg-secondary, #f3f4f6);
    border-radius: var(--ai-radius-lg);
    border: 1px solid var(--border, #e5e7eb);
    height: 100%;
    justify-content: center;
}

.gen-user-info-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #111827);
}

.gen-user-info-desc {
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
    line-height: 1.6;
    max-width: 240px;
}

.gen-user-info-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    width: 100%;
    max-width: 240px;
    margin-top: 4px;
}

.gen-user-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
}

.gen-user-step-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ede9fe;
    color: #4338ca;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

/* Submitted step */
.gen-submitted-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 28px 24px 20px;
    gap: 12px;
}

.gen-submitted-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #f0fdf4;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #22c55e;
}

.gen-submitted-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary, #111827);
}

.gen-submitted-sub {
    font-size: 13px;
    color: var(--text-secondary, #6b7280);
    line-height: 1.6;
    max-width: 320px;
}

.gen-submitted-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.gen-submitted-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
}

    .gen-submitted-badge.pending {
        background: var(--ai-pending-bg);
        color: var(--ai-pending-text);
    }

.gen-submitted-model {
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
}

.gen-submitted-prompt {
    font-size: 12px;
    font-style: italic;
    color: var(--text-secondary, #6b7280);
    background: var(--bg-secondary, #f3f4f6);
    padding: 8px 14px;
    border-radius: var(--ai-radius);
    max-width: 340px;
    text-align: center;
}

.gen-actions.center {
    justify-content: center;
}

/* gen-spinner.xs size (canvas-ai chỉ có .sm = 20px) */
.gen-spinner.xs {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

/* ============================================================
   BADGE UTILS
   ============================================================ */

/* Generic status badge pill — canvas-ai không có */
.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 9px;
    border-radius: 12px;
}

    .badge.amber {
        background: var(--ai-pending-bg);
        color: var(--ai-pending-text);
    }

    .badge.green {
        background: var(--ai-completed-bg);
        color: var(--ai-completed-text);
    }

    .badge.pending {
        background: var(--ai-pending-bg);
        color: var(--ai-pending-text);
    }

    .badge.processing {
        background: var(--ai-processing-bg);
        color: var(--ai-processing-text);
    }

    .badge.completed {
        background: var(--ai-completed-bg);
        color: var(--ai-completed-text);
    }

    .badge.rejected {
        background: var(--ai-rejected-bg);
        color: var(--ai-rejected-text);
    }

    .badge.failed {
        background: var(--ai-failed-bg);
        color: var(--ai-failed-text);
    }

/* Nav pending count badge */
.badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    margin-left: auto;
    animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: .7;
    }
}

/* Admin model list (dùng flex row, khác gen-model-list của canvas-ai là flex column) */
.aireq-model-list {
    display: flex;
    gap: 6px;
    margin-bottom: 2px;
}

.aireq-model-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border-radius: var(--ai-radius);
    border: 1.5px solid var(--border, #e5e7eb);
    cursor: pointer;
    transition: border-color .15s, background .15s;
    background: var(--bg-primary, #fff);
    flex: 1;
    font-size: 12px;
}

    .aireq-model-row:hover {
        border-color: #a5b4fc;
    }

    .aireq-model-row.selected {
        border-color: #6366f1;
        background: #eef2ff;
    }

/* ============================================================
   GALLERY POPUP — chỉ những class canvas-ai.css CHƯA có
   ============================================================ */

/* ── Fullscreen overlay mode ── */
.gallery-popup-overlay.fullscreen-mode {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
}

/* ── Popup fullscreen state ── */
.gallery-popup--fullscreen {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    height: 100vh;
    border-radius: 0 !important;
}

/* ── Fullscreen toggle button ── */
.gallery-fullscreen-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary, #6b7280);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}

    .gallery-fullscreen-btn:hover {
        background: var(--bg-hover, #f3f4f6);
    }

/* ── Header actions group ── */
.gallery-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ── Layout switcher group ── */
.gallery-layout-btns {
    display: flex;
    gap: 2px;
    background: var(--bg-secondary, #f3f4f6);
    border-radius: 6px;
    padding: 2px;
    margin-right: 2px;
}

.gallery-layout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    border-radius: 5px;
    cursor: pointer;
    color: var(--text-secondary, #6b7280);
    transition: background .15s, color .15s;
}

    .gallery-layout-btn:hover {
        background: var(--bg-hover, #f3f4f6);
    }

    .gallery-layout-btn.active {
        background: var(--bg-primary, #fff);
        color: var(--text-primary, #111827);
        box-shadow: 0 1px 3px rgba(0,0,0,.08);
    }

/* ── Content wrapper (replaces canvas-ai fixed .gallery-grid) ── */
.gallery-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* Fullscreen: content + detail side by side */
.gallery-popup--fullscreen .gallery-content {
    display: flex;
    min-height: 0;
    padding: 0;
    overflow: hidden;
}

/* ── Layout: grid (3 col) ── */
.gallery-content.gallery-layout-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    align-content: start;
}

    .gallery-content.gallery-layout-grid .gallery-card-body {
        display: none;
    }

/* ── Layout: grid3 (3 col medium) ── */
.gallery-content.gallery-layout-grid3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    align-content: start;
}

    .gallery-content.gallery-layout-grid3 .gallery-card-body {
        display: none;
    }

/* ── Layout: large (2 col, 4:3) ── */
.gallery-content.gallery-layout-large {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    align-content: start;
}

    .gallery-content.gallery-layout-large .gallery-card-img,
    .gallery-content.gallery-layout-large .gallery-card-img.placeholder {
        aspect-ratio: 4 / 3;
    }

    .gallery-content.gallery-layout-large .gallery-card-body {
        display: none;
    }

/* ── Layout: list (horizontal rows) ── */
.gallery-content.gallery-layout-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-content: start;
}

    .gallery-content.gallery-layout-list .gallery-card {
        flex-direction: row !important;
        align-items: center;
        padding: 8px 10px;
        gap: 10px;
    }

    .gallery-content.gallery-layout-list .gallery-card-img,
    .gallery-content.gallery-layout-list .gallery-card-img.placeholder {
        width: 56px !important;
        height: 56px !important;
        aspect-ratio: unset !important;
        flex-shrink: 0;
        border-radius: 6px;
    }

    .gallery-content.gallery-layout-list .gallery-card-body {
        display: flex;
        flex-direction: column;
        gap: 2px;
        flex: 1;
        min-width: 0;
    }
    /* Reposition status badge trong list mode */
    .gallery-content.gallery-layout-list .gallery-card-status-badge {
        position: static;
        margin-left: auto;
        flex-shrink: 0;
    }

/* ── Card extensions chưa có trong canvas-ai ── */
.gallery-card.status-pending {
    background: #fffdf5;
}

.gallery-card.status-rejected,
.gallery-card.status-failed {
    background: #fff8f8;
}

/* Card body — chỉ show trong list layout */
.gallery-card-body {
    display: none;
}

.gallery-card-source {
    font-size: 11px;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status badge (canvas-ai có .gallery-card-status với style khác — đây là class mới) */
.gallery-card-status-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    line-height: 1.5;
    z-index: 1;
}

    .gallery-card-status-badge.pending {
        background: var(--ai-pending-bg);
        color: var(--ai-pending-text);
    }

    .gallery-card-status-badge.processing {
        background: var(--ai-processing-bg);
        color: var(--ai-processing-text);
    }

    .gallery-card-status-badge.completed {
        background: var(--ai-completed-bg);
        color: var(--ai-completed-text);
    }

    .gallery-card-status-badge.rejected {
        background: var(--ai-rejected-bg);
        color: var(--ai-rejected-text);
    }

    .gallery-card-status-badge.failed {
        background: var(--ai-failed-bg);
        color: var(--ai-failed-text);
    }

/* ── Pending: show canvas image inside placeholder ── */
.gallery-card-img.placeholder .pending-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(15%) opacity(.72);
}

.pending-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: linear-gradient(to top, rgba(0,0,0,.48) 0%, transparent 55%);
    padding-bottom: 7px;
}

.pending-overlay-label {
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    background: rgba(0,0,0,.35);
    padding: 2px 7px;
    border-radius: 10px;
    letter-spacing: .02em;
}

/* Placeholder tints */
.gallery-card-img.placeholder.pending {
    background: #fef9e7;
}

.gallery-card-img.placeholder.processing {
    background: var(--ai-processing-bg);
}

.gallery-card-img.placeholder.rejected,
.gallery-card-img.placeholder.failed {
    background: var(--ai-rejected-bg);
}

/* ── Gallery detail panel (mới — canvas-ai có gallery-detail-panel khác) ── */
.gallery-detail {
    border-top: 1px solid var(--border, #e5e7eb);
    background: var(--bg-secondary, #f9fafb);
    overflow-y: auto;
    flex-shrink: 0;
    max-height: 38vh;
}

.gallery-popup--fullscreen .gallery-detail {
    border-top: none;
    border-left: 1px solid var(--border, #e5e7eb);
    max-height: unset;
    width: 300px;
    flex-shrink: 0;
}

/* Detail full-res image (khác gallery-detail-col của canvas-ai) */
.gallery-detail-image-wrap {
    position: relative;
    background: var(--bg-secondary, #f3f4f6);
    margin: 12px 14px 0;
    border-radius: var(--ai-radius);
    overflow: hidden;
}

.gallery-detail-img {
    width: 100%;
    max-height: 260px;
    object-fit: contain;
    display: block;
}

    .gallery-detail-img.pending-canvas-full {
        filter: grayscale(12%) opacity(.82);
    }

.gallery-detail-pending-notice {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px;
    background: linear-gradient(to top, rgba(0,0,0,.55), transparent);
    text-align: center;
}

    .gallery-detail-pending-notice span {
        font-size: 12px;
        font-weight: 600;
        color: #fff;
    }

/* Pending / rejected empty detail */
.gallery-detail-pending,
.gallery-detail-rejected {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 20px 16px;
    font-size: 13px;
    color: var(--text-secondary, #6b7280);
}

    .gallery-detail-pending svg {
        color: var(--ai-pending, #f59e0b);
        opacity: .8;
    }

    .gallery-detail-rejected svg {
        color: var(--ai-rejected, #ef4444);
        opacity: .8;
    }

.gallery-detail-note {
    font-size: 12px;
    font-style: italic;
    background: var(--bg-secondary, #f3f4f6);
    padding: 6px 12px;
    border-radius: var(--ai-radius);
    max-width: 280px;
}

/* gallery-cost-bar: override canvas-ai layout (item stacked → inline) */
.gallery-cost-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 7px 14px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    font-size: 12px;
    flex-shrink: 0;
}

.gallery-cost-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary, #6b7280);
    flex: unset;
    flex-direction: row;
    border-right: none;
    padding: 0;
}

/* ============================================================
   AI REQUEST ADMIN PAGE  (/admin/ai-requests)
   Tất cả là class mới, không có trong canvas-ai.css
   ============================================================ */

.admin-page {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-secondary, #f3f4f6);
    font-family: inherit;
}

.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Sidebar ── */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    gap: 2px;
}

    .sidebar-nav .nav-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 16px;
        font-size: 13px;
        color: var(--text-secondary, #6b7280);
        text-decoration: none;
        border-radius: 6px;
        margin: 0 8px;
        transition: background .15s, color .15s;
    }

        .sidebar-nav .nav-item:hover {
            background: var(--bg-hover, #f3f4f6);
            color: var(--text-primary, #111827);
        }

        .sidebar-nav .nav-item.active {
            background: #ede9fe;
            color: #4338ca;
            font-weight: 500;
        }

/* ── Topbar ── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-primary, #fff);
    border-bottom: 1px solid var(--border, #e5e7eb);
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary, #111827);
}

.topbar-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 9px;
    border-radius: 12px;
}

    .topbar-badge.pending {
        background: var(--ai-pending-bg);
        color: var(--ai-pending-text);
    }

/* ── Layout switcher ── */
.aireq-layout-btns {
    display: flex;
    align-items: center;
    gap: 1px;
    background: var(--bg-secondary, #f3f4f6);
    border-radius: var(--ai-radius);
    padding: 2px;
}

.aireq-layout-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    transition: background .12s, color .12s;
    white-space: nowrap;
}

    .aireq-layout-btn:hover {
        background: var(--bg-hover, #f3f4f6);
        color: var(--text-primary, #111827);
    }

    .aireq-layout-btn.active {
        background: var(--bg-primary, #fff);
        color: var(--text-primary, #111827);
        font-weight: 500;
        box-shadow: 0 1px 3px rgba(0,0,0,.08);
    }

.btn-outline {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border, #e5e7eb);
    background: var(--bg-primary, #fff);
    border-radius: var(--ai-radius);
    font-size: 12px;
    cursor: pointer;
    color: var(--text-secondary, #6b7280);
    transition: background .12s;
}

    .btn-outline:hover {
        background: var(--bg-hover, #f3f4f6);
    }

/* ── Summary cards ── */
.aireq-summary-cards {
    display: flex;
    gap: 8px;
    padding: 12px 16px 0;
    flex-wrap: wrap;
}

.aireq-summary-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 16px;
    border-radius: var(--ai-radius);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border, #e5e7eb);
    min-width: 72px;
    gap: 2px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .1s;
}

    .aireq-summary-card:hover {
        transform: translateY(-1px);
        box-shadow: 0 3px 10px rgba(0,0,0,.07);
    }

    .aireq-summary-card.filter-active {
        box-shadow: 0 0 0 2px #6366f1;
    }

    .aireq-summary-card .card-num {
        font-size: 20px;
        font-weight: 600;
        line-height: 1.2;
        color: var(--text-primary, #111827);
    }

    .aireq-summary-card .card-label {
        font-size: 11px;
        color: var(--text-secondary, #6b7280);
    }

    .aireq-summary-card.pending {
        border-top: 3px solid var(--ai-pending);
    }

    .aireq-summary-card.processing {
        border-top: 3px solid var(--ai-processing);
    }

    .aireq-summary-card.completed {
        border-top: 3px solid var(--ai-completed);
    }

    .aireq-summary-card.rejected {
        border-top: 3px solid var(--ai-rejected);
    }

    .aireq-summary-card.failed {
        border-top: 3px solid var(--ai-failed);
    }

    .aireq-summary-card.cost {
        border-top: 3px solid #8b5cf6;
    }

        .aireq-summary-card.cost .card-num {
            font-size: 16px;
        }

    .aireq-summary-card.pending .card-num {
        color: var(--ai-pending-text);
    }

    .aireq-summary-card.processing .card-num {
        color: var(--ai-processing-text);
    }

    .aireq-summary-card.completed .card-num {
        color: var(--ai-completed-text);
    }

    .aireq-summary-card.rejected .card-num {
        color: var(--ai-rejected-text);
    }

    .aireq-summary-card.failed .card-num {
        color: var(--ai-failed-text);
    }

/* ── Filter bar ── */
.aireq-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    flex-wrap: wrap;
}

.date-input {
    font-size: 12px;
    padding: 6px 8px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: var(--ai-radius);
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #111827);
    outline: none;
}

    .date-input:focus {
        border-color: #6366f1;
    }

.date-sep {
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
}

/* ═══════════════════════════════════
   LAYOUT: LIST
═══════════════════════════════════ */

.aireq-body--list {
    display: grid;
    grid-template-columns: 1fr 380px;
    flex: 1;
    overflow: hidden;
}

@media (max-width: 900px) {
    .aireq-body--list {
        grid-template-columns: 1fr;
    }
}

.aireq-list {
    overflow-y: auto;
    padding: 8px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.aireq-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--ai-radius);
    border: 1.5px solid var(--border, #e5e7eb);
    background: var(--bg-primary, #fff);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

    .aireq-row:hover {
        border-color: #a5b4fc;
        background: var(--bg-hover, #f3f4f6);
    }

    .aireq-row.selected {
        border-color: #6366f1 !important;
        background: #eef2ff;
    }

    .aireq-row.skeleton {
        height: 80px;
        background: linear-gradient(90deg, var(--bg-secondary, #f3f4f6) 25%, #eee 50%, var(--bg-secondary, #f3f4f6) 75%);
        background-size: 200% 100%;
        animation: ai-shimmer 1.4s infinite;
        cursor: default;
        border: none;
    }

    .aireq-row.status-pending {
        border-left: 3px solid var(--ai-pending);
    }

    .aireq-row.status-processing {
        border-left: 3px solid var(--ai-processing);
    }

    .aireq-row.status-completed {
        border-left: 3px solid var(--ai-completed);
    }

    .aireq-row.status-rejected {
        border-left: 3px solid var(--ai-rejected);
    }

    .aireq-row.status-failed {
        border-left: 3px solid var(--ai-failed);
    }

.aireq-thumb {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-secondary, #f3f4f6);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .aireq-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

        .aireq-thumb img.thumb-pending {
            filter: grayscale(15%) opacity(.7);
        }

.thumb-pending-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 9px;
    background: rgba(0,0,0,.45);
    color: #fff;
    border-radius: 3px;
    padding: 0 3px;
    line-height: 14px;
}

.thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

    .thumb-placeholder.pending {
        background: var(--ai-pending-bg);
    }

    .thumb-placeholder.processing {
        background: var(--ai-processing-bg);
    }

    .thumb-placeholder.completed {
        background: var(--ai-completed-bg);
    }

    .thumb-placeholder.rejected,
    .thumb-placeholder.failed {
        background: var(--ai-rejected-bg);
    }

.aireq-info {
    flex: 1;
    min-width: 0;
}

.aireq-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 3px;
}

.aireq-user {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary, #111827);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aireq-source {
    font-size: 11px;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aireq-prompt {
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.aireq-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary, #6b7280);
}

.aireq-cost {
    color: #7c3aed;
    font-weight: 500;
}

.aireq-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

    .aireq-badge.pending {
        background: var(--ai-pending-bg);
        color: var(--ai-pending-text);
    }

    .aireq-badge.processing {
        background: var(--ai-processing-bg);
        color: var(--ai-processing-text);
    }

    .aireq-badge.completed {
        background: var(--ai-completed-bg);
        color: var(--ai-completed-text);
    }

    .aireq-badge.rejected {
        background: var(--ai-rejected-bg);
        color: var(--ai-rejected-text);
    }

    .aireq-badge.failed {
        background: var(--ai-failed-bg);
        color: var(--ai-failed-text);
    }

.aireq-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.aireq-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--ai-radius);
    font-size: 12px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background .15s, opacity .15s, transform .1s;
    white-space: nowrap;
}

    .aireq-btn:disabled {
        opacity: .5;
        cursor: not-allowed;
    }

    .aireq-btn:active:not(:disabled) {
        transform: scale(.97);
    }

    .aireq-btn.approve {
        background: #dcfce7;
        color: #166534;
    }

        .aireq-btn.approve:hover:not(:disabled) {
            background: #bbf7d0;
        }

    .aireq-btn.reject {
        background: #fee2e2;
        color: #991b1b;
    }

        .aireq-btn.reject:hover:not(:disabled) {
            background: #fecaca;
        }

    .aireq-btn.full {
        flex: 1;
        justify-content: center;
        padding: 8px 12px;
    }

    .aireq-btn.xs {
        width: 26px;
        height: 26px;
        padding: 0;
    }

/* ═══════════════════════════════════
   LAYOUT: GRID
═══════════════════════════════════ */

.aireq-body--grid {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.aireq-grid {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    align-content: start;
}

.aireq-grid-card {
    background: var(--bg-primary, #fff);
    border-radius: var(--ai-radius-lg);
    border: 1.5px solid var(--border, #e5e7eb);
    overflow: hidden;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .1s;
}

    .aireq-grid-card:hover {
        border-color: #a5b4fc;
        box-shadow: 0 4px 12px rgba(99,102,241,.12);
        transform: translateY(-1px);
    }

    .aireq-grid-card.selected {
        border-color: #6366f1 !important;
    }

    .aireq-grid-card.skeleton {
        height: 220px;
        background: linear-gradient(90deg, var(--bg-secondary, #f3f4f6) 25%, #eee 50%, var(--bg-secondary, #f3f4f6) 75%);
        background-size: 200% 100%;
        animation: ai-shimmer 1.4s infinite;
        border: none;
    }

    .aireq-grid-card.status-pending {
        border-top: 3px solid var(--ai-pending);
    }

    .aireq-grid-card.status-processing {
        border-top: 3px solid var(--ai-processing);
    }

    .aireq-grid-card.status-completed {
        border-top: 3px solid var(--ai-completed);
    }

    .aireq-grid-card.status-rejected {
        border-top: 3px solid var(--ai-rejected);
    }

    .aireq-grid-card.status-failed {
        border-top: 3px solid var(--ai-failed);
    }

.aireq-grid-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--bg-secondary, #f3f4f6);
}

.aireq-grid-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

    .aireq-grid-img.img-dimmed {
        opacity: .58;
        filter: grayscale(12%);
    }

.aireq-grid-img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

    .aireq-grid-img-placeholder.pending {
        background: var(--ai-pending-bg);
    }

    .aireq-grid-img-placeholder.processing {
        background: var(--ai-processing-bg);
    }

    .aireq-grid-img-placeholder.completed {
        background: var(--ai-completed-bg);
    }

    .aireq-grid-img-placeholder.rejected,
    .aireq-grid-img-placeholder.failed {
        background: var(--ai-rejected-bg);
    }

.aireq-grid-pending-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.36);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

    .aireq-grid-pending-overlay.processing {
        background: rgba(99,102,241,.35);
    }

.aireq-grid-status-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
}

    .aireq-grid-status-badge.pending {
        background: var(--ai-pending-bg);
        color: var(--ai-pending-text);
    }

    .aireq-grid-status-badge.processing {
        background: var(--ai-processing-bg);
        color: var(--ai-processing-text);
    }

    .aireq-grid-status-badge.completed {
        background: var(--ai-completed-bg);
        color: var(--ai-completed-text);
    }

    .aireq-grid-status-badge.rejected {
        background: var(--ai-rejected-bg);
        color: var(--ai-rejected-text);
    }

    .aireq-grid-status-badge.failed {
        background: var(--ai-failed-bg);
        color: var(--ai-failed-text);
    }

.aireq-grid-quick-actions {
    position: absolute;
    bottom: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity .15s;
}

.aireq-grid-img-wrap:hover .aireq-grid-quick-actions {
    opacity: 1;
}

.aireq-grid-info {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.aireq-grid-user {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary, #111827);
}

.aireq-grid-prompt {
    font-size: 11px;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aireq-grid-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary, #6b7280);
}

.aireq-detail--side {
    width: 340px;
    flex-shrink: 0;
    border-left: 1px solid var(--border, #e5e7eb);
    background: var(--bg-primary, #fff);
    overflow-y: auto;
}

/* ═══════════════════════════════════
   LAYOUT: KANBAN
═══════════════════════════════════ */

.aireq-kanban {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    align-items: flex-start;
}

.aireq-kanban-col {
    flex: 0 0 210px;
    background: var(--bg-secondary, #f3f4f6);
    border-radius: var(--ai-radius-lg);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 230px);
    overflow: hidden;
}

.aireq-kanban-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: var(--ai-radius-lg) var(--ai-radius-lg) 0 0;
    flex-shrink: 0;
}

    .aireq-kanban-col-header.pending {
        background: var(--ai-pending-bg);
    }

    .aireq-kanban-col-header.processing {
        background: var(--ai-processing-bg);
    }

    .aireq-kanban-col-header.completed {
        background: var(--ai-completed-bg);
    }

    .aireq-kanban-col-header.rejected,
    .aireq-kanban-col-header.failed {
        background: var(--ai-rejected-bg);
    }

.kanban-col-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.aireq-kanban-col-header.pending .kanban-col-title {
    color: var(--ai-pending-text);
}

.aireq-kanban-col-header.processing .kanban-col-title {
    color: var(--ai-processing-text);
}

.aireq-kanban-col-header.completed .kanban-col-title {
    color: var(--ai-completed-text);
}

.aireq-kanban-col-header.rejected .kanban-col-title,
.aireq-kanban-col-header.failed .kanban-col-title {
    color: var(--ai-rejected-text);
}

.kanban-col-count {
    font-size: 11px;
    font-weight: 700;
    background: rgba(0,0,0,.1);
    padding: 1px 7px;
    border-radius: 10px;
}

.aireq-kanban-cards {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.aireq-kanban-card {
    background: var(--bg-primary, #fff);
    border-radius: var(--ai-radius);
    border: 1.5px solid var(--border, #e5e7eb);
    overflow: hidden;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
    position: relative;
}

    .aireq-kanban-card:hover {
        border-color: #a5b4fc;
        box-shadow: 0 2px 8px rgba(99,102,241,.1);
    }

    .aireq-kanban-card.selected {
        border-color: #6366f1 !important;
    }

    .aireq-kanban-card.skeleton {
        height: 90px;
        background: linear-gradient(90deg, var(--bg-secondary, #f3f4f6) 25%, #eee 50%, var(--bg-secondary, #f3f4f6) 75%);
        background-size: 200% 100%;
        animation: ai-shimmer 1.4s infinite;
        border: none;
    }

.kanban-card-thumb {
    width: 100%;
    height: 90px;
    overflow: hidden;
    background: var(--bg-secondary, #f3f4f6);
}

    .kanban-card-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

        .kanban-card-thumb img.img-dimmed {
            opacity: .52;
            filter: grayscale(10%);
        }

.kanban-card-body {
    padding: 7px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kanban-card-user {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary, #111827);
}

.kanban-card-prompt {
    font-size: 11px;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanban-card-meta {
    font-size: 10px;
    color: var(--text-secondary, #6b7280);
}

.kanban-card-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 3px;
    opacity: 0;
    transition: opacity .15s;
}

.aireq-kanban-card:hover .kanban-card-actions {
    opacity: 1;
}

.kanban-empty {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
    padding: 20px 0;
}

.aireq-detail-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 16px;
}

.aireq-detail--modal {
    width: 360px;
    max-height: calc(100vh - 32px);
    background: var(--bg-primary, #fff);
    border-radius: var(--ai-radius-lg);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

/* ═══════════════════════════════════
   SHARED: Detail panel (admin)
═══════════════════════════════════ */

.aireq-detail {
    border-left: 1px solid var(--border, #e5e7eb);
    background: var(--bg-primary, #fff);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.aireq-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary, #111827);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 1;
}

.aireq-detail-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    background: var(--bg-secondary, #f9fafb);
}

.aireq-detail-img-col {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

    .aireq-detail-img-col img {
        width: 100%;
        aspect-ratio: 1;
        object-fit: contain;
        border-radius: 6px;
        background: #ffffff;
        border: 1px solid var(--border, #e5e7eb);
    }

.aireq-detail-actions {
    padding: 12px 16px;
    border-top: 1px solid var(--border, #e5e7eb);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ============================================================
   DARK MODE
   ============================================================ */

@media (prefers-color-scheme: dark) {
    .sidebar-nav .nav-item.active {
        background: #2e1065;
        color: #a5b4fc;
    }

    .aireq-row.selected {
        background: #1e1b4b;
        border-color: #6366f1;
    }

    .aireq-kanban-col-header.pending {
        background: #451a03;
    }

    .aireq-kanban-col-header.processing {
        background: #1e3a5f;
    }

    .aireq-kanban-col-header.completed {
        background: #052e16;
    }

    .aireq-kanban-col-header.rejected,
    .aireq-kanban-col-header.failed {
        background: #450a0a;
    }

    .aireq-btn.approve {
        background: #052e16;
        color: #86efac;
    }

        .aireq-btn.approve:hover:not(:disabled) {
            background: #14532d;
        }

    .aireq-btn.reject {
        background: #450a0a;
        color: #fca5a5;
    }

        .aireq-btn.reject:hover:not(:disabled) {
            background: #7f1d1d;
        }

    .aireq-model-row.selected {
        border-color: #6366f1;
        background: #2e1065;
    }

    .gallery-layout-btn.active {
        background: rgba(255,255,255,.1);
    }

    .aireq-summary-card.filter-active {
        box-shadow: 0 0 0 2px #a5b4fc;
    }

    .gen-submitted-prompt {
        background: rgba(255,255,255,.06);
    }
}

/* ── Transparent PNG (Fabric canvas export) — luôn cần white bg ──────────
   Áp dụng cho bất kỳ img nào hiển thị ảnh canvas/result trong các component.
   ─────────────────────────────────────────────────────────────────────── */

/* Gallery popup cards */
.gallery-card-img,
.gallery-card-img.placeholder .pending-canvas {
    background: #ffffff;
}

/* Admin list thumbnail */
.aireq-thumb img {
    background: #ffffff;
}

/* Admin grid card image */
.aireq-grid-img {
    background: #ffffff;
}

/* Admin kanban card thumb */
.kanban-card-thumb img {
    background: #ffffff;
}

/* Admin detail panel — compare images (canvas vs result) */
.aireq-detail-img-col img {
    background: #ffffff !important; /* override dark #222 */
}

/* Gallery detail full-res */
.gallery-detail-img {
    background: #ffffff;
}

/* Checkerboard util class — dùng khi muốn hiện rõ vùng transparent */
.img-transparent-bg {
    background-image: linear-gradient(45deg, #d9d9d9 25%, transparent 25%), linear-gradient(-45deg, #d9d9d9 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #d9d9d9 75%), linear-gradient(-45deg, transparent 75%, #d9d9d9 75%);
    background-size: 12px 12px;
    background-position: 0 0, 0 6px, 6px -6px, -6px 0;
    background-color: #f5f5f5;
}

/* ── Animations ── */
@keyframes ai-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}
