@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --ibis-blue: #003b7a;
    --ibis-blue-dark: #002557;
    --ibis-blue-light: #e8f0fb;
    --ibis-red: #e30613;
    --ibis-red-light: #fdecea;
    --bg: #f0f2f7;
    --card: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --sidebar-w: 260px;
    --radius: 14px;
    --shadow: 0 2px 12px rgba(0,59,122,0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

/* ── LOGIN ── */
.login-body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(145deg, var(--ibis-blue-dark) 0%, var(--ibis-blue) 60%, #1a5faa 100%);
}

.login-card {
    background: white;
    padding: 44px 40px;
    border-radius: 20px;
    width: 360px;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0,0,0,0.28);
}

.login-card img { width: 160px; margin-bottom: 8px; }

.login-card h2 {
    color: var(--ibis-blue);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 28px;
    letter-spacing: 0.02em;
}

/* ── LAYOUT ── */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--ibis-blue);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    z-index: 100;
    box-shadow: 3px 0 20px rgba(0,0,0,0.15);
}

.sidebar-logo {
    padding: 28px 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    text-align: center;
}

.sidebar-logo img {
    width: 130px;
    background: white;
    border-radius: 10px;
    padding: 8px 12px;
}

.sidebar-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    padding: 20px 24px 8px;
}

.sidebar nav {
    flex: 1;
    padding: 4px 12px;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.82);
    text-decoration: none;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background 0.15s, color 0.15s;
}

.sidebar a:hover {
    background: rgba(255,255,255,0.12);
    color: white;
}

.sidebar a.active {
    background: rgba(255,255,255,0.18);
    color: white;
    font-weight: 600;
}

.sidebar a .icon {
    font-size: 17px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.12);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
}

.sidebar-footer a:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* ── MAIN ── */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 36px 40px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--ibis-blue);
    margin: 0 0 4px;
}

.page-header p {
    color: var(--text-muted);
    margin: 0;
    font-size: 14px;
}

/* ── CARDS ── */
.card {
    background: var(--card);
    padding: 28px;
    border-radius: var(--radius);
    margin-bottom: 22px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--ibis-blue);
    margin: 0 0 18px;
}

/* ── KPI GRID ── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.kpi-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px 26px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-left: 4px solid var(--ibis-blue);
}

.kpi-card .kpi-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.kpi {
    font-size: 32px;
    font-weight: 700;
    color: var(--ibis-blue);
    line-height: 1;
}

/* ── FORMS ── */
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin: 14px 0 5px;
}

input, select, textarea {
    padding: 11px 14px;
    width: 100%;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: #fafbff;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--ibis-blue);
    box-shadow: 0 0 0 3px rgba(0,59,122,0.1);
    background: white;
}

button {
    padding: 12px 22px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.15s, transform 0.1s;
}

button:active { transform: scale(0.98); }

.btn-primary {
    background: var(--ibis-blue);
    color: white;
    width: 100%;
    margin-top: 18px;
}

.btn-primary:hover { background: var(--ibis-blue-dark); }

.btn-danger {
    background: var(--ibis-red);
    color: white;
    padding: 7px 14px;
    font-size: 13px;
    width: auto;
}

.btn-danger:hover { background: #c0050f; }

.btn-search {
    background: var(--ibis-blue);
    color: white;
    width: auto;
    margin-top: 0;
}

.btn-search:hover { background: var(--ibis-blue-dark); }

/* ── SEARCH BAR ── */
.search-bar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.search-bar input, .search-bar select {
    flex: 1;
    min-width: 160px;
    margin: 0;
}

/* ── TABLE ── */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead tr {
    background: var(--ibis-blue-light);
}

th {
    padding: 12px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ibis-blue);
    border-bottom: 2px solid var(--border);
}

td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: none; }

/* ── BADGE ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-blue {
    background: var(--ibis-blue-light);
    color: var(--ibis-blue);
}

/* ── LINK ── */
.link {
    color: var(--ibis-blue);
    text-decoration: none;
    font-weight: 500;
}

.link:hover { text-decoration: underline; }

/* ── ALERT ── */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 14px;
    font-weight: 500;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.alert-info {
    background: var(--ibis-blue-light);
    color: var(--ibis-blue);
    border-left: 4px solid var(--ibis-blue);
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

/* ── UPLOAD AREA ── */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    background: #fafbff;
    transition: border-color 0.2s;
}

.upload-area:hover { border-color: var(--ibis-blue); }
.upload-area input[type=file] { cursor: pointer; }

/* ── OCR TEXT ── */
.ocr-text {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 320px;
    overflow-y: auto;
    color: var(--text-muted);
}

/* ── SPINNER ── */
.spinner-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,59,122,0.55);
    z-index: 999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 16px;
}

.spinner-overlay.active { display: flex; }

.spinner {
    width: 52px; height: 52px;
    border: 5px solid rgba(255,255,255,0.25);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-text {
    color: white;
    font-size: 15px;
    font-weight: 600;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── BOTTOM NAV MÓVIL ── */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--ibis-blue);
    z-index: 200;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.2);
    padding: 0;
}

.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    padding: 8px 2px;
    font-size: 9px;
    font-weight: 500;
    transition: color 0.15s;
}

.bottom-nav a.active, .bottom-nav a:hover {
    color: white;
}

.bottom-nav a .icon {
    font-size: 20px;
    line-height: 1;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .bottom-nav { display: flex; }

    .main {
        margin-left: 0;
        padding: 16px 14px 90px; /* espacio para bottom nav */
    }

    .page-header h1 { font-size: 20px; }

    .grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .kpi { font-size: 24px; }

    .card { padding: 16px; }

    /* Tablas scrollables en móvil */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    table { font-size: 12px; min-width: unset; width: 100%; }

    th, td { padding: 8px 10px; }

    /* Ocultar columnas menos importantes */
    .hide-mobile { display: none; }

    /* Search bar en columna */
    .search-bar {
        flex-direction: column;
        gap: 8px;
    }

    .search-bar input,
    .search-bar select {
        min-width: unset;
    }

    /* Grids de dashboard en columna */
    div[style*="grid-template-columns:2fr 1fr"],
    div[style*="grid-template-columns:1fr 1fr"] {
        display: flex !important;
        flex-direction: column !important;
    }

    /* Login */
    .login-card {
        width: 92%;
        padding: 32px 24px;
    }

    /* Formulario subida */
    .upload-area { padding: 20px; }

    /* Botones más grandes para dedos */
    button, .btn-primary, .btn-search {
        min-height: 44px;
    }
}
