/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Variables ─────────────────────────────────────────────── */
:root {
    --azul:        #1a56a0;
    --azul-hover:  #2e74c4;
    --azul-bg:     #eef4fb;
    --azul-hielo:  #dbeafe;
    --texto:       #111827;
    --texto-sec:   #6b7280;
    --texto-sutil: #9ca3af;
    --borde:       #d1d5db;
    --separador:   #e5e7eb;
    --blanco:      #ffffff;
    --rojo:        #dc2626;
    --rojo-bg:     #fef2f2;
    --rojo-borde:  #fecaca;
    --verde:       #16a34a;
    --verde-bg:    #f0fdf4;
    --verde-borde: #bbf7d0;
    --amarillo:    #d97706;
    --amarillo-bg: #fffbeb;
    --radio-sm:    6px;
    --radio:       10px;
    --radio-lg:    14px;
    --sombra-sm:   0 1px 3px rgba(0,0,0,.08);
    --sombra:      0 2px 8px rgba(0,0,0,.10);
    --sombra-lg:   0 4px 20px rgba(0,0,0,.12);
    --topbar-h:    56px;
    --nav-h:       60px;
}

/* ── Base ───────────────────────────────────────────────────── */
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--texto);
    background: var(--azul-bg);
    line-height: 1.5;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; display: block; }

/* ── Tipografía ─────────────────────────────────────────────── */
h1 { font-size: 1.375rem; font-weight: 700; line-height: 1.3; }
h2 { font-size: 1.125rem; font-weight: 600; line-height: 1.35; }
h3 { font-size: 1rem;     font-weight: 600; }
h4 { font-size: .875rem;  font-weight: 600; }
small { font-size: .8125rem; }

/* ════════════════════════════════════════════════════════════
   LAYOUT — Portal
══════════════════════════════════════════════════════════════ */

/* Barra superior fija */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--azul);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.topbar-brand {
    color: #fff;
    font-size: .9375rem;
    font-weight: 700;
    letter-spacing: -.01em;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: rgba(255,255,255,.85);
    font-size: .8125rem;
    cursor: pointer;
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,.22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

/* Contenido principal */
.page-content {
    padding-top: calc(var(--topbar-h) + 1rem);
    padding-bottom: calc(var(--nav-h) + 1rem);
    padding-left: 1rem;
    padding-right: 1rem;
    min-height: 100dvh;
    max-width:500px
}

/* Navbar inferior — mobile */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--blanco);
    border-top: 1px solid var(--separador);
    display: flex;
    z-index: 100;
}

.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .2rem;
    font-size: .625rem;
    font-weight: 500;
    color: var(--texto-sutil);
    padding: .4rem .25rem .5rem;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav a.active,
.bottom-nav a:hover { color: var(--azul); }

.bottom-nav .nav-icon { font-size: 1.25rem; line-height: 1; }

/* Desktop: sidebar */
@media (min-width: 768px) {
    .bottom-nav { display: none; }

    .with-sidebar {
        display: flex;
        min-height: 100dvh;
    }

    .sidebar {
        position: fixed;
        top: var(--topbar-h);
        left: 0;
        width: 220px;
        height: calc(100dvh - var(--topbar-h));
        background: var(--blanco);
        border-right: 1px solid var(--separador);
        padding: 1rem .75rem;
        overflow-y: auto;
        z-index: 50;
    }

    .sidebar a {
        display: flex;
        align-items: center;
        gap: .65rem;
        padding: .6rem .75rem;
        border-radius: var(--radio);
        font-size: .875rem;
        font-weight: 500;
        color: var(--texto-sec);
        transition: background .12s, color .12s;
        margin-bottom: .15rem;
    }

    .sidebar a:hover { background: var(--azul-bg); color: var(--azul); }
    .sidebar a.active { background: var(--azul-hielo); color: var(--azul); font-weight: 600; }
    .sidebar .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

    .sidebar-sep {
        height: 1px;
        background: var(--separador);
        margin: .75rem 0;
    }

    .page-content {
        margin-left: 220px;
        padding-bottom: 2rem;
    }
}

/* ════════════════════════════════════════════════════════════
   COMPONENTES
══════════════════════════════════════════════════════════════ */

/* Título de página */
.page-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--texto);
    margin-bottom: 1rem;
}

.page-title small {
    display: block;
    font-size: .8125rem;
    font-weight: 400;
    color: var(--texto-sec);
    margin-top: .15rem;
}

/* Sección con título */
.section-title {
    font-size: .75rem;
    font-weight: 600;
    color: var(--texto-sec);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin: 1.25rem 0 .6rem;
}

/* Cards */
.card {
    background: var(--blanco);
    border-radius: var(--radio-lg);
    padding: 1rem;
    box-shadow: var(--sombra-sm);
}

.card + .card { margin-top: .75rem; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
}

/* Stats row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .6rem;
    margin-bottom: .25rem;
}

.stat-card {
    background: var(--blanco);
    border-radius: var(--radio-lg);
    padding: .75rem .5rem;
    text-align: center;
    box-shadow: var(--sombra-sm);
}

.stat-card .num {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--azul);
    line-height: 1;
}

.stat-card .lbl {
    font-size: .6875rem;
    color: var(--texto-sutil);
    margin-top: .2rem;
}

/* Lista de pacientes / items */
.list-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    background: var(--blanco);
    border-radius: var(--radio-lg);
    padding: .75rem;
    margin-bottom: .5rem;
    box-shadow: var(--sombra-sm);
    cursor: pointer;
    transition: box-shadow .12s;
    -webkit-tap-highlight-color: transparent;
}

.list-item:hover { box-shadow: var(--sombra); }

.list-item:last-child { margin-bottom: 0; }

.item-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--azul-hielo);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8125rem;
    font-weight: 700;
    color: var(--azul);
    flex-shrink: 0;
}

.item-info { flex: 1; min-width: 0; }

.item-name {
    font-size: .875rem;
    font-weight: 600;
    color: var(--texto);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-sub {
    font-size: .75rem;
    color: var(--texto-sec);
    margin-top: .1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-arrow {
    color: var(--texto-sutil);
    font-size: .875rem;
    flex-shrink: 0;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .6875rem;
    font-weight: 600;
    line-height: 1.4;
}

.badge-azul    { background: var(--azul-hielo); color: var(--azul); }
.badge-verde   { background: var(--verde-bg);   color: var(--verde); }
.badge-rojo    { background: var(--rojo-bg);    color: var(--rojo); }
.badge-gris    { background: #f3f4f6;           color: var(--texto-sec); }
.badge-amarillo{ background: var(--amarillo-bg);color: var(--amarillo); }
.badge-violeta { background: #ede9fe;           color: #6d28d9; }
.badge-naranja { background: #fff7ed;           color: #c2410c; }

/* Alertas */
.alerta {
    padding: .75rem 1rem;
    border-radius: var(--radio);
    font-size: .875rem;
    margin-bottom: 1rem;
    line-height: 1.45;
}

.alerta-error   { background: var(--rojo-bg);    color: var(--rojo);    border: 1px solid var(--rojo-borde); }
.alerta-ok      { background: var(--verde-bg);   color: var(--verde);   border: 1px solid var(--verde-borde); }
.alerta-info    { background: var(--azul-bg);    color: var(--azul);    border: 1px solid var(--azul-hielo); }
.alerta-warning { background: var(--amarillo-bg);color: var(--amarillo);border: 1px solid #fde68a; }

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .7rem 1.25rem;
    font-size: .9375rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radio);
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background .15s, opacity .15s, box-shadow .15s;
    min-height: 44px;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-block { display: flex; width: 100%; }

.btn-primario  { background: var(--azul);       color: #fff; }
.btn-primario:hover  { background: var(--azul-hover); }

.btn-secundario {
    background: transparent;
    color: var(--azul);
    border: 1.5px solid var(--azul);
}
.btn-secundario:hover { background: var(--azul-bg); }

.btn-ghost {
    background: transparent;
    color: var(--texto-sec);
}
.btn-ghost:hover { background: var(--separador); color: var(--texto); }

.btn-danger { background: var(--rojo); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: .45rem .85rem; font-size: .8125rem; min-height: 36px; }

/* Formularios */
.form-group { margin-bottom: 1rem; }

.form-group:last-child { margin-bottom: 0; }

label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    margin-bottom: .35rem;
    color: var(--texto);
}

.form-hint {
    font-size: .75rem;
    color: var(--texto-sec);
    margin-top: .25rem;
}

.form-error {
    font-size: .75rem;
    color: var(--rojo);
    margin-top: .25rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: .7rem .875rem;
    font-size: .9375rem;
    font-family: inherit;
    border: 1.5px solid var(--borde);
    border-radius: var(--radio);
    background: var(--blanco);
    color: var(--texto);
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--azul-hover);
    box-shadow: 0 0 0 3px rgba(46,116,196,.18);
}

textarea { resize: vertical; min-height: 120px; line-height: 1.55; }

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .875rem center;
    padding-right: 2.5rem;
}

.input-group {
    display: flex;
    gap: .5rem;
}

.input-group input { flex: 1; }

/* Search bar */
.search-wrap { position: relative; margin-bottom: 1rem; }

.search-wrap input {
    padding-left: 2.5rem;
    background-color: var(--blanco);
}

.search-wrap::before {
    content: '🔍';
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: .875rem;
    pointer-events: none;
}

/* Divider */
.divider {
    height: 1px;
    background: var(--separador);
    margin: 1rem 0;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--texto-sec);
}

.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state p { font-size: .875rem; }

/* ════════════════════════════════════════════════════════════
   AUTH (login, 2FA, cambio clave)
══════════════════════════════════════════════════════════════ */
.auth-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 1.5rem 1rem;
    background: var(--azul-bg);
}

.auth-card {
    background: var(--blanco);
    border-radius: var(--radio-lg);
    box-shadow: var(--sombra-lg);
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 420px;
}

.auth-logo { text-align: center; margin-bottom: 1.75rem; }
.auth-logo h1 { color: var(--azul); font-size: 1.25rem; }
.auth-logo p  { color: var(--texto-sec); font-size: .875rem; margin-top: .25rem; }

.auth-footer {
    text-align: center;
    margin-top: 1.25rem;
    font-size: .8125rem;
    color: var(--texto-sec);
}

/* ════════════════════════════════════════════════════════════
   UTILITIES
══════════════════════════════════════════════════════════════ */
.mt-0  { margin-top: 0; }
.mt-1  { margin-top: .5rem; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.5rem; }
.mb-1  { margin-bottom: .5rem; }
.mb-2  { margin-bottom: 1rem; }
.flex  { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.text-sec   { color: var(--texto-sec); }
.text-sutil { color: var(--texto-sutil); }
.text-azul  { color: var(--azul); }
.text-rojo  { color: var(--rojo); }
.text-sm    { font-size: .8125rem; }
.text-xs    { font-size: .75rem; }
.fw-600     { font-weight: 600; }
.fw-700     { font-weight: 700; }
.truncate   { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
