/* ============================================================
   DESIGN SYSTEM — Omnisalud Citas Especializadas
   Basado en el Manual de Imagen Corporativa de Omnisalud:
   azul corporativo #1C75BB como color dominante, navy #0F1A2B
   para superficies oscuras y el rosado #E22084 reservado al logo
   y a acentos mínimos.
   ============================================================ */

/* ── Google Fonts (Figtree: sans geométrica, sustituto web de Antipasto) ── */
@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700;800&display=swap');

/* ── Design Tokens ── */
:root {
    /* Marca — paleta primaria */
    --blue:          #1C75BB;
    --pink:          #E22084;   /* solo acentos mínimos */
    --dark:          #333333;
    --gray:          #D9D8D6;

    /* Marca — paleta secundaria */
    --blue-light:    #009CE0;
    --cyan:          #00BDEA;
    --purple:        #AF2680;
    --pink-light:    #FFACDC;
    --pink-soft:     #FFC6E7;

    /* Derivados del azul */
    --navy:          #0F1A2B;
    --navy-2:        #14243A;
    --blue-dark:     #155E96;
    --blue-darker:   #0E3F6B;
    --blue-bg:       #EAF3FB;
    --blue-50:       #F4F9FD;
    --pink-bg:       #FDEAF3;
    --gradient-brand: linear-gradient(135deg, #1C75BB 0%, #009CE0 100%);
    --gradient-dark:  linear-gradient(160deg, #0F1A2B 0%, #14243A 55%, #0E3F6B 100%);
    --gradient-pink:  var(--gradient-brand); /* compatibilidad: ya no se usa rosado en rellenos */

    /* Neutrales */
    --white:         #FFFFFF;
    --bg-page:       #F3F6F9;
    --bg-card:       #FFFFFF;
    --bg-subtle:     #F7F9FB;
    --text-main:     #1B2A3A;
    --text-muted:    #556577;
    --text-light:    #8796A7;
    --border:        #D9E1EA;
    --border-light:  #E9EEF3;

    /* Estado (contraste AA sobre su fondo) */
    --success:       #12805C;
    --success-bg:    #E7F5EF;
    --danger:        #C62828;
    --danger-bg:     #FDECEC;
    --warning:       #B45309;
    --warning-bg:    #FEF4E6;
    --info:          #1C75BB;
    --info-bg:       #EAF3FB;

    /* Elevación */
    --shadow-xs:     0 1px 2px rgba(15,26,43,.05);
    --shadow-sm:     0 1px 3px rgba(15,26,43,.08), 0 1px 2px rgba(15,26,43,.04);
    --shadow-md:     0 4px 12px rgba(15,26,43,.08), 0 2px 4px rgba(15,26,43,.04);
    --shadow-lg:     0 12px 28px rgba(15,26,43,.10), 0 4px 8px rgba(15,26,43,.04);
    --shadow-xl:     0 24px 48px rgba(15,26,43,.16);
    --shadow-glow:   0 0 0 4px rgba(28,117,187,.18);
    --focus-ring:    0 0 0 3px rgba(28,117,187,.35);

    /* Bordes */
    --radius-xs:     4px;
    --radius-sm:     8px;
    --radius:        12px;
    --radius-lg:     16px;
    --radius-xl:     20px;
    --radius-pill:   999px;
    --radius-circle: 50%;

    /* Movimiento */
    --ease-out:      cubic-bezier(0.2, 0.8, 0.2, 1);
    --ease-spring:   cubic-bezier(0.34, 1.3, 0.64, 1);
    --transition-fast: 0.15s var(--ease-out);
    --transition:    0.25s var(--ease-out);
    --transition-slow: 0.4s var(--ease-out);

    /* Tipografía */
    --font: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, 'Cascadia Code', 'Segoe UI Mono', monospace;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    font-size: 1rem;
    background: var(--bg-page);
    color: var(--text-main);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    min-height: 100dvh;
}

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

/* ── Íconos SVG ── */
.ico { display: inline-block; flex-shrink: 0; vertical-align: -0.2em; }

/* ── Accesibilidad ── */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; top: -100%; left: 50%; transform: translateX(-50%);
    background: var(--blue); color: var(--white); padding: 12px 24px;
    border-radius: var(--radius-sm); z-index: 9999; font-weight: 600;
    transition: top var(--transition);
}
.skip-link:focus { top: 10px; color: var(--white); }

:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ── Utilidades ── */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ── Tipografía ── */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

a {
    color: var(--blue);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--blue-dark); }

/* ── Logo ── */
.brand-logo { height: auto; width: 100%; max-width: 220px; }

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    overflow: hidden;
}
.card-body { padding: 1.5rem; }

/* ── Botones ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0.7rem 1.35rem;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    font-family: var(--font);
    line-height: 1.2;
    transition: background-color var(--transition-fast), border-color var(--transition-fast),
                color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible { box-shadow: var(--focus-ring); }
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--blue); color: var(--white); box-shadow: 0 1px 2px rgba(15,26,43,.12); }
.btn-primary:hover { background: var(--blue-dark); color: var(--white); }

.btn-pink { background: var(--blue); color: var(--white); } /* compatibilidad */
.btn-pink:hover { background: var(--blue-dark); color: var(--white); }

.btn-secondary {
    background: var(--white);
    color: var(--text-main);
    border-color: var(--border);
}
.btn-secondary:hover {
    background: var(--blue-50);
    border-color: var(--blue);
    color: var(--blue);
}

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #0E6A4C; color: var(--white); }
.btn-danger  { background: var(--danger);  color: var(--white); }
.btn-danger:hover { background: #A61F1F; color: var(--white); }
.btn-warning { background: var(--warning); color: var(--white); }
.btn-warning:hover { background: #92430A; color: var(--white); }

.btn-sm { min-height: 36px; padding: 0.45rem 0.9rem; font-size: 0.85rem; border-radius: var(--radius-sm); }
.btn-lg { min-height: 52px; padding: 0.9rem 1.75rem; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ── Badges de estado ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge-warning   { background: var(--warning-bg); color: #8A3D06; border-color: #F6DDBB; }
.badge-success   { background: var(--success-bg); color: #0B5E43; border-color: #C3E6D6; }
.badge-danger    { background: var(--danger-bg);  color: #9B1C1C; border-color: #F5C6C6; }
.badge-info      { background: #E5F6FC;           color: #035E86; border-color: #BDE7F7; }
.badge-primary   { background: var(--blue-bg);    color: var(--blue-darker); border-color: #C9DFF2; }
.badge-secondary { background: #EEF2F6;           color: var(--text-muted); border-color: var(--border); }
.badge-attending { background: var(--blue); color: #fff; animation: pulseAttend 2s ease-in-out infinite; }

@keyframes pulseAttend {
    0%, 100% { box-shadow: 0 0 0 0 rgba(28,117,187,.45); }
    50%      { box-shadow: 0 0 0 6px rgba(28,117,187,0); }
}

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

.form-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0.45rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}
.form-label .ico { color: var(--blue); }
.form-label small { font-weight: 500; color: var(--text-muted); }

.form-control {
    width: 100%;
    min-height: 46px;
    padding: 0.7rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: var(--font);
    color: var(--text-main);
    background: var(--white);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    appearance: none;
}
.form-control:hover { border-color: #B9C6D4; }
.form-control:focus, .form-control:focus-visible {
    outline: none;
    border-color: var(--blue);
    box-shadow: var(--focus-ring);
}
.form-control[readonly] { background: var(--bg-subtle); color: var(--text-muted); }
.form-control::placeholder { color: var(--text-light); }
.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(198,40,40,.25); }

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23556577' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    padding-right: 2.5rem;
}
select.form-control[multiple] { background-image: none; padding-right: 0.95rem; }

textarea.form-control { resize: vertical; min-height: 100px; }

input[type="checkbox"], input[type="radio"] { accent-color: var(--blue); width: 18px; height: 18px; }

.form-hint {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 4px;
}

/* ── Grid ── */
.grid-2, .grid-3, .grid-4 { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ── Mensajes flash ── */
.flash-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(420px, calc(100vw - 32px));
}
.flash-message {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    background: var(--white);
    color: var(--text-main);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--blue);
    animation: slideInRight 0.3s var(--ease-out);
    display: flex;
    align-items: center;
    gap: 10px;
}
.flash-message.success { border-left-color: var(--success); }
.flash-message.danger  { border-left-color: var(--danger); }
.flash-message.warning { border-left-color: var(--warning); }
.flash-message.info    { border-left-color: var(--blue); }

.flash-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--text-muted);
    width: 28px; height: 28px;
    border-radius: var(--radius-sm);
}
.flash-close:hover { background: var(--bg-subtle); color: var(--text-main); }

@keyframes slideInRight {
    from { transform: translateX(24px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ── Tablas ── */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}
.data-table th {
    background: var(--bg-subtle);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.data-table td:first-child { white-space: nowrap; }
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: var(--blue-50); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Paginación ── */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 1.5rem;
    list-style: none;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text-muted);
    transition: all var(--transition-fast);
}
.pagination a:hover { border-color: var(--blue); color: var(--blue); }
.pagination .active { background: var(--blue); color: var(--white); border-color: var(--blue); }

/* ── Animaciones ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in  { animation: fadeIn 0.35s var(--ease-out); }
.slide-up { animation: slideUp 0.35s var(--ease-out); }

/* ── Spinner ── */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--blue-bg);
    border-top-color: var(--blue);
    border-radius: var(--radius-circle);
    animation: spin 0.8s linear infinite;
}

/* ── Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,26,43,.55);
    z-index: 5000;
    justify-content: center;
    align-items: center;
    padding: 16px;
    animation: fadeIn 0.2s var(--ease-out);
}
.modal-overlay.active { display: flex; }

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.25s var(--ease-out);
}
.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .card-body { padding: 1.1rem; }
}

/* ── Movimiento reducido ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
