/* ═══════════════════════════════════════════════════════════════
   PAYMI SALUD — Design System v2.0
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    /* Colores principales */
    --primary:        #2563eb;
    --primary-dark:   #1e40af;
    --primary-light:  #3b82f6;
    --primary-glow:   rgba(37, 99, 235, 0.22);

    --success:        #059669;
    --success-dark:   #047857;
    --success-glow:   rgba(5, 150, 105, 0.2);

    --warning:        #d97706;
    --warning-dark:   #b45309;
    --warning-glow:   rgba(217, 119, 6, 0.2);

    --danger:         #dc2626;
    --danger-dark:    #b91c1c;

    /* Fondo y superficies */
    --bg:             #f1f5fb;
    --surface:        #ffffff;
    --surface-soft:   #f8fafc;
    --surface-hover:  #f0f7ff;

    /* Bordes */
    --border:         #dde5f0;
    --border-soft:    #e8eef6;

    /* Textos */
    --text:           #0f172a;
    --text-soft:      #475569;
    --muted:          #64748b;

    /* Alertas */
    --danger-bg:      #fff1f1;
    --danger-border:  #fca5a5;
    --danger-text:    #991b1b;
    --ok-bg:          #f0fdf7;
    --ok-border:      #6ee7b7;
    --ok-text:        #065f46;

    /* Sombras */
    --shadow-xs:   0 1px 3px rgba(15,23,42,0.07), 0 1px 2px rgba(15,23,42,0.04);
    --shadow-sm:   0 4px 16px rgba(15,23,42,0.07), 0 1px 4px rgba(15,23,42,0.04);
    --shadow-md:   0 8px 28px rgba(15,23,42,0.09), 0 2px 8px rgba(15,23,42,0.05);
    --shadow-lg:   0 16px 48px rgba(15,23,42,0.11), 0 4px 16px rgba(15,23,42,0.06);
    --shadow-blue: 0 4px 18px rgba(37,99,235,0.28);
    --shadow-green:0 4px 18px rgba(5,150,105,0.28);

    /* Radio */
    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 9px;

    /* Navbar oscura */
    --nav-bg:     #0f172a;
    --nav-text:   rgba(255,255,255,0.75);
    --nav-active: #ffffff;

    /* Dark mode toggle */
    --dm-toggle-bg: rgba(255,255,255,0.1);
}

/* ══ MODO OSCURO ══════════════════════════════════════════════════ */
[data-theme="dark"] {
    --primary:       #3b82f6;
    --primary-dark:  #2563eb;
    --primary-light: #60a5fa;
    --primary-glow:  rgba(59,130,246,0.25);

    --bg:            #0f172a;
    --surface:       #1e293b;
    --surface-soft:  #1a2536;
    --surface-hover: #223047;

    --border:        #2d3f55;
    --border-soft:   #243347;

    --text:          #f1f5f9;
    --text-soft:     #94a3b8;
    --muted:         #64748b;

    --danger-bg:     #2d1515;
    --danger-border: #7f1d1d;
    --danger-text:   #fca5a5;
    --ok-bg:         #0d2318;
    --ok-border:     #166534;
    --ok-text:       #86efac;

    --shadow-xs:   0 1px 3px rgba(0,0,0,0.3);
    --shadow-sm:   0 4px 16px rgba(0,0,0,0.3);
    --shadow-md:   0 8px 28px rgba(0,0,0,0.4);
    --nav-bg:      #050d1a;
}

[data-theme="dark"] .card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .kpi-card,
[data-theme="dark"] .agenda-card { background: var(--surface); border-color: var(--border); }

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--surface); color: var(--text); border-color: var(--border);
}

[data-theme="dark"] .tabla thead th { background: var(--surface-soft); color: var(--muted); }
[data-theme="dark"] .tabla tbody tr:hover td { background: var(--surface-hover); }
[data-theme="dark"] .tabla td, [data-theme="dark"] .tabla th { border-color: var(--border); }

[data-theme="dark"] .hero { background: linear-gradient(135deg,#0c1a2e,#162540); }

/* Botón toggle dark mode */
.dm-btn {
    background: var(--dm-toggle-bg);
    border: none; cursor: pointer;
    color: var(--nav-text);
    font-size: 1rem; padding: 5px 8px;
    border-radius: 8px; transition: background .15s;
    line-height: 1;
}
.dm-btn:hover { background: rgba(255,255,255,0.18); }

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ─── Wrapper ────────────────────────────────────────────────── */
.wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px 24px;
}

/* ═══════════════════════════════════════════════════════════════
   NAVBAR — Premium oscura
   ═══════════════════════════════════════════════════════════════ */
.navbar {
    background: var(--nav-bg);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding: 0 28px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 16px rgba(0,0,0,0.25);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-weight: 800;
    font-size: 1.15rem;
    color: #fff;
    text-decoration: none;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.navbar-brand::before { display: none; }

.navbar-links {
    display: flex;
    gap: 2px;
    align-items: center;
    height: 100%;
}

.navbar-links a {
    text-decoration: none;
    color: var(--nav-text);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 6px 13px;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    height: 34px;
    display: flex;
    align-items: center;
}

.navbar-links a:hover {
    background: rgba(255,255,255,0.09);
    color: #fff;
}

.navbar-links a.active {
    background: rgba(59,130,246,0.2);
    color: #93c5fd;
    font-weight: 600;
}

.navbar-links .sep {
    width: 1px;
    height: 18px;
    background: rgba(255,255,255,0.12);
    margin: 0 4px;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.65);
}

.navbar-user strong { color: #fff; }

.navbar-consultorio {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.45);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    padding: 5px 14px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.7);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.btn-logout:hover {
    background: rgba(220,38,38,0.2);
    border-color: rgba(220,38,38,0.5);
    color: #fca5a5;
}

.badge-superadmin {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 6px rgba(217,119,6,0.4);
}

/* Dropdown */
.nav-dropdown { position: relative; height: 100%; display: flex; align-items: center; }

.nav-dropdown > .nav-btn {
    text-decoration: none;
    color: var(--nav-text);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 6px 13px;
    height: 34px;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 5px;
}

.nav-dropdown > .nav-btn:hover,
.nav-dropdown:hover > .nav-btn {
    background: rgba(255,255,255,0.09);
    color: #fff;
}

.nav-dropdown > .nav-btn.active {
    background: rgba(59,130,246,0.2);
    color: #93c5fd;
    font-weight: 600;
}

.nav-dropdown > .nav-btn .caret {
    font-size: 0.55rem;
    opacity: 0.5;
    transition: transform 0.2s;
}

.nav-dropdown:hover > .nav-btn .caret { transform: rotate(180deg); }

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: #1e293b;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 30px rgba(0,0,0,0.35);
    min-width: 185px;
    z-index: 200;
    padding: 6px;
    overflow: hidden;
}

.nav-dropdown:hover .dropdown-menu { display: block; }

.dropdown-menu a {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    text-decoration: none;
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 7px;
    transition: background 0.12s, color 0.12s;
}

.dropdown-menu a:hover {
    background: rgba(255,255,255,0.09);
    color: #fff;
}

.dropdown-menu a.active {
    background: rgba(59,130,246,0.2);
    color: #93c5fd;
    font-weight: 600;
}

.dropdown-menu .drop-sep {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 4px 0;
}

/* Encabezados de sección dentro de dropdown */
.dropdown-menu a.drop-section {
    font-weight: 800;
    font-size: 0.74rem;
    color: #93c5fd;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 9px 12px 4px;
    background: rgba(255,255,255,.04);
    border-left: 2px solid #3b82f6;
    margin-top: 2px;
}
.dropdown-menu a.drop-section:hover {
    background: rgba(59,130,246,.15);
    color: #bfdbfe;
}
.dropdown-menu a.drop-sub {
    padding-left: 22px;
    font-size: 0.82rem;
    color: rgba(255,255,255,.62);
}
.dropdown-menu a.drop-sub:hover { color: rgba(255,255,255,.9); }
.dropdown-menu.wide { min-width: 240px; }

/* ═══════════════════════════════════════════════════════════════
   HERO — Gradiente vibrante
   ═══════════════════════════════════════════════════════════════ */
.hero {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
    border-radius: var(--radius-xl);
    padding: 32px 36px;
    margin-bottom: 24px;
    box-shadow: 0 8px 32px rgba(37,99,235,0.35);
    position: relative;
    overflow: hidden;
}

.hero::after {
    content: '';
    position: absolute;
    top: -30%;
    right: -5%;
    width: 260px;
    height: 260px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    pointer-events: none;
}

.hero h1 {
    margin: 0 0 8px 0;
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.2;
    color: #ffffff;
    letter-spacing: -0.02em;
}

.hero p {
    margin: 0;
    color: rgba(255,255,255,0.75);
    max-width: 680px;
    font-size: 0.95rem;
}

/* ═══════════════════════════════════════════════════════════════
   CARD — Elevada y refinada
   ═══════════════════════════════════════════════════════════════ */
.card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 26px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* ═══════════════════════════════════════════════════════════════
   BOTONES — Gradientes y glow
   ═══════════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 10px 18px;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: #ffffff;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, filter 0.15s;
    box-shadow: var(--shadow-blue);
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(37,99,235,0.38);
    filter: brightness(1.07);
}

.btn:active { transform: translateY(0); filter: brightness(0.97); }

.btn:focus-visible,
.input:focus-visible,
.select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(59,130,246,0.4);
    outline-offset: 2px;
}

.btn-muted {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    box-shadow: 0 4px 14px rgba(71,85,105,0.22);
}
.btn-muted:hover { box-shadow: 0 6px 20px rgba(71,85,105,0.35); }

.btn-success {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: var(--shadow-green);
}
.btn-success:hover { box-shadow: 0 6px 22px rgba(5,150,105,0.38); }

.btn-warning {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    box-shadow: 0 4px 14px rgba(217,119,6,0.28);
}
.btn-warning:hover { box-shadow: 0 6px 22px rgba(217,119,6,0.42); }

.btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 14px rgba(220,38,38,0.28);
}
.btn-danger:hover { box-shadow: 0 6px 22px rgba(220,38,38,0.42); }

.btn-small {
    min-height: 32px;
    padding: 5px 11px;
    font-size: 0.8rem;
    border-radius: 7px;
    letter-spacing: 0;
}

.acciones {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.buscador {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    align-items: center;
}

/* ═══════════════════════════════════════════════════════════════
   INPUTS — Limpios con focus llamativo
   ═══════════════════════════════════════════════════════════════ */
.input,
.select,
textarea {
    width: 100%;
    min-width: 0;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: #fdfdff;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.input:hover,
.select:hover,
textarea:hover {
    border-color: #94a3b8;
    background: #fff;
}

.input:focus,
.select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
}

.input::placeholder,
textarea::placeholder { color: #a0aec0; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.campo {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.campo label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-soft);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.hint {
    font-size: 0.76rem;
    color: var(--muted);
}

/* ═══════════════════════════════════════════════════════════════
   TABLAS — Headers con gradiente
   ═══════════════════════════════════════════════════════════════ */
.tabla-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

th, td {
    border-bottom: 1px solid var(--border-soft);
    padding: 12px 14px;
    text-align: left;
    font-size: 0.875rem;
    vertical-align: middle;
}

th {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    border-bottom: 2px solid var(--border);
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
    transition: background 0.12s;
}

tbody tr:hover {
    background: var(--surface-hover);
}

/* ═══════════════════════════════════════════════════════════════
   ALERTAS
   ═══════════════════════════════════════════════════════════════ */
.alerta-ok,
.alerta-error {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 18px;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alerta-ok {
    background: var(--ok-bg);
    border: 1px solid var(--ok-border);
    color: var(--ok-text);
    border-left: 4px solid #059669;
}

.alerta-error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger-text);
    border-left: 4px solid #dc2626;
}

.lista-errores {
    margin: 0;
    padding-left: 18px;
}
.lista-errores li + li { margin-top: 6px; }

/* ═══════════════════════════════════════════════════════════════
   DETALLE — Grid de datos
   ═══════════════════════════════════════════════════════════════ */
.detalle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.detalle-item {
    background: linear-gradient(145deg, #f8fafc, #f1f5f9);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: box-shadow 0.15s, transform 0.15s;
}

.detalle-item:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.detalle-label {
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 7px;
    font-weight: 700;
}

.detalle-valor {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    word-break: break-word;
}

/* ═══════════════════════════════════════════════════════════════
   BADGE
   ═══════════════════════════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: var(--primary);
    border: 1px solid #bfdbfe;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 12px;
    box-shadow: 0 2px 8px rgba(37,99,235,0.12);
}

/* ═══════════════════════════════════════════════════════════════
   MISC
   ═══════════════════════════════════════════════════════════════ */
.mensaje { color: var(--muted); margin-top: 12px; }
.texto-vacio { color: var(--muted); font-style: italic; }

/* Scrollbar personalizada (Chrome/Edge) */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1cad8; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .wrap { padding: 16px; }

    .hero { padding: 22px 20px; }
    .hero h1 { font-size: 1.55rem; }

    .card { padding: 18px; }

    .acciones,
    .buscador { flex-direction: column; align-items: stretch; }

    .btn { width: 100%; justify-content: center; }

    th, td { white-space: nowrap; }

    .navbar { padding: 0 16px; }
    .navbar-brand { font-size: 1rem; }
}

@media (max-width: 480px) {
    .form-grid,
    .detalle-grid { grid-template-columns: 1fr; }

    .hero h1 { font-size: 1.3rem; }
}
