/* ==========================================================================
   Zabex AI — Theme CSS: Sóbrio SaaS Dark Mode (Linear / Stripe style)
   Agente 10: Front-end, UI/UX & Design System
   ========================================================================== */

:root {
    /* Paleta Dark Mode Sóbria Linear/Stripe (Padrão) */
    --bg-base: #0b0f19;
    --surface-default: #111827;
    --surface-elevated: #1f2937;
    --border-subtle: rgba(55, 65, 81, 0.7);
    --border-default: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    /* Semântica e Status */
    --status-success: #10b981;
    --status-success-bg: rgba(16, 185, 129, 0.12);
    --status-success-border: rgba(16, 185, 129, 0.3);

    --status-warning: #f59e0b;
    --status-warning-bg: rgba(245, 158, 11, 0.12);
    --status-warning-border: rgba(245, 158, 11, 0.3);

    --status-danger: #ef4444;
    --status-danger-bg: rgba(239, 68, 68, 0.12);
    --status-danger-border: rgba(239, 68, 68, 0.3);

    --status-info: #3b82f6;
    --status-info-bg: rgba(59, 130, 246, 0.12);
    --status-info-border: rgba(59, 130, 246, 0.3);

    /* Medidas e Controles de Gaveta */
    --drawer-control-height: var(--control-height-md);
    --drawer-radius: var(--radius-sm);
}

:root[data-theme="light"] {
    --bg-base: #f8fafc;
    --surface-default: #ffffff;
    --surface-elevated: #f1f5f9;
    --border-subtle: #e2e8f0;
    --border-default: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --status-success: #059669;
    --status-success-bg: #ecfdf5;
    --status-success-border: #a7f3d0;

    --status-warning: #d97706;
    --status-warning-bg: #fffbeb;
    --status-warning-border: #fde68a;

    --status-danger: #dc2626;
    --status-danger-bg: #fef2f2;
    --status-danger-border: #fecaca;

    --status-info: #2563eb;
    --status-info-bg: #eff6ff;
    --status-info-border: #bfdbfe;
}

/* Aplicação na Casca e Superfícies Elevadas */
body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Gavetas e Diálogos no estilo Linear */
dialog::backdrop {
    background: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
}

.drawer,
.entity-drawer,
dialog.drawer {
    --control-height: var(--control-height-md);
    --radius-button: var(--radius-sm);
    background-color: var(--surface-default);
    border: none !important;
    border-left: 1px solid var(--border-subtle) !important;
    box-shadow: -10px 0 35px rgba(0, 0, 0, 0.3) !important;
    color: var(--text-primary);
    width: min(720px, 92vw) !important;
    max-width: 760px !important;
    box-sizing: border-box !important;
}

dialog.drawer.drawer-half {
    width: min(720px, 92vw) !important;
    max-width: 760px !important;
}

dialog.drawer.drawer-wide {
    width: min(920px, 95vw) !important;
    max-width: 960px !important;
}

.drawer-content {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    max-height: 100vh !important;
    box-sizing: border-box !important;
}

.drawer-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 16px 24px !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    background: var(--surface-default) !important;
    flex-shrink: 0 !important;
}

.drawer-body {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 24px !important;
    box-sizing: border-box !important;
}

.entity-drawer-head {
    background-color: var(--surface-default);
    border-bottom: 1px solid var(--border-subtle);
}

.entity-drawer-title {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entity-drawer .summary-card {
    background-color: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
}

.entity-drawer .panel-section {
    border-top: 1px solid var(--border-subtle);
    padding-top: var(--space-4);
}

.entity-drawer .panel-section:first-of-type {
    border-top: none;
    padding-top: 0;
}

/* Controles dentro da Gaveta de Anúncio */
.entity-drawer .field-box,
.entity-drawer input[type="text"],
.entity-drawer input[type="number"],
.entity-drawer select,
.entity-drawer button[type="submit"] {
    border-radius: var(--radius-sm);
}

/* ---------- Componente de Progresso em Tempo Real (SSE) ---------- */
.batch-progress-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    margin-bottom: var(--space-4);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.batch-progress-bar .progress-track {
    width: 100%;
    height: 6px;
    background: rgba(55, 65, 81, 0.5);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.batch-progress-bar .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
    border-radius: 999px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.batch-progress-bar .progress-status-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Auto-fadeout suave após 2 segundos ao concluir (100%) */
.batch-progress-bar:has(.progress-fill.is-complete),
.batch-progress-bar.is-complete {
    animation: sseFadeOutProgress 0.6s cubic-bezier(0.16, 1, 0.3, 1) 2s forwards;
}

@keyframes sseFadeOutProgress {
    0% {
        opacity: 1;
        transform: translateY(0);
        max-height: 80px;
        margin-bottom: var(--space-4);
    }
    99% {
        opacity: 0;
        transform: translateY(-6px);
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        margin-bottom: 0;
        border-color: transparent;
    }
    100% {
        opacity: 0;
        display: none;
        visibility: hidden;
    }
}

/* Formulário de Edição Lateral Cirúrgico */
.drawer-edit-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-top: var(--space-4);
    padding: var(--space-4);
    background: var(--surface-default);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.drawer-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.drawer-field-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-secondary);
    min-width: 0;
}

.drawer-label-text {
    display: block;
    min-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
}

.drawer-input-control {
    display: block;
    width: 100%;
    height: var(--control-height-md);
    padding: 0 12px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--bg-base);
    color: var(--text-primary);
    font-size: var(--text-sm);
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.drawer-input-control:focus {
    outline: none;
    border-color: var(--color-focus);
    box-shadow: 0 0 0 2px rgba(47, 107, 255, 0.2);
}

.drawer-input-control:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--surface-elevated);
}

.drawer-textarea.drawer-input-control {
    height: auto;
    min-height: 84px;
    padding: 8px 12px;
    line-height: 1.5;
    resize: vertical;
}

.drawer-attrs-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
}

.drawer-section-subtitle {
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.drawer-attrs-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
}

@media (max-width: 600px) {
    .drawer-attrs-grid {
        grid-template-columns: 1fr;
    }
}

.drawer-edit-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-top: var(--space-3);
    margin-top: var(--space-2);
    border-top: 1px solid var(--border-subtle);
}

.drawer-edit-actions .btn {
    height: var(--control-height-md);
    border-radius: var(--radius-sm);
    padding: 0 16px;
    font-weight: var(--weight-semibold);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Minimalist SaaS Global Overhauls */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 13px;
    padding: 0 14px;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background: #3b82f6 !important;
    border-color: #3b82f6 !important;
    color: #ffffff !important;
    box-shadow: 0 1px 2px rgba(59, 130, 246, 0.3) !important;
}

.btn-primary:hover {
    background: #2563eb !important;
    border-color: #2563eb !important;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4) !important;
    transform: translateY(-1px) !important;
}

.btn-secondary {
    background: var(--surface-elevated) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

.btn-secondary:hover {
    background: var(--surface-hover) !important;
    border-color: var(--border-default) !important;
}

.page-header {
    margin-bottom: 20px !important;
}

.page-header h1 {
    font-size: 24px !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em !important;
    color: var(--text-primary) !important;
}

.page-header p {
    font-size: 13px !important;
    color: var(--text-muted) !important;
    margin-top: 4px !important;
}
