/* =========================================================
   Trámite Documentario — Hoja de estilos principal
   ========================================================= */

:root {
    --azul-oscuro: #0f2b46;
    --azul: #1a5c8a;
    --acento: #1a73e8;
    --fondo: #f1f5f9;
    --blanco: #ffffff;
    --texto: #1e293b;
    --texto-suave: #64748b;
    --borde: #e2e8f0;
    --verde: #15803d;
    --rojo: #b91c1c;
    --ambar: #b45309;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    overflow-x: hidden;
    max-width: 100%;
    width: 100%;
}
html { overflow-x: clip; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--fondo);
    color: var(--texto);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout general ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: var(--azul-oscuro);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-logo {
    padding: 22px 20px;
    font-size: 17px;
    font-weight: 700;
    color: var(--blanco);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.menu { padding: 14px 10px; flex: 1; }

.menu-item {
    display: block;
    padding: 11px 14px;
    margin-bottom: 4px;
    border-radius: 8px;
    color: #cbd5e1;
    font-weight: 500;
}
.menu-item:hover { background: rgba(255, 255, 255, 0.08); color: var(--blanco); text-decoration: none; }
.menu-item.active { background: var(--acento); color: var(--blanco); }

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

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: var(--blanco);
    border-bottom: 1px solid var(--borde);
    padding: 0 28px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-title { font-weight: 700; font-size: 17px; color: var(--azul-oscuro); }

.topbar-actions { display: flex; align-items: center; gap: 18px; }

.content { padding: 28px; max-width: 1280px; width: 100%; }

/* ---------- Campana de notificaciones ---------- */
.nav-bell { position: relative; }
.bell-link { font-size: 20px; display: inline-block; position: relative; color: var(--texto); }
.badge-bell {
    position: absolute;
    top: -6px;
    right: -10px;
    background: var(--rojo);
    color: var(--blanco);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.user-menu { display: flex; align-items: center; gap: 12px; }
.user-info { text-align: right; }
.user-name { display: block; font-weight: 600; font-size: 14px; }
.user-email { display: block; color: var(--texto-suave); font-size: 12px; }

/* ---------- Botones ---------- */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--borde);
    background: var(--blanco);
    color: var(--texto);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn-primary { background: var(--acento); border-color: var(--acento); color: var(--blanco); }
.btn-primary:hover { background: #1558b0; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Tarjetas y estadísticas ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }

.card-stat {
    background: var(--blanco);
    border: 1px solid var(--borde);
    border-radius: 12px;
    padding: 18px;
}
.stat-num { font-size: 30px; font-weight: 800; color: var(--azul-oscuro); }
.stat-label { color: var(--texto-suave); font-size: 13px; margin-top: 4px; }

.card {
    background: var(--blanco);
    border: 1px solid var(--borde);
    border-radius: 12px;
    margin-bottom: 24px;
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--borde);
    font-weight: 700;
    font-size: 15px;
}
.card-body { padding: 20px; }

.estados-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Encabezados de página ---------- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}
.page-header h1 { font-size: 24px; color: var(--azul-oscuro); }

.hint { color: var(--texto-suave); font-size: 13px; }
.empty { color: var(--texto-suave); padding: 16px 0; text-align: center; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--borde);
    color: var(--texto-suave);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--borde); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }

.acciones { white-space: nowrap; text-align: right; }
.acciones .btn { margin-left: 6px; }

/* ---------- Filtros ---------- */
.filtros { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.filtro label { display: block; font-size: 12px; color: var(--texto-suave); margin-bottom: 4px; }
.filtro-busqueda { flex: 1; min-width: 180px; }

/* ---------- Formularios ---------- */
.campo { margin-bottom: 16px; }
.campo label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }

.password-field { position: relative; }
.password-field .input { padding-right: 44px; }
.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--texto-suave);
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}
.password-toggle:hover { color: var(--texto); }
.password-toggle .eye-icon {
    width: 19px;
    height: 19px;
    display: block;
}
.password-toggle .eye-icon-off { display: none; }

.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--borde);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--blanco);
}
.input:focus { outline: 2px solid var(--acento); outline-offset: -1px; border-color: transparent; }
textarea.input { resize: vertical; }
.input-file { font-size: 14px; }

.error { color: var(--rojo); font-size: 13px; display: block; margin-top: 4px; }
.acciones-form { margin-top: 20px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.lista-archivos { margin-top: 10px; padding-left: 20px; color: var(--texto-suave); font-size: 13px; }

/* ---------- Detalles ---------- */
.detalles { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; }
.detalles dt { color: var(--texto-suave); font-weight: 600; }
.detalles dd { word-break: break-word; }

.fila {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--borde);
}
.fila:last-child { border-bottom: none; }
.fila .hint { display: block; }

/* ---------- Línea de tiempo ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--borde);
}
.timeline-item { position: relative; padding-bottom: 22px; }
.timeline-dot {
    position: absolute;
    left: -24px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--texto-suave);
    border: 3px solid var(--blanco);
    box-shadow: 0 0 0 2px var(--borde);
}
.dot-enviado, .dot-derivado, .dot-informe_solicitado { background: var(--acento); }
.dot-recibido, .dot-informe_emitido { background: var(--verde); }
.dot-observado { background: var(--ambar); }
.dot-notificado { background: #7c3aed; }
.dot-cerrado { background: var(--azul-oscuro); }
.dot-creado { background: var(--texto-suave); }

.timeline-content p { color: var(--texto); font-size: 14px; }
.timeline-comentario {
    margin-top: 4px;
    background: #f8fafc;
    border-left: 3px solid var(--acento);
    padding: 8px 12px;
    border-radius: 0 8px 8px 0;
    font-size: 13px;
}

/* ---------- Acciones ---------- */
.acciones-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .acciones-panel { grid-template-columns: 1fr; } }
.accion-form {
    border: 1px solid var(--borde);
    border-radius: 10px;
    padding: 14px;
    background: #fbfdff;
}
.accion-form h3 { font-size: 14px; margin-bottom: 10px; }
.accion-form .input { margin-bottom: 8px; }
.accion-form .btn { width: 100%; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-borrador { background: #e2e8f0; color: #334155; }
.badge-enviado { background: #dbeafe; color: #1d4ed8; }
.badge-recibido { background: #dcfce7; color: #15803d; }
.badge-en_evaluacion { background: #fef3c7; color: #b45309; }
.badge-observado { background: #ffedd5; color: #c2410c; }
.badge-notificado { background: #ede9fe; color: #6d28d9; }
.badge-cerrado { background: #e2e8f0; color: #334155; }
.badge-danger { background: #fee2e2; color: var(--rojo); }
.badge-rol { background: #e0f2fe; color: #0369a1; }
.badge-prioridad-alta { background: #fee2e2; color: var(--rojo); }
.badge-prioridad-normal { background: #e2e8f0; color: #334155; }
.badge-prioridad-baja { background: #dcfce7; color: #15803d; }

/* ---------- Alertas ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-weight: 500; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-danger { background: #fee2e2; color: #991b1b; }

/* ---------- Notificaciones ---------- */
.notificacion {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 4px;
    border-bottom: 1px solid var(--borde);
    color: var(--texto);
}
.notificacion:last-child { border-bottom: none; }
.notificacion.no-leida { background: #eff6ff; margin: 0 -12px; padding: 14px 12px; border-radius: 8px; }
.notificacion p { margin: 2px 0; }

/* ---------- Autenticación ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-x: hidden;
    max-width: 100%;
    min-width: 0;
}
.auth-card {
    background: var(--blanco);
    border: 1px solid var(--borde);
    overflow-x: hidden;
    border-radius: 14px;
    padding: 34px;
    width: 100%;
    max-width: 420px;
    min-width: 0;
    box-shadow: 0 8px 30px rgba(15, 43, 70, 0.08);
}
.auth-logo { font-size: 40px; text-align: center; margin-bottom: 8px; }
.auth-card h1 { text-align: center; font-size: 22px; color: var(--azul-oscuro); }
.auth-sub { text-align: center; color: var(--texto-suave); margin-bottom: 22px; }
.auth-link { text-align: center; margin-top: 18px; font-size: 14px; }
.auth-card, .auth-card form, .campo, .auth-card input, .auth-card .btn-list,
.auth-card h1, .auth-sub, .auth-link { max-width: 100%; overflow-wrap: break-word; word-break: break-word; min-width: 0; }
.check { font-weight: 400; display: flex; align-items: center; gap: 8px; }

/* ---------- Botón descargar aplicativo (PWA) ---------- */
.app-install {
    margin-top: 16px;
    text-align: center;
}
.btn-install {
    display: block;
    margin: 0 auto;
    padding: 5px 24px;
    background: #c62828;
    color: #ffffff;
    border: 1px solid #c62828;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: background 0.15s;
}
.btn-install:hover { background: #b71c1c; border-color: #b71c1c; }

.btn-install-help {
    display: block;
    margin: 10px auto 0;
    background: none;
    border: none;
    padding: 0;
    color: var(--acento);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.btn-install-help:hover { color: var(--azul-oscuro); }

/* ---------- Modal: Cómo instalar (fondo integrado) ---------- */
.install-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.install-modal.open { display: flex; }
.install-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 18, 32, 0.55);
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.install-modal-box {
    position: relative;
    background: #eef3f8;
    border: 1px solid #d6e0ea;
    border-radius: 16px;
    width: 100%;
    max-width: 340px;
    padding: 24px 22px 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
    animation: popIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes popIn { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.install-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 17px;
    color: var(--texto-suave);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}
.install-modal-close:hover { color: var(--azul-oscuro); }

.install-modal-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--azul-oscuro);
    margin-bottom: 3px;
    padding-right: 24px;
}
.install-modal-sub {
    font-size: 13px;
    color: var(--texto-suave);
    margin: 0 0 18px;
}

.install-steps {
    background: #f8fafc;
    border: 1px solid #e3ebf4;
    border-radius: 11px;
    padding: 16px 18px;
    margin-bottom: 20px;
}
.install-steps ol {
    margin: 0;
    padding: 0;
    list-style: none;
}
.install-steps li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed #e3ebf4;
}
.install-steps li:last-child { border-bottom: none; }
.step-num {
    font-size: 14px;
    font-weight: 700;
    color: var(--acento);
    line-height: 1.5;
    flex-shrink: 0;
    width: 14px;
}
.step-text {
    font-size: 14px;
    color: var(--texto);
    line-height: 1.5;
}
.step-text strong { color: var(--azul-oscuro); }

.install-modal-done {
    width: 100%;
    padding: 13px;
    background: var(--acento);
    border: none;
    border-radius: 11px;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}
.install-modal-done:hover { opacity: 0.93; }
.install-modal-done:active { transform: scale(0.98); }




/* ---------- Paginación (bootstrap-5) ---------- */
.pagination-wrap { margin-top: 18px; }
.pagination { display: flex; gap: 6px; list-style: none; flex-wrap: wrap; }
.page-item .page-link {
    display: block;
    padding: 7px 12px;
    border: 1px solid var(--borde);
    border-radius: 8px;
    color: var(--texto);
    font-size: 14px;
}
.page-item .page-link:hover { background: #f8fafc; text-decoration: none; }
.page-item.active .page-link { background: var(--acento); border-color: var(--acento); color: var(--blanco); }
.page-item.disabled .page-link { color: #cbd5e1; pointer-events: none; }

/* ---------- Sidebar mobile ---------- */
.hamburger {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 21;
    background: var(--azul-oscuro);
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    padding: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--blanco);
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
}
.hamburger-close {
    display: none;
    background: none;
    border: none;
    color: var(--blanco);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.hamburger-close:hover { background: rgba(255,255,255,0.1); }
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 19;
    transition: opacity 0.3s;
}
.sidebar-overlay.active { display: block; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .hamburger { display: flex; }
    .hamburger-close { display: block; }
    .sidebar-overlay.active { display: block; }

    .app { flex-direction: column; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 270px;
        height: 100vh;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-logo { padding: 18px 16px; font-size: 16px; }

    .main { margin-left: 0; }

    .topbar {
        padding: 0 16px 0 60px;
        height: 56px;
    }
    .topbar-title {
        font-size: 15px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .topbar-actions { gap: 10px; }

    .user-info { display: none; }

    .content { padding: 16px; }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .page-header h1 { font-size: 20px; }
    .page-header .btn { align-self: flex-start; }

    .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .card-stat { padding: 14px; }
    .stat-num { font-size: 24px; }

    .card-header { padding: 12px 16px; font-size: 14px; }
    .card-body { padding: 16px; }

    .detalles { grid-template-columns: 1fr; gap: 4px 0; }
    .detalles dt { margin-top: 8px; }
    .detalles dd { margin-bottom: 4px; }

    .acciones-panel { grid-template-columns: 1fr; }

    .filtros { flex-direction: column; gap: 10px; }
    .filtro { width: 100%; }
    .filtro-busqueda { min-width: 0; }

    .table-wrap { margin: 0 -16px; padding: 0; }
    .table-wrap .table { min-width: 0; }

    .fila { flex-direction: column; align-items: flex-start; gap: 8px; }

    .notificacion { flex-wrap: wrap; }
    .notificacion .badge { align-self: flex-start; flex-shrink: 0; }

    .timeline { padding-left: 22px; }
    .timeline-dot { left: -20px; width: 12px; height: 12px; }

    .auth-wrap { padding: 0; align-items: stretch; }
    .auth-card {
        max-width: 100%;
        width: 100%;
        min-height: 100vh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 28px 26px;
    }
    .auth-logo { font-size: 48px; margin-bottom: 10px; }
    .auth-card h1 { font-size: 24px; }
    .auth-sub { margin-bottom: 24px; font-size: 15px; }
    .auth-card label { font-size: 15px; margin-bottom: 8px; }
    .auth-card .input { padding: 15px 16px; font-size: 17px; border-radius: 10px; }
    .auth-card .password-field .input { padding-right: 50px; }
    .password-toggle .eye-icon { width: 22px; height: 22px; }
    .auth-card .btn { padding: 16px; font-size: 17px; border-radius: 10px; }
    .auth-card .btn-install { padding: 8px 22px; font-size: 16px; border-radius: 10px; }
    .auth-link { font-size: 15px; margin-top: 22px; }
    .check { font-size: 16px; gap: 10px; }
}

@media (max-width: 480px) {
    .cards { grid-template-columns: 1fr; }
    .card-stat { padding: 12px; }
    .stat-num { font-size: 22px; }

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

    .content { padding: 12px; }
    .topbar { padding: 0 12px 0 56px; }

    .acciones-form { margin-top: 14px; }

    .auth-card { padding: 24px 20px; }
    .auth-logo { font-size: 44px; }
    .auth-card h1 { font-size: 23px; }
}

/* ---------- Tablas → cards en mobile ---------- */
@media (max-width: 768px) {
    .table-responsive thead { display: none; }

    .table-responsive tbody tr {
        display: flex;
        flex-direction: column;
        padding: 14px 16px;
        margin-bottom: 10px;
        border: 1px solid var(--borde);
        border-radius: 10px;
        background: var(--blanco);
    }

    .table-responsive tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border-bottom: 1px solid #f1f5f9;
        text-align: right;
        white-space: normal;
    }
    .table-responsive tbody td:last-child { border-bottom: none; }

    .table-responsive tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 12px;
        color: var(--texto-suave);
        text-transform: uppercase;
        letter-spacing: 0.03em;
        text-align: left;
        flex: 1;
        padding-right: 12px;
    }

    .table-responsive tbody td.acciones {
        flex-direction: row;
        justify-content: flex-end;
        gap: 8px;
    }
    .table-responsive tbody td.acciones::before { display: none; }
}

@media (max-width: 400px) {
    .auth-card { padding: 20px 16px; }
    .auth-logo { font-size: 40px; }
    .auth-card h1 { font-size: 21px; }
    .auth-sub { font-size: 14px; margin-bottom: 20px; }
    .auth-card .input { font-size: 16px; padding: 14px 14px; }
    .auth-card .btn { font-size: 16px; padding: 15px; }
}
