/* =============================================================================
   FASE 2 — Autenticacion y panel.

   Se carga JUNTO a app.css y encima de Bootstrap 5 (CDN). Aqui va solo lo que
   Bootstrap no cubre o lo que conviene fijar por identidad visual.

   La pagina de estado NO carga este fichero: tiene que poder renderizarse sin
   ninguna dependencia externa cuando el sistema esta roto.
   ========================================================================== */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--accent);
    color: #fff;
    padding: .6rem 1rem;
    z-index: 100;
}

.skip-link:focus { left: 0; }

/* ---------------------------------------------------------------- Acceso -- */

.auth-body {
    background: linear-gradient(145deg, #0B1528 0%, #060e1c 100%);
    min-height: 100vh;
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 26rem;
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(11, 21, 40, 0.25);
    padding: 2.25rem;
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .65rem;
    margin-bottom: 1.5rem;
}

.auth-brand-mark,
.app-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 8px;
    background: #FF5A36;
    color: #fff;
    font-weight: 700;
}

.auth-brand-name,
.app-brand-name {
    font-family: var(--font-title);
    font-weight: 700;
    letter-spacing: -.02em;
    color: #0F172A;
}

.auth-title {
    font-family: var(--font-title);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 .3rem;
    letter-spacing: -.02em;
    color: #0F172A;
}
.auth-sub { color: #64748B; margin: 0 0 1.5rem; font-size: .92rem; }

.auth-alt {
    margin: 1.25rem 0 0;
    text-align: center;
    font-size: .9rem;
    color: #64748B;
}

.auth-alt a { color: #0284C7; font-weight: 600; text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }

.auth-foot { margin-top: 1.5rem; font-size: .8rem; color: #64748B; }

/* ----------------------------------------------------------------- Panel -- */

.app-body { background: var(--bg); }

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: 16rem;
    flex-shrink: 0;
    flex-direction: column;
    background: #0B1528; /* Azul Marino Obsidiana Profundo 70% */
    color: #cbd2dd;
    padding: 1.25rem 0.85rem;
    border-right: 1px solid #1e293b;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .25rem .5rem 1.25rem;
    color: #fff;
}

.app-nav { display: flex; flex-direction: column; gap: .12rem; padding: .5rem; }

.nav-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .75rem;
    border-radius: 8px;
    color: #94a3b8;
    text-decoration: none;
    font-size: .92rem;
    font-weight: 500;
    font-family: var(--font-body);
    transition: all 0.15s ease;
}

.app-sidebar .nav-item:hover {
    background: rgba(255, 255, 255, .08);
    color: #ffffff;
}

.offcanvas .nav-item { color: var(--text); }
.offcanvas .nav-item:hover { background: #f1f3f6; }

.nav-item--active {
    background: #0284C7 !important; /* Azul Acero Quirúrgico */
    color: #fff !important;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.nav-item--disabled { opacity: .45; cursor: default; }
.nav-item--disabled:hover { background: transparent !important; }

.nav-icon { width: 1.1rem; text-align: center; opacity: .9; }

.nav-phase {
    margin-left: auto;
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    opacity: .8;
}

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

.app-topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.app-topbar-company { font-weight: 600; }

.app-topbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .9rem;
}

.app-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #e6ebf5;
    color: #364154;
    font-size: .78rem;
    font-weight: 700;
}

.app-content { padding: 1.75rem 1.5rem 3rem; max-width: 72rem; width: 100%; }

/* ----------------------------------------------------------- Tipografía -- */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-title);
}

.page-title { margin-bottom: 1.5rem; }
.page-title h1 {
    font-family: var(--font-title);
    font-size: 1.85rem;
    font-weight: 700;
    color: #0F172A;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0 0 .2rem;
}
.page-title p {
    font-family: var(--font-body);
    margin: 0;
    color: #64748B;
    font-size: .95rem;
    line-height: 1.6;
}

h2, h3, .h2, .h3 {
    font-family: var(--font-title);
    font-weight: 600;
    color: #0284C7;
    letter-spacing: -0.01em;
}

/* --------------------------------------------------------------- Bloques -- */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.card-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem;
    box-shadow: var(--shadow);
}

.card-item h2 {
    font-family: var(--font-body);
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #64748B;
    margin: 0 0 .55rem;
}

.card-item p { margin: .55rem 0 0; font-size: .85rem; color: #64748B; }

.state {
    display: inline-block;
    font-size: .78rem;
    font-weight: 600;
    padding: .18rem .6rem;
    border-radius: 999px;
}

.state--on  { background: var(--ok-bg); color: var(--ok); }
.state--off { background: #eef0f3; color: #64748B; }

.metric {
    font-family: var(--font-title);
    font-size: 1.85rem;
    font-weight: 700;
    color: #0F172A;
    letter-spacing: -.02em;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.panel h2 {
    font-family: var(--font-title);
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0 0 .6rem;
    color: #0F172A;
}
.panel p { margin: 0 0 .5rem; line-height: 1.6; }

.muted { color: #64748B; font-size: .88rem; }

/* ------------------------------------------------------------- Botones -- */
.btn-primary,
.btn-warning {
    background-color: #FF5A36 !important; /* Naranja Coral Cinético (CTA) */
    border-color: #FF5A36 !important;
    color: #FFFFFF !important;
    font-family: var(--font-body);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(255, 90, 54, 0.25);
    transition: all 0.15s ease-in-out;
}

.btn-primary:hover,
.btn-warning:hover {
    background-color: #e04826 !important;
    border-color: #e04826 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 90, 54, 0.35);
}

.btn-outline-primary,
.btn-secondary {
    background-color: transparent !important;
    border-color: #0284C7 !important;
    color: #0284C7 !important;
    font-family: var(--font-body);
    font-weight: 600;
}

.btn-outline-primary:hover,
.btn-secondary:hover {
    background-color: #0284C7 !important;
    color: #FFFFFF !important;
}

.callout {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-left: 4px solid var(--ok);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.callout strong {
    color: var(--text);
    font-size: 0.95rem;
}

.callout--muted {
    background: rgba(255, 255, 255, 0.02);
    border-color: var(--border);
    border-left-color: #64748B;
}

.callout p { margin: .25rem 0 0; font-size: .88rem; color: var(--text-soft); }
.callout .btn { margin-left: auto; }

.form-grid { max-width: 32rem; }

/* --------------------------------------------------------------- Stepper -- */

.stepper {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
}

.stepper-item a {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .4rem .75rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-soft);
    text-decoration: none;
    font-size: .82rem;
    white-space: nowrap;
}

.stepper-item a:hover { border-color: #c3cbd8; }

.stepper-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: #eef0f3;
    font-size: .7rem;
    font-weight: 700;
}

.stepper-item--current a { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.stepper-item--current .stepper-num { background: var(--accent); color: #fff; }

.stepper-item--done a { color: var(--ok); }
.stepper-item--done .stepper-num { background: var(--ok-bg); color: var(--ok); }

/* ------------------------------------------------------------ Responsive -- */

@media (max-width: 640px) {
    .app-content { padding: 1.25rem 1rem 2.5rem; }
    .stepper-label { display: none; }
    .callout .btn { margin-left: 0; }
}

/* =============================================================================
   TEMA MODERNO DARK SLATE (INSPIRACIÓN PANEL DE ALTA PRECISIÓN & KINET DESIGN)
   ========================================================================== */

.card {
    background-color: #111C30 !important;
    border: 1px solid rgba(226, 232, 240, 0.12) !important;
    color: #F8FAFC !important;
    border-radius: 14px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25) !important;
}

.card-header {
    background-color: #0B1528 !important;
    border-bottom: 1px solid rgba(226, 232, 240, 0.12) !important;
    color: #F8FAFC !important;
}

.list-group-item {
    background-color: #111C30 !important;
    color: #F8FAFC !important;
    border-color: rgba(226, 232, 240, 0.1) !important;
}

.table {
    color: #F8FAFC !important;
    --bs-table-bg: transparent !important;
    --bs-table-color: #F8FAFC !important;
}

.table th, .table td {
    border-color: rgba(226, 232, 240, 0.1) !important;
    color: #F8FAFC !important;
}

.form-control, .form-select, .form-control:focus, .form-select:focus {
    background-color: #0B1528 !important;
    color: #F8FAFC !important;
    border-color: rgba(226, 232, 240, 0.2) !important;
}

.form-control::placeholder {
    color: #64748B !important;
}

/* =============================================================================
   ESTRUCTURA VISUAL Y SEPARACIÓN CLARA DE TÍTULOS, BADGES Y EMOJIS
   ========================================================================== */

.page-title h1,
.card-header h3,
.card-header h4,
.card-header h5,
.card-body h3,
.card-body h4,
.card-body h5 {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    line-height: 1.4;
    color: #F8FAFC;
}

.badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    height: auto !important;
    margin-left: 0.35rem;
    margin-right: 0.35rem;
    padding: 0.35em 0.65em;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    vertical-align: middle;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border-radius: 999px !important;
}

.nav-tabs .nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    white-space: nowrap;
    color: #94A3B8;
    border-color: transparent;
}

/* =============================================================================
   GARANTÍA DE FONDO AZUL MARINO OBSIDIANA Y MÁXIMO CONTRASTE DE TEXTOS
   ========================================================================== */

html, body, .app-body, .app-shell, .app-main, .app-topbar, .app-content, .auth-body {
    background-color: #0B1528 !important;
    color: #FFFFFF !important;
}

/* Override de fondos claros de Bootstrap para tarjetas y contenedores */
.bg-white, .bg-light, .bg-body, .bg-surface,
.card, .card-header, .card-header.bg-white, .card-footer, .card-footer.bg-white, .card-body.bg-white,
.panel {
    background-color: #111C30 !important;
    color: #FFFFFF !important;
    border-color: rgba(226, 232, 240, 0.12) !important;
}

.panel h2 {
    color: #FFFFFF !important;
}

/* Override de alertas de Bootstrap en tema oscuro KINET */
.alert {
    background-color: #111C30 !important;
    color: #FFFFFF !important;
    border-color: rgba(226, 232, 240, 0.15) !important;
}

.alert-light, .alert-secondary {
    background-color: #111C30 !important;
    color: #CBD5E1 !important;
    border: 1px solid rgba(226, 232, 240, 0.15) !important;
}

.alert-light strong, .alert-light b {
    color: #FFFFFF !important;
}

.alert-info {
    background-color: rgba(2, 132, 199, 0.15) !important;
    color: #7DD3FC !important;
    border: 1px solid rgba(2, 132, 199, 0.3) !important;
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: #FBBF24 !important;
    border: 1px solid rgba(245, 158, 11, 0.3) !important;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: #34D399 !important;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
}

.alert-danger {
    background-color: rgba(244, 63, 94, 0.15) !important;
    color: #FB7185 !important;
    border: 1px solid rgba(244, 63, 94, 0.3) !important;
}

/* Override de tablas y encabezados (solución definitiva para barras blancas) */
.table,
.table > :not(caption) > * > *,
.table-light,
thead.table-light,
.table-light > tr > th,
.table-light > tr > td,
.table > thead,
.table > thead > tr > th,
.table > tbody > tr > td {
    --bs-table-bg: #0B1528 !important;
    --bs-table-color: #FFFFFF !important;
    --bs-table-hover-bg: #15233D !important;
    --bs-table-hover-color: #FFFFFF !important;
    --bs-table-border-color: rgba(226, 232, 240, 0.12) !important;
    background-color: #0B1528 !important;
    color: #FFFFFF !important;
    border-color: rgba(226, 232, 240, 0.12) !important;
}

thead, thead.table-light, .table > thead, .table > thead > tr > th {
    background-color: #111C30 !important;
    color: #38BDF8 !important;
    font-family: var(--font-title, 'Plus Jakarta Sans', sans-serif) !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    font-size: 0.75rem !important;
    letter-spacing: 0.05em;
    border-bottom: 2px solid rgba(226, 232, 240, 0.15) !important;
}

.table-hover > tbody > tr:hover > * {
    --bs-table-accent-bg: #15233D !important;
    background-color: #15233D !important;
    color: #FFFFFF !important;
}

/* Override de textos oscuros para legibilidad crystal-clear */
.text-dark, .text-black, .text-body, strong, b, h1, h2, h3, h4, h5, h6, dt, dd, th, td {
    color: #FFFFFF !important;
}

.text-muted, .text-secondary, .muted, small, .small {
    color: #CBD5E1 !important; /* Plata Slate brillante de alto contraste */
}

/* Modales, Offcanvas, Tarjetas y Paneles */
.offcanvas, .offcanvas-header, .offcanvas-body, .modal-content, .modal-header, .modal-body, .modal-footer {
    background-color: #0B1528 !important;
    color: #FFFFFF !important;
    border-color: rgba(226, 232, 240, 0.15) !important;
}

/* Formularios, inputs y selects */
.form-control, .form-select, textarea, input[type="text"], input[type="number"], input[type="email"], input[type="password"], input[type="date"], input[type="time"], input[type="search"] {
    background-color: #060E1A !important;
    color: #FFFFFF !important;
    border: 1px solid #334155 !important;
}

.form-control:focus, .form-select:focus, textarea:focus, input[type="search"]:focus {
    background-color: #0B1528 !important;
    color: #FFFFFF !important;
    border-color: #0284C7 !important;
    box-shadow: 0 0 0 0.25rem rgba(2, 132, 199, 0.25) !important;
}

.form-label, label {
    color: #F8FAFC !important;
    font-weight: 500;
}

/* Enlaces dentro del panel */
a:not(.btn):not(.nav-item):not(.dropdown-item) {
    color: #38BDF8 !important;
}

a:not(.btn):not(.nav-item):not(.dropdown-item):hover {
    color: #7DD3FC !important;
    text-decoration: underline;
}

/* Badges neutros y sutiles de Bootstrap en tema oscuro KINET */
.badge {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.35rem !important;
    padding: 0.35rem 0.65rem !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    width: auto !important;
}

.badge.bg-light, 
.badge.text-dark,
.badge.bg-secondary-subtle,
.badge.bg-secondary {
    background-color: #1E293B !important;
    color: #F8FAFC !important;
    border: 1px solid #475569 !important;
}

.badge.bg-success-subtle,
.badge.text-success,
.badge.border-success-subtle {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: #34D399 !important;
    border: 1px solid rgba(16, 185, 129, 0.35) !important;
}

.badge.bg-danger-subtle,
.badge.text-danger,
.badge.border-danger-subtle {
    background-color: rgba(244, 63, 94, 0.15) !important;
    color: #FB7185 !important;
    border: 1px solid rgba(244, 63, 94, 0.35) !important;
}

.badge.bg-warning-subtle,
.badge.text-warning,
.badge.border-warning-subtle {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: #FBBF24 !important;
    border: 1px solid rgba(245, 158, 11, 0.35) !important;
}

.badge.bg-info-subtle,
.badge.text-info,
.badge.border-info-subtle {
    background-color: rgba(2, 132, 199, 0.15) !important;
    color: #38BDF8 !important;
    border: 1px solid rgba(2, 132, 199, 0.35) !important;
}

.badge.bg-primary {
    background-color: #0284C7 !important;
    color: #FFFFFF !important;
}

/* Bloques de código (Zona horaria, emails, etc) */
code, kbd, samp, pre {
    background-color: #1E293B !important;
    color: #38BDF8 !important;
    padding: 0.2rem 0.5rem !important;
    border-radius: 6px !important;
    font-size: 0.85em !important;
    border: 1px solid rgba(226, 232, 240, 0.15) !important;
    font-family: monospace;
}

/* Botones principales y secundarios KINET */
.btn-primary {
    background-color: #FF5A36 !important;
    border-color: #FF5A36 !important;
    color: #FFFFFF !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 8px rgba(255, 90, 54, 0.3) !important;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: #E04826 !important;
    border-color: #E04826 !important;
    color: #FFFFFF !important;
}

.btn-secondary {
    background-color: #0284C7 !important;
    border-color: #0284C7 !important;
    color: #FFFFFF !important;
    font-weight: 600 !important;
}

.btn-secondary:hover, .btn-secondary:focus {
    background-color: #0369A1 !important;
    border-color: #0369A1 !important;
    color: #FFFFFF !important;
}

.btn-outline-secondary {
    color: #CBD5E1 !important;
    border-color: #475569 !important;
    background-color: transparent !important;
}

.btn-outline-secondary:hover, .btn-outline-secondary:focus {
    background-color: #1E293B !important;
    color: #FFFFFF !important;
    border-color: #64748B !important;
}

.btn-outline-primary {
    color: #38BDF8 !important;
    border-color: #0284C7 !important;
    background-color: transparent !important;
}

.btn-outline-primary:hover, .btn-outline-primary:focus {
    background-color: #0284C7 !important;
    color: #FFFFFF !important;
}

.emoji-icon,
.nav-icon {
    margin-right: 0.4rem;
    display: inline-block;
    vertical-align: middle;
}

/* =============================================================================
   FULLCALENDAR TEMA MÉDICO ALTA PRECISIÓN (CLINIC CLOUD / ARCHIVEX STYLE)
   ========================================================================== */

.fc {
    font-family: var(--font-body);
    --fc-page-bg-color: #111C30;
    --fc-neutral-bg-color: #0B1528;
    --fc-list-day-cbg-color: #0B1528;
    --fc-border-color: rgba(226, 232, 240, 0.12);
    --fc-today-bg-color: rgba(2, 132, 199, 0.1);
    --fc-event-resizer-thickness: 8px;
    color: #F8FAFC;
}

.fc .fc-toolbar-title {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 1.35rem;
    color: #FFFFFF;
}

.fc .fc-button {
    background-color: #0B1528 !important;
    border: 1px solid rgba(226, 232, 240, 0.2) !important;
    color: #38BDF8 !important;
    font-weight: 600;
    border-radius: 8px !important;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
}

.fc .fc-button:hover {
    background-color: #0284C7 !important;
    color: #FFFFFF !important;
}

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
    background-color: #0284C7 !important;
    border-color: #0284C7 !important;
    color: #FFFFFF !important;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.fc-theme-standard td, .fc-theme-standard th {
    border-color: rgba(226, 232, 240, 0.1) !important;
}

.fc .fc-col-header-cell-cushion {
    color: #38BDF8;
    font-family: var(--font-title);
    font-weight: 700;
    padding: 8px 4px;
    text-transform: capitalize;
    text-decoration: none;
}

.fc .fc-timegrid-slot-label-cushion {
    color: #94A3B8;
    font-weight: 500;
    font-size: 0.8rem;
}

.fc .fc-timegrid-now-indicator-line {
    border-color: #FF5A36 !important;
    border-width: 2px !important;
}

.fc .fc-timegrid-now-indicator-arrow {
    border-color: #FF5A36 !important;
    border-width: 6px !important;
}

.fc-event {
    border-radius: 8px !important;
    padding: 3px 6px !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.fc-event:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
