/* ==========================================================================
   SAIM Automation Dashboard - Modern Clean Light Theme
   ========================================================================== */

:root {
    /* Base Backgrounds & Surfaces */
    --bg-page: #F8FAFC;         /* Slate 50 */
    --bg-surface: #FFFFFF;      /* Pure White */
    --bg-surface-subtle: #F1F5F9; /* Slate 100 */
    --bg-hover: #F8FAFC;        /* Light hover */
    
    /* Borders & Lines */
    --border-subtle: #F1F5F9;
    --border-color: #E2E8F0;    /* Slate 200 */
    --border-strong: #CBD5E1;   /* Slate 300 */
    
    /* Typography Colors */
    --text-heading: #0F172A;    /* Slate 900 */
    --text-body: #334155;       /* Slate 700 */
    --text-muted: #64748B;      /* Slate 500 */
    --text-subtle: #94A3B8;     /* Slate 400 */
    
    /* Brand Accent Colors */
    --primary: #4F46E5;         /* Indigo 600 */
    --primary-hover: #4338CA;   /* Indigo 700 */
    --primary-light: #EEF2FF;   /* Indigo 50 */
    --primary-border: #C7D2FE;  /* Indigo 200 */
    
    /* Functional Accents */
    --accent-blue: #0284C7;     /* Sky 600 */
    --accent-blue-bg: #E0F2FE;  /* Sky 100 */
    --accent-blue-border: #BAE6FD;
    
    --accent-indigo: #4F46E5;
    --accent-indigo-bg: #EEF2FF;
    --accent-indigo-border: #C7D2FE;
    
    --accent-amber: #D97706;    /* Amber 600 */
    --accent-amber-bg: #FEF3C7; /* Amber 100 */
    --accent-amber-border: #FDE68A;
    
    --accent-emerald: #059669;  /* Emerald 600 */
    --accent-emerald-bg: #D1FAE5; /* Emerald 100 */
    --accent-emerald-border: #A7F3D0;
    
    --accent-rose: #DC2626;     /* Red 600 */
    --accent-rose-bg: #FEE2E2;  /* Red 100 */
    --accent-rose-border: #FECACA;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 12px 24px -4px rgba(79, 70, 229, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
}

/* Reset & Global */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-page);
    color: var(--text-body);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Main Layout Structure */
.dashboard-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */
.sidebar {
    width: 270px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 20;
    box-shadow: var(--shadow-sm);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary) 0%, #6366F1 100%);
    color: white;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}

.logo-text h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.1;
}

.logo-text h2 span {
    color: var(--primary);
}

.logo-tag {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.nav-item i {
    font-size: 1.1rem;
    color: var(--text-subtle);
    transition: color 0.2s ease;
}

.nav-item:hover {
    background-color: var(--bg-surface-subtle);
    color: var(--text-heading);
}

.nav-item:hover i {
    color: var(--primary);
}

.nav-item.active {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active i {
    color: var(--primary);
}

.sidebar-footer {
    padding: 16px 14px;
    border-top: 1px solid var(--border-subtle);
}

.db-status-card {
    background-color: var(--bg-surface-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.db-status-icon {
    width: 32px;
    height: 32px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 0.95rem;
}

.db-status-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.db-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.db-name {
    font-size: 0.8rem;
    color: var(--text-heading);
    font-weight: 600;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-emerald);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.5);
    animation: pulse-light 2s infinite;
}

@keyframes pulse-light {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.4); }
    70% { transform: scale(1); box-shadow: 0 0 0 5px rgba(5, 150, 105, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.main-content {
    flex: 1;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background-color: var(--bg-page);
}

/* Top Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
}

.header-title h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.3px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.86rem;
    margin-top: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.btn-secondary {
    background-color: var(--bg-surface);
    color: var(--text-body);
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background-color: var(--bg-surface-subtle);
    border-color: var(--border-strong);
    color: var(--text-heading);
}

.btn-outline-danger {
    background-color: var(--bg-surface);
    color: var(--accent-rose);
    border-color: var(--accent-rose-border);
}

.btn-outline-danger:hover {
    background-color: var(--accent-rose-bg);
    border-color: var(--accent-rose);
    color: var(--accent-rose);
}

.btn-danger {
    background-color: var(--accent-rose);
    color: white;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.25);
}

.btn-danger:hover {
    background-color: #B91C1C;
}

.btn-icon {
    padding: 10px;
    width: 38px;
    height: 38px;
    background-color: var(--bg-surface);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.btn-icon:hover {
    background-color: var(--bg-surface-subtle);
    color: var(--primary);
    border-color: var(--primary-border);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.btn-text:hover {
    background-color: var(--primary-light);
}

/* Tabs Display */
.tab-content {
    display: none;
    animation: fadeInTab 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tab-content.active {
    display: block;
}

@keyframes fadeInTab {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   KPI Cards Grid
   ========================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.kpi-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px 20px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--shadow-card);
    transition: all 0.25s ease;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-border);
}

.kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.45rem;
    flex-shrink: 0;
}

.kpi-icon.blue { background: var(--accent-blue-bg); color: var(--accent-blue); border: 1px solid var(--accent-blue-border); }
.kpi-icon.indigo { background: var(--accent-indigo-bg); color: var(--accent-indigo); border: 1px solid var(--accent-indigo-border); }
.kpi-icon.amber { background: var(--accent-amber-bg); color: var(--accent-amber); border: 1px solid var(--accent-amber-border); }
.kpi-icon.emerald { background: var(--accent-emerald-bg); color: var(--accent-emerald); border: 1px solid var(--accent-emerald-border); }

.kpi-details {
    flex: 1;
}

.kpi-details h3 {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.kpi-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.2;
    margin: 3px 0;
}

.kpi-subtext {
    font-size: 0.75rem;
    color: var(--text-subtle);
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ==========================================================================
   Content Panels & Tables
   ========================================================================== */
.content-row {
    display: flex;
    gap: 24px;
}

.flex-2 { flex: 2; }
.flex-1 { flex: 1; }

.card-panel {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.full-height-panel {
    min-height: calc(100vh - 200px);
}

.panel-header {
    margin-bottom: 20px;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-title h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.12rem;
    font-weight: 600;
    color: var(--text-heading);
}

.title-icon {
    font-size: 1.15rem;
}

.text-indigo { color: var(--primary); }
.text-amber { color: var(--accent-amber); }

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Table Container & Elements */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    background-color: var(--bg-surface-subtle);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.data-table th:first-child {
    border-top-left-radius: var(--radius-sm);
    border-bottom-left-radius: var(--radius-sm);
    border-left: 1px solid var(--border-color);
}

.data-table th:last-child {
    border-top-right-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
    border-right: 1px solid var(--border-color);
}

.data-table td {
    padding: 14px 16px;
    font-size: 0.88rem;
    color: var(--text-body);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
    background-color: var(--bg-surface-subtle);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.badge.pendiente {
    background-color: var(--accent-amber-bg);
    color: var(--accent-amber);
    border: 1px solid var(--accent-amber-border);
}

.badge.notificado {
    background-color: var(--accent-blue-bg);
    color: var(--accent-blue);
    border: 1px solid var(--accent-blue-border);
}

.badge.reportado {
    background-color: #EDE9FE;
    color: #6D28D9;
    border: 1px solid #DDD6FE;
}

.badge.subsanado {
    background-color: var(--accent-emerald-bg);
    color: var(--accent-emerald);
    border: 1px solid var(--accent-emerald-border);
}

.badge.error {
    background-color: var(--accent-rose-bg);
    color: var(--accent-rose);
    border: 1px solid var(--accent-rose-border);
}

/* Live Pill */
.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background-color: var(--accent-emerald-bg);
    color: var(--accent-emerald);
    border: 1px solid var(--accent-emerald-border);
    border-radius: 9999px;
    font-size: 0.76rem;
    font-weight: 600;
}

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--bg-surface-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    width: 280px;
    transition: all 0.2s ease;
}

.search-box:focus-within {
    border-color: var(--primary);
    background-color: white;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.search-box i {
    color: var(--text-subtle);
    font-size: 0.9rem;
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    color: var(--text-heading);
    font-size: 0.88rem;
}

.search-box input::placeholder {
    color: var(--text-subtle);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    color: var(--text-subtle);
    margin-bottom: 12px;
}

.empty-state h4 {
    font-size: 1rem;
    color: var(--text-heading);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 360px;
    margin: 0 auto;
}

/* ==========================================================================
   Upload Area
   ========================================================================== */
.upload-card {
    max-width: 780px;
    margin: 0 auto;
    padding: 40px;
    text-align: center;
}

.upload-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    color: var(--text-heading);
    margin: 12px 0 8px;
}

.upload-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 540px;
    margin: 0 auto 28px;
    line-height: 1.5;
}

.upload-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: var(--accent-emerald-bg);
    color: var(--accent-emerald);
    border: 1px solid var(--accent-emerald-border);
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.upload-dropzone {
    border: 2px dashed var(--border-strong);
    background-color: var(--bg-surface-subtle);
    border-radius: var(--radius-xl);
    padding: 50px 30px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
    border-color: var(--primary);
    background-color: var(--primary-light);
    transform: scale(1.01);
}

.dropzone-icon {
    width: 64px;
    height: 64px;
    background-color: white;
    color: var(--primary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 16px;
    box-shadow: var(--shadow-card);
}

.upload-dropzone h3 {
    font-size: 1.1rem;
    color: var(--text-heading);
    font-weight: 600;
    margin-bottom: 4px;
}

.dropzone-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.dropzone-divider {
    display: flex;
    align-items: center;
    margin: 18px 0;
}

.dropzone-divider::before, .dropzone-divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.dropzone-divider span {
    padding: 0 12px;
    color: var(--text-subtle);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.upload-progress-container {
    margin-top: 24px;
    background-color: var(--bg-surface-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: left;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-heading);
    margin-bottom: 8px;
}

.progress-track {
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, #6366F1 100%);
    width: 0%;
    transition: width 0.3s ease;
}

/* ==========================================================================
   Logs Feed & Console
   ========================================================================== */
.logs-feed {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.log-item-card {
    background-color: var(--bg-surface-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    font-size: 0.84rem;
    transition: all 0.2s ease;
}

.log-item-card:hover {
    border-color: var(--border-strong);
    background-color: white;
}

.log-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.log-item-type {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background-color: var(--primary-light);
    color: var(--primary);
    text-transform: uppercase;
}

.log-item-time {
    font-size: 0.72rem;
    color: var(--text-subtle);
    font-family: monospace;
}

.log-item-details {
    color: var(--text-body);
    line-height: 1.4;
    word-break: break-word;
}

/* Full Console Box */
.console-box {
    background-color: #0F172A; /* Crisp deep slate terminal */
    color: #F1F5F9;
    border-radius: var(--radius-md);
    padding: 20px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    overflow-y: auto;
    height: 60vh;
    border: 1px solid #1E293B;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.console-line {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    line-height: 1.5;
}

.c-time { color: #94A3B8; }
.c-type { color: #818CF8; font-weight: bold; }
.c-msg { color: #34D399; }
.c-err { color: #F87171; }

/* ==========================================================================
   Modals & Toast
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeInModal 0.2s ease forwards;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background-color: white;
    border-radius: var(--radius-xl);
    padding: 32px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-icon-danger {
    width: 60px;
    height: 60px;
    background-color: var(--accent-rose-bg);
    color: var(--accent-rose);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 16px;
}

.modal-card h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.3rem;
    color: var(--text-heading);
    margin-bottom: 8px;
}

.modal-card p {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    background: white;
    color: var(--text-heading);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary);
    padding: 14px 22px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    transform: translateX(140%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1100;
    font-size: 0.88rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.show {
    transform: translateX(0);
}

.hidden {
    display: none !important;
}
