/**
 * style.css — Portal de Pacientes HAC
 * Diseño institucional: Azules profundos, tipografía clara, UI limpia.
 * Requiere: Bootstrap 5, Bootstrap Icons, Plus Jakarta Sans (Google Fonts)
 */

/* ── Variables de tema ─────────────────────────────────────────────────────── */
:root {
    --hac-blue-900:  #001f4d;
    --hac-blue-800:  #003366;
    --hac-blue-700:  #004488;
    --hac-blue-600:  #0055aa;
    --hac-blue-500:  #0066cc;
    --hac-blue-400:  #2e86e8;
    --hac-blue-100:  #deeeff;
    --hac-blue-50:   #f0f7ff;

    --hac-accent:    #00a8e8;      /* celeste vivo para highlights */
    --hac-success:   #0d9e6e;
    --hac-warn:      #d97706;
    --hac-danger:    #dc2626;

    --sidebar-w:     260px;
    --sidebar-bg:    var(--hac-blue-900);
    --sidebar-text:  rgba(255,255,255,.82);
    --sidebar-hover: rgba(255,255,255,.08);
    --sidebar-active:rgba(0,102,204,.55);

    --topbar-h:      62px;
    --body-font:     'Plus Jakarta Sans', sans-serif;
    --radius-card:   14px;
    --shadow-card:   0 4px 24px rgba(0,30,80,.09);
}

/* ── Reset / Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-family: var(--body-font);
    background: #f3f7fc;
    color: #1e2a3b;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout principal ──────────────────────────────────────────────────────── */
.portal-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 1040;
    transition: transform .3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 1.35rem 1.4rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    text-decoration: none;
}
.sidebar-brand-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--hac-blue-600), var(--hac-accent));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-brand-icon i { color:#fff; font-size:1.25rem; }
.sidebar-brand-text { line-height: 1.2; }
.sidebar-brand-text strong {
    display: block;
    color: #fff;
    font-size: .92rem;
    font-weight: 700;
    letter-spacing: .01em;
}
.sidebar-brand-text small {
    color: rgba(255,255,255,.5);
    font-size: .72rem;
}

.sidebar-section-label {
    font-size: .65rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(255,255,255,.35);
    padding: 1.25rem 1.4rem .4rem;
    font-weight: 600;
}

.sidebar-nav { list-style: none; margin: 0; padding: 0 .65rem; }
.sidebar-nav li { margin-bottom: .15rem; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .65rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 10px;
    font-size: .88rem;
    font-weight: 500;
    transition: background .18s, color .18s;
    position: relative;
}
.sidebar-link i { font-size: 1.08rem; flex-shrink: 0; opacity:.8; }
.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.sidebar-link:hover i { opacity:1; }
.sidebar-link.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}
.sidebar-link.active i { opacity:1; }
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 3px;
    background: var(--hac-accent);
    border-radius: 0 3px 3px 0;
}

/* Botón "Nuevos Servicios" — destacado */
.sidebar-link.new-badge {
    background: linear-gradient(135deg, rgba(0,168,232,.22), rgba(0,102,204,.18));
    border: 1px solid rgba(0,168,232,.3);
    color: #7ed6fb;
}
.sidebar-link.new-badge i { color: var(--hac-accent); opacity:1; }
.sidebar-link.new-badge:hover {
    background: linear-gradient(135deg, rgba(0,168,232,.35), rgba(0,102,204,.3));
    color: #fff;
}
.badge-pill {
    margin-left: auto;
    background: var(--hac-accent);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: .2em .6em;
    border-radius: 20px;
    letter-spacing: .04em;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem .65rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user-block {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .9rem;
    background: rgba(255,255,255,.06);
    border-radius: 10px;
}
.sidebar-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--hac-blue-600), var(--hac-accent));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-avatar i { color:#fff; font-size:.95rem; }
.sidebar-user-info strong {
    display: block;
    color: #fff;
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}
.sidebar-user-info small { color: rgba(255,255,255,.45); font-size: .7rem; }
.btn-logout {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: rgba(255,255,255,.5);
    text-decoration: none;
    font-size: .8rem;
    padding: .45rem .9rem;
    border-radius: 8px;
    transition: background .18s, color .18s;
    margin-top: .4rem;
}
.btn-logout:hover { background: rgba(220,38,38,.15); color: #fc8080; }

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid #e4eaf4;
    display: flex;
    align-items: center;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,30,80,.05);
}
.topbar-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--hac-blue-800);
    margin: 0;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.topbar-date {
    font-size: .78rem;
    color: #7a8faa;
    font-weight: 500;
}
.btn-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--hac-blue-800);
    font-size: 1.3rem;
    padding: .3rem .5rem;
    cursor: pointer;
    margin-right: .5rem;
}

/* ── Main content ──────────────────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.page-body { padding: 1.75rem; flex: 1; }

/* ── Cards métricas ────────────────────────────────────────────────────────── */
.metric-card {
    background: #fff;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 1.4rem 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1.1rem;
    border: 1px solid #eaf0fa;
    transition: box-shadow .2s, transform .2s;
}
.metric-card:hover { box-shadow: 0 8px 32px rgba(0,40,100,.13); transform: translateY(-2px); }
.metric-icon {
    width: 50px; height: 50px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.metric-icon i { font-size: 1.4rem; }
.metric-icon.blue  { background:#deeeff; color: var(--hac-blue-600); }
.metric-icon.teal  { background:#d1faf0; color: var(--hac-success); }
.metric-icon.amber { background:#fef3c7; color: var(--hac-warn); }
.metric-icon.cyan  { background:#cff4fd; color: #0891b2; }
.metric-label { font-size: .78rem; color: #7a8faa; font-weight: 600; text-transform:uppercase; letter-spacing:.05em; margin-bottom:.2rem; }
.metric-value { font-size: 1.7rem; font-weight: 800; color: var(--hac-blue-900); line-height:1; margin-bottom:.25rem; }
.metric-hint  { font-size: .77rem; color: #94a3b8; }

/* ── Sección card genérica ─────────────────────────────────────────────────── */
.section-card {
    background: #fff;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    border: 1px solid #eaf0fa;
    overflow: hidden;
}
.section-card-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid #eaf0fa;
}
.section-card-header h5 {
    margin: 0;
    font-size: .95rem;
    font-weight: 700;
    color: var(--hac-blue-800);
}
.section-card-header .header-icon {
    width: 32px; height: 32px;
    background: var(--hac-blue-50);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
}
.section-card-header .header-icon i { color: var(--hac-blue-600); font-size:.95rem; }

/* ── Tabla resultados ──────────────────────────────────────────────────────── */
.table-portal { width:100%; margin:0; }
.table-portal thead tr {
    background: var(--hac-blue-50);
}
.table-portal thead th {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: #5a7090;
    padding: .75rem 1.25rem;
    border: none;
    white-space: nowrap;
}
.table-portal tbody tr {
    border-bottom: 1px solid #f0f5ff;
    transition: background .15s;
}
.table-portal tbody tr:last-child { border-bottom: none; }
.table-portal tbody tr:hover { background: var(--hac-blue-50); }
.table-portal tbody td {
    padding: .85rem 1.25rem;
    vertical-align: middle;
    font-size: .88rem;
    color: #2c3e5a;
}

/* Botón "Ver Resultado" */
.btn-ver-resultado {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: linear-gradient(135deg, var(--hac-blue-700), var(--hac-blue-500));
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: .38rem .9rem;
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity .18s, transform .15s, box-shadow .18s;
    box-shadow: 0 2px 8px rgba(0,80,180,.22);
    white-space: nowrap;
}
.btn-ver-resultado:hover { opacity:.88; transform: translateY(-1px); color:#fff; box-shadow: 0 4px 14px rgba(0,80,180,.3); }
.btn-ver-resultado:active { transform: translateY(0); }

/* Placeholder pills */
.pill-soon {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: #f1f5f9;
    color: #94a3b8;
    border-radius: 8px;
    padding: .35rem .9rem;
    font-size: .78rem;
    font-weight: 600;
    pointer-events: none;
}

/* ── Placeholder módulos ───────────────────────────────────────────────────── */
.placeholder-module {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}
.placeholder-module .ph-icon {
    width: 72px; height: 72px;
    background: var(--hac-blue-50);
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 1.25rem;
}
.placeholder-module .ph-icon i { font-size: 2rem; color: var(--hac-blue-400); }
.placeholder-module h5 { font-weight: 700; color: var(--hac-blue-800); margin-bottom: .5rem; }
.placeholder-module p  { color: #94a3b8; font-size: .88rem; max-width: 320px; }

/* ── Alertas ───────────────────────────────────────────────────────────────── */
.alert-hac {
    border-radius: 10px;
    border: none;
    font-size: .87rem;
    padding: .8rem 1.1rem;
}
.alert-hac.success { background: #ecfdf5; color: #065f46; }
.alert-hac.error   { background: #fef2f2; color: #991b1b; }
.alert-hac.info    { background: var(--hac-blue-50); color: var(--hac-blue-800); }

/* ── Overlay sidebar móvil ─────────────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,15,40,.55);
    z-index: 1039;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── Animaciones ───────────────────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity:0; transform: translateY(16px); }
    to   { opacity:1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp .4s ease both; }
.fade-in-1 { animation-delay: .05s; }
.fade-in-2 { animation-delay: .10s; }
.fade-in-3 { animation-delay: .15s; }
.fade-in-4 { animation-delay: .20s; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 40px rgba(0,10,40,.35);
    }
    .main-content { margin-left: 0; }
    .btn-sidebar-toggle { display: block; }
}

@media (max-width: 575.98px) {
    .page-body { padding: 1rem; }
    .metric-value { font-size: 1.4rem; }
    .table-portal thead th,
    .table-portal tbody td { padding: .65rem .85rem; }
}
