/* ── Fontes & Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    transition: background 0.2s, color 0.2s;
}

/* ── Variáveis Dark (padrão) ─────────────────────────────────────────────────── */
/* Paleta BL: Azul #080738 | Dourado escuro #d9a14e | Dourado claro #f8d786 */
/* Branco #f2f4f8 | Preto #121212                                             */
.theme-dark {
    --bg: #0b0a45;
    --bg-card: #10104f;
    --bg-input: #16156a;
    --bg-hover: #1c1b7a;
    --border: #2e2c85;
    --text: #f2f4f8;
    --text-muted: #a8a8c8;
    --text-faint: #5a5a8a;
    --accent: #d9a14e;
    --accent-hover: #f8d786;
    --accent-soft: rgba(217,161,78,0.15);
    --success: #10b981;
    --success-soft: rgba(16,185,129,0.15);
    --warning: #f8d786;
    --warning-soft: rgba(248,215,134,0.15);
    --error: #ef4444;
    --error-soft: rgba(239,68,68,0.15);
    --info: #60a5fa;
    --info-soft: rgba(96,165,250,0.15);
    --shadow: 0 4px 24px rgba(0,0,0,0.5);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
    --radius: 10px;
    --radius-sm: 6px;
    --icon-color: #d9a14e; /* dourado no tema dark */
}

/* ── Variáveis Light ─────────────────────────────────────────────────────────── */
.theme-light {
    --bg: #f2f4f8;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;
    --bg-hover: #eef0f6;
    --border: #dde0ec;
    --text: #121212;
    --text-muted: #4a4a6a;
    --text-faint: #9090b0;
    --accent: #d9a14e;
    --accent-hover: #b8832e;
    --accent-soft: rgba(217,161,78,0.12);
    --success: #059669;
    --success-soft: rgba(5,150,105,0.1);
    --warning: #b8832e;
    --warning-soft: rgba(184,131,46,0.1);
    --error: #dc2626;
    --error-soft: rgba(220,38,38,0.1);
    --info: #2563eb;
    --info-soft: rgba(37,99,235,0.1);
    --shadow: 0 4px 24px rgba(8,7,56,0.1);
    --shadow-sm: 0 2px 8px rgba(8,7,56,0.07);
    --radius: 10px;
    --radius-sm: 6px;
    --icon-color: #080738; /* azul escuro no tema light */
}

body {
    background: var(--bg);
    color: var(--text);
}

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
}

.sidebar {
    width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

    .sidebar-logo .logo-icon {
        width: 32px;
        height: 32px;
        background: var(--accent);
        border-radius: var(--radius-sm);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
    }

    .sidebar-logo span {
        font-weight: 700;
        font-size: 16px;
        color: var(--text);
    }

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 13.5px;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

    .nav-item:hover {
        background: var(--bg-hover);
        color: var(--text);
    }

    .nav-item.active {
        background: var(--accent-soft);
        color: var(--accent);
    }

    .nav-item .nav-icon {
        font-size: 16px;
        width: 20px;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

/* ── Ícones SVG inline (componente Icon.razor) ───────────────────────────────── */
/* Cor automática: dourado no dark, azul escuro no light via --icon-color      */
.nav-icon svg {
    color: var(--icon-color);
}

.nav-item.active .nav-icon svg {
    color: var(--accent);
}

.theme-toggle svg {
    color: var(--icon-color);
}

.alert svg {
    color: inherit;
}

.nav-section {
    padding: 16px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.main-content {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-body {
    padding: 24px;
    flex: 1;
    background: var(--bg);
    color: var(--text);
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-weight: 600;
    font-size: 15px;
}

/* ── Botões ───────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.15s, opacity 0.15s, transform 0.1s;
    text-decoration: none;
    white-space: nowrap;
}

    .btn:active:not(:disabled) {
        transform: scale(0.97);
    }

    .btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

/* Botão primário: dourado escuro com texto escuro para contraste */
.btn-primary {
    background: var(--accent);
    color: #121212;
}

    .btn-primary:hover:not(:disabled) {
        background: var(--accent-hover);
        color: #121212;
    }

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

    .btn-secondary:hover:not(:disabled) {
        background: var(--bg-input);
    }

.btn-danger {
    background: var(--error-soft);
    color: var(--error);
}

    .btn-danger:hover:not(:disabled) {
        background: var(--error);
        color: #fff;
    }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

    .btn-ghost:hover:not(:disabled) {
        background: var(--bg-hover);
        color: var(--text);
    }

.btn-sm {
    padding: 5px 10px;
    font-size: 12.5px;
}

.btn-icon {
    padding: 7px;
}

/* ── Formulário ──────────────────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 14px;
}

.form-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 8px 12px;
    font-size: 13.5px;
    font-family: inherit;
    width: 100%;
    transition: border-color 0.15s;
    outline: none;
}

    .form-control:focus {
        border-color: var(--accent);
    }

    .form-control::placeholder {
        color: var(--text-faint);
    }

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

    .form-check input[type="checkbox"] {
        accent-color: var(--accent);
        width: 15px;
        height: 15px;
    }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-queued {
    background: var(--text-faint);
    color: var(--bg);
    opacity: 0.7;
}

.badge-running {
    background: var(--info-soft);
    color: var(--info);
}

.badge-done {
    background: var(--success-soft);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.badge-error {
    background: var(--error-soft);
    color: var(--error);
}

/* ── Tabela ──────────────────────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 9px 12px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: left;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-hover);
}

/* ── Modal / Drawer ──────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    animation: fadeIn 0.15s ease;
}

.drawer {
    width: 520px;
    max-width: 95vw;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    animation: slideIn 0.2s ease;
    overflow: hidden;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.drawer-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.drawer-title {
    font-weight: 600;
    font-size: 15px;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.drawer-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Alert / Toast ───────────────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-error {
    background: var(--error-soft);
    color: var(--error);
    border: 1px solid var(--error);
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid var(--success);
}

.alert-info {
    background: var(--info-soft);
    color: var(--info);
    border: 1px solid var(--info);
}

/* ── Progress bar ────────────────────────────────────────────────────────────── */
.progress-bar-wrap {
    background: var(--bg-hover);
    border-radius: 999px;
    height: 6px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.4s ease;
}

/* ── Misc ────────────────────────────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

.text-muted {
    color: var(--text-muted);
}

.text-sm {
    font-size: 12.5px;
}

.text-xs {
    font-size: 11.5px;
}

.font-mono {
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 12px;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 8px;
}

.gap-3 {
    gap: 12px;
}

.mt-1 {
    margin-top: 4px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-4 {
    margin-top: 16px;
}

.mb-4 {
    margin-bottom: 16px;
}

.w-full {
    width: 100%;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

    .empty-state .empty-icon {
        font-size: 36px;
        margin-bottom: 12px;
    }

    .empty-state p {
        font-size: 14px;
        margin-bottom: 16px;
    }

/* ── Toggle theme button ─────────────────────────────────────────────────────── */
.theme-toggle {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: color 0.15s, background 0.15s;
}

    .theme-toggle:hover {
        color: var(--accent);
        background: var(--accent-soft);
    }

/* ── Login page ──────────────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
    width: 380px;
    box-shadow: var(--shadow);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

    .login-logo .logo-icon {
        width: 38px;
        height: 38px;
        background: var(--accent);
        border-radius: var(--radius-sm);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
    }

    .login-logo h1 {
        font-size: 20px;
        font-weight: 700;
        color: var(--text);
    }

/* ── Upload drop zone ────────────────────────────────────────────────────────── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: var(--bg-input);
}

    .drop-zone:hover, .drop-zone.drag-over {
        border-color: var(--accent);
        background: var(--accent-soft);
    }

    .drop-zone .drop-icon {
        font-size: 36px;
        margin-bottom: 10px;
    }

    .drop-zone p {
        color: var(--text-muted);
        font-size: 13.5px;
    }

    .drop-zone .drop-hint {
        font-size: 12px;
        color: var(--text-faint);
        margin-top: 4px;
    }

/* ── Execution card ──────────────────────────────────────────────────────────── */
.exec-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 10px;
}

.exec-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 10px;
}

.exec-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.exec-stats {
    display: flex;
    gap: 16px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Spinner ─────────────────────────────────────────────────────────────────── */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Splash loader ───────────────────────────────────────────────────────────── */
.splash-loader {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: #a8a8c8;
    background: #0b0a45;
}

.splash-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #2e2c85;
    border-top-color: #d9a14e;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ── Blazor error UI ─────────────────────────────────────────────────────────── */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--error-soft);
    color: var(--error);
    border-top: 1px solid var(--error);
    padding: 10px 16px;
    font-size: 13px;
    z-index: 999;
}

    #blazor-error-ui .reload {
        color: var(--error);
        font-weight: 600;
    }

    #blazor-error-ui .dismiss {
        float: right;
        cursor: pointer;
        background: none;
        border: none;
        color: inherit;
    }

/* ── Scroll customizado ──────────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--accent);
    }

/* ── Grid helpers ────────────────────────────────────────────────────────────── */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
}

@media (max-width: 768px) {
    .sidebar {
        width: 0;
        overflow: hidden;
    }

    .main-content {
        margin-left: 0;
    }

    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
}

/* ── Banner de impersonate ───────────────────────────────────────────────────── */
.impersonate-bar {
    background: linear-gradient(90deg, #b8832e, #d9a14e);
    color: #121212;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
}

    .impersonate-bar strong {
        font-weight: 700;
    }
