/* =============================================================================
   Salud Mag IPS · estilos propios (complementan Bootstrap 5)
   Enfoque Mobile-First
   ========================================================================== */

:root {
    --sm-brand: #0b6b5e;
    --sm-brand-dark: #084c43;
    --sm-brand-soft: #e7f3f1;
    --sm-accent: #f2a900;
    --sm-ink: #14211f;
    --sm-muted: #5b6c68;
    --sm-border: #dfe7e5;
    --sm-radius: 16px;
    --sm-touch: 48px;
}

/* -----------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
body {
    background: #f7faf9;
    color: var(--sm-ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4, h5, h6 {
    letter-spacing: -0.01em;
}

a {
    color: var(--sm-brand);
}

a:hover {
    color: var(--sm-brand-dark);
}

:focus-visible {
    outline: 3px solid rgba(11, 107, 94, .45);
    outline-offset: 2px;
}

.text-secondary {
    color: var(--sm-muted) !important;
}

.eyebrow {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--sm-brand);
}

.bg-soft {
    background: var(--sm-brand-soft);
}

/* -----------------------------------------------------------------------------
   Botones (área táctil mínima 48px)
   -------------------------------------------------------------------------- */
.btn {
    border-radius: 10px;
    font-weight: 600;
}

.btn-lg {
    padding: .75rem 1.5rem;
    font-size: 1rem;
}

.btn-brand {
    background: var(--sm-brand);
    border-color: var(--sm-brand);
    color: #fff;
    min-height: var(--sm-touch);
}

.btn-brand:hover,
.btn-brand:focus {
    background: var(--sm-brand-dark);
    border-color: var(--sm-brand-dark);
    color: #fff;
}

.btn-outline-brand {
    border: 1px solid var(--sm-brand);
    color: var(--sm-brand);
    background: transparent;
    min-height: var(--sm-touch);
}

.btn-outline-brand:hover,
.btn-outline-brand:focus {
    background: var(--sm-brand);
    color: #fff;
}

.form-control {
    min-height: var(--sm-touch);
    border-radius: 10px;
    border-color: var(--sm-border);
}

.form-control:focus {
    border-color: var(--sm-brand);
    box-shadow: 0 0 0 .2rem rgba(11, 107, 94, .18);
}

.form-label {
    font-weight: 600;
    font-size: .92rem;
}

/* -----------------------------------------------------------------------------
   Marca
   -------------------------------------------------------------------------- */
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--sm-brand);
    color: #fff;
    font-weight: 800;
    font-size: .95rem;
    letter-spacing: .02em;
}

.brand-text {
    line-height: 1.05;
}

.brand-text strong {
    font-size: 1.05rem;
    color: var(--sm-ink);
}

.brand-text small {
    font-size: .58rem;
    letter-spacing: .025em;
    line-height: 1.2;
    color: var(--sm-muted);
}

.brand-text .brand-slogan {
    max-width: 190px;
    font-weight: 500;
    text-transform: none;
    white-space: normal;
}

.site-header .navbar {
    padding-top: .35rem;
    padding-bottom: .35rem;
}

.site-header .navbar-toggler {
    border-color: var(--sm-border);
    min-height: 44px;
    min-width: 44px;
}

.site-header .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
    font-weight: 500;
}

@media (min-width: 992px) {
    .site-header .nav-link {
        padding-left: .9rem;
        padding-right: .9rem;
    }
}

/* -----------------------------------------------------------------------------
   Portada
   -------------------------------------------------------------------------- */
.hero {
    background:
        radial-gradient(1100px 420px at 88% -10%, rgba(11, 107, 94, .16), transparent 60%),
        linear-gradient(180deg, #ffffff 0%, #f2f8f7 100%);
    border-bottom: 1px solid var(--sm-border);
}

.hero h1 {
    font-size: clamp(1.9rem, 5vw, 3.1rem);
}

.hero-panel {
    background: #fff;
    border: 1px solid var(--sm-border);
    border-radius: var(--sm-radius);
    box-shadow: 0 18px 45px rgba(11, 107, 94, .10);
}

.steps li {
    display: flex;
    gap: .8rem;
    align-items: flex-start;
    padding: .55rem 0;
    font-size: .95rem;
}

.step-num {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--sm-brand-soft);
    color: var(--sm-brand-dark);
    font-weight: 700;
    font-size: .85rem;
}

.service-card,
.module-card {
    border: 1px solid var(--sm-border);
    border-radius: var(--sm-radius);
    transition: transform .15s ease, box-shadow .15s ease;
}

.service-card:hover,
.module-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(11, 107, 94, .10);
}

.service-card .card-footer,
.module-card .card-footer {
    border-top: 1px solid var(--sm-border);
    border-radius: 0 0 var(--sm-radius) var(--sm-radius);
}

/* -----------------------------------------------------------------------------
   Autenticación
   -------------------------------------------------------------------------- */
.auth-shell {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background:
        radial-gradient(900px 400px at 50% -20%, rgba(11, 107, 94, .18), transparent 65%),
        #f4f8f7;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 20px;
    padding: 32px 24px;
    box-shadow: 0 24px 60px rgba(11, 107, 94, .14);
}

@media (min-width: 576px) {
    .auth-card {
        padding: 40px 36px;
    }
}

/* -----------------------------------------------------------------------------
   Contenido autenticado
   -------------------------------------------------------------------------- */
#contenido {
    min-height: 50vh;
}

.card {
    border-radius: var(--sm-radius);
}

.table > :not(caption) > * > * {
    padding: .75rem .85rem;
}

/* -----------------------------------------------------------------------------
   Tablas que se convierten en tarjetas en móvil
   Uso: <table class="table table-cards"> con data-label en cada <td>
   -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .table-cards thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .table-cards tbody tr {
        display: block;
        border: 1px solid var(--sm-border);
        border-radius: 14px;
        margin-bottom: .85rem;
        padding: .35rem .25rem;
        background: #fff;
        box-shadow: 0 4px 14px rgba(20, 33, 31, .05);
    }

    .table-cards tbody td,
    .table-cards tbody th {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        border: 0;
        padding: .5rem .9rem;
        text-align: right;
    }

    .table-cards tbody td::before,
    .table-cards tbody th::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: .78rem;
        letter-spacing: .04em;
        text-transform: uppercase;
        color: var(--sm-muted);
        text-align: left;
    }
}

/* -----------------------------------------------------------------------------
   Accesibilidad y movimiento reducido
   -------------------------------------------------------------------------- */
.visually-hidden-focusable:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: .75rem 1rem;
    background: #fff;
    z-index: 1080;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

/* Impresión de comprobantes / resultados */
@media print {
    .site-header,
    .site-footer,
    .btn,
    .navbar {
        display: none !important;
    }

    body {
        background: #fff;
    }
}

/* =============================================================================
   Panel de administración
   ========================================================================== */
.admin-shell {
    min-height: 100dvh;
    background: #f4f8f7;
}

.admin-sidebar {
    --bs-offcanvas-width: 284px;
    background: linear-gradient(180deg, #0b3b35 0%, #072824 100%);
    color: #d9ece8;
    border-right: 0;
}

@media (min-width: 992px) {
    .admin-shell {
        display: flex;
    }

    .admin-sidebar {
        position: sticky;
        top: 0;
        height: 100dvh;
        width: 270px;
        flex: 0 0 270px;
    }

    .admin-content {
        flex: 1;
        min-width: 0;
    }
}

.admin-sidebar .offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    padding: 1rem 1.1rem;
}

.admin-brand-text strong {
    display: block;
    font-size: .98rem;
    color: #fff;
    line-height: 1.15;
}

.admin-brand-text small {
    display: block;
    font-size: .72rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .55);
}

.admin-logo {
    height: 38px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    padding: 3px;
}

.admin-nav {
    padding: .75rem;
    overflow-y: auto;
}

.admin-nav-title {
    margin: .9rem .75rem .35rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .42);
}

.admin-nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    min-height: 44px;
    padding: .6rem .75rem;
    border-radius: 10px;
    color: rgba(255, 255, 255, .82);
    text-decoration: none;
    font-size: .93rem;
    transition: background .15s ease, color .15s ease;
}

.admin-nav-link:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.admin-nav-link.active {
    background: #0b6b5e;
    color: #fff;
    font-weight: 600;
}

.admin-nav-link.disabled {
    opacity: .5;
    cursor: not-allowed;
}

.admin-nav-link .nav-icon {
    width: 20px;
    text-align: center;
    opacity: .9;
}

.admin-sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, .1);
    color: rgba(255, 255, 255, .78);
}

.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .65rem 1rem;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--sm-border);
    backdrop-filter: blur(8px);
}

.admin-topbar .navbar-toggler-icon {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    background-image: var(--bs-navbar-toggler-icon-bg);
    background-repeat: no-repeat;
    background-size: 100%;
}

.admin-main {
    padding: 1.1rem 1rem 2rem;
    max-width: 1360px;
}

@media (min-width: 992px) {
    .admin-main {
        padding: 1.5rem 1.75rem 2.5rem;
    }
}

.admin-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .5rem;
    padding: 1rem 1.25rem 1.5rem;
    font-size: .78rem;
    color: var(--sm-muted);
    border-top: 1px solid var(--sm-border);
}

.page-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

/* Tarjetas de estadística */
.stat-card {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    height: 100%;
    padding: 1rem 1.1rem;
    background: #fff;
    border: 1px solid var(--sm-border);
    border-radius: 16px;
    text-decoration: none;
    color: inherit;
    transition: transform .15s ease, box-shadow .15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(11, 107, 94, .1);
    color: inherit;
}

.stat-label {
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--sm-muted);
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--sm-brand-dark);
}

.stat-link {
    font-size: .78rem;
    color: var(--sm-brand);
    margin-top: .3rem;
}

/* Paneles y checklist */
.panel {
    background: #fff;
    border: 1px solid var(--sm-border);
    border-radius: 16px;
    padding: 1.1rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .9rem;
}

.checklist li {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 0;
    border-bottom: 1px solid var(--sm-border);
}

.checklist li:last-child {
    border-bottom: 0;
}

.checklist-icon {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .8rem;
}

.checklist-icon.ok {
    background: #e7f6ee;
    color: #0f7a43;
}

.checklist-icon.pending {
    background: #fff4d6;
    color: #946200;
}

/* Formularios del panel */
.form-section {
    background: #fff;
    border: 1px solid var(--sm-border);
    border-radius: 16px;
    padding: 1.1rem;
    margin-bottom: 1rem;
}

.form-section h2 {
    font-size: .98rem;
    font-weight: 700;
    margin-bottom: .15rem;
}

.form-section .hint {
    font-size: .82rem;
    color: var(--sm-muted);
    margin-bottom: 1rem;
}

/* Credenciales generadas */
.cred-card {
    background: #fffbeb;
    border: 1px solid #f0d48a;
    border-radius: 12px;
    padding: 1rem;
}

.cred-card code {
    font-size: .95rem;
    color: #7a4b00;
    word-break: break-all;
}

/* Vista previa del logo */
.logo-preview {
    width: 128px;
    height: 72px;
    display: grid;
    place-items: center;
    background: #fff;
    border: 1px solid var(--sm-border);
    border-radius: 12px;
    padding: 8px;
}

.logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* =============================================================================
   Agenda: calendario y horarios
   ========================================================================== */
.calendar {
    background: #fff;
    border: 1px solid var(--sm-border);
    border-radius: 16px;
    padding: .9rem;
}

.calendar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .75rem;
}

.calendar-nav {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--sm-border);
    color: var(--sm-brand);
    text-decoration: none;
    font-size: 1.4rem;
    line-height: 1;
}

.calendar-nav:hover {
    background: var(--sm-brand-soft);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-dow {
    text-align: center;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--sm-muted);
    padding: .25rem 0;
}

.calendar-day {
    display: grid;
    place-items: center;
    min-height: 44px;
    border-radius: 10px;
    font-size: .9rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--sm-ink);
    background: #f7faf9;
    border: 1px solid transparent;
}

.calendar-day.disponible:hover {
    background: var(--sm-brand-soft);
    color: var(--sm-brand-dark);
}

.calendar-day.fuera {
    opacity: .38;
}

.calendar-day.hoy {
    border-color: var(--sm-brand);
}

.calendar-day.seleccionado {
    background: var(--sm-brand);
    color: #fff;
}

.calendar-day.no-disponible {
    color: #a9b6b3;
    background: transparent;
    text-decoration: line-through;
}

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: .75rem;
    font-size: .75rem;
    color: var(--sm-muted);
}

.calendar-legend .dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: .25rem;
    background: #e3ecea;
}

.calendar-legend .dot.disponible { background: #9fd3c7; }
.calendar-legend .dot.no-disponible { background: #d8dfdd; }
.calendar-legend .dot.seleccionado { background: var(--sm-brand); }

.slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: .5rem;
}

.slot-option {
    position: relative;
}

.slot-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.slot-option label {
    display: grid;
    place-items: center;
    min-height: 48px;
    padding: .35rem .4rem;
    border: 1px solid var(--sm-border);
    border-radius: 10px;
    background: #fff;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    text-align: center;
}

.slot-option small {
    display: block;
    font-size: .66rem;
    font-weight: 500;
    color: var(--sm-muted);
}

.slot-option input:checked + label {
    background: var(--sm-brand);
    border-color: var(--sm-brand);
    color: #fff;
}

.slot-option input:checked + label small {
    color: rgba(255, 255, 255, .8);
}

.slot-option input:disabled + label {
    background: #f1f4f3;
    color: #a9b6b3;
    cursor: not-allowed;
    text-decoration: line-through;
}

.slot-option input:focus-visible + label {
    outline: 3px solid rgba(11, 107, 94, .4);
    outline-offset: 2px;
}

.cita-resumen {
    background: var(--sm-brand-soft);
    border-radius: 12px;
    padding: .8rem 1rem;
    font-size: .9rem;
}

/* Resultados de búsqueda en vivo */
.resultados-busqueda {
    min-height: 1px;
}

.resultados-busqueda ul {
    margin-bottom: 0;
}

.resultados-busqueda .btn {
    min-height: 38px;
}

/* Documentos legales */
.legal-doc {
    max-width: 820px;
}

.legal-doc p,
.legal-doc li {
    font-size: .95rem;
    color: #33413e;
}

.legal-doc h2 {
    margin-top: 2rem;
}

/* Filtros */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: flex-end;
}

.filter-bar .form-control,
.filter-bar .form-select {
    min-height: 42px;
}

/* Aviso de acción pendiente */
.soon-note {
    background: #eef6f5;
    border: 1px dashed #b9d6d1;
    border-radius: 12px;
    padding: .75rem 1rem;
    font-size: .85rem;
    color: #2c5b55;
}

/* Botón flotante de WhatsApp */
.whatsapp-float {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1040;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #25d366;
    color: #fff;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 24px rgba(37, 211, 102, .38);
    transition: transform .15s ease;
}

.whatsapp-float:hover {
    color: #fff;
    transform: translateY(-2px);
}

@media print {
    .admin-sidebar,
    .admin-topbar,
    .whatsapp-float {
        display: none !important;
    }
}

.persona-inicial {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #e8f3ef;
    color: #146b55;
    font-weight: 700;
    font-size: 1.25rem;
    flex: 0 0 auto;
}

.legal-content {
    line-height: 1.7;
    font-size: .95rem;
}

.legal-content h2 {
    font-size: 1.1rem;
    margin-top: 1.4rem;
}

.legal-content h2:first-child {
    margin-top: 0;
}

.legal-content ul,
.legal-content ol {
    padding-left: 1.25rem;
}

.legal-editor:focus {
    outline: 2px solid #9ec9bf;
    outline-offset: 1px;
}

.service-picker-list {
    max-height: 330px;
    overflow-y: auto;
    padding: .25rem .4rem .4rem .25rem;
    border: 1px solid #d7e2df;
    border-radius: .65rem;
    background: #fbfdfc;
}

.service-category + .service-category {
    margin-top: .8rem;
}

.service-category-title {
    margin: 0 0 .35rem;
    padding-left: .2rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #52635f;
}

.service-option {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    width: 100%;
    height: 100%;
    padding: .5rem .55rem;
    border: 1px solid #dde7e4;
    border-radius: .55rem;
    background: #fff;
    cursor: pointer;
    transition: border-color .12s ease, background .12s ease;
}

.service-option:hover {
    border-color: #9ec9bf;
    background: #f5fbf9;
}

.service-option.is-selected,
.service-option:has(input:checked) {
    border-color: #2c8b76;
    background: #e8f3ef;
}

.service-option .form-check-input {
    flex: 0 0 auto;
    margin-top: .1rem;
}

.service-option-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

.service-option-name {
    font-size: .82rem;
    font-weight: 600;
    color: #14211f;
}

.service-option-price {
    font-size: .74rem;
    color: #52635f;
}

.service-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .45rem;
}

.service-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    max-width: 100%;
    padding: .25rem .45rem .25rem .6rem;
    border: 1px solid #b9d6d1;
    border-radius: 999px;
    background: #e8f3ef;
    color: #0b5f54;
    font-size: .78rem;
    line-height: 1.2;
}

.service-chip > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 260px;
}

.service-chip-remove {
    border: 0;
    background: transparent;
    color: #0b5f54;
    font-size: 1rem;
    line-height: 1;
    padding: 0 .1rem;
    cursor: pointer;
}

.service-chip-remove:hover {
    color: #8a1f1f;
}
