/* ============================================================
   Sistema de Citas Médicas – FCTM / UNA
   Paleta: #005bab  #00c1e3  #00b977
   ============================================================ */

:root {
    --azul:    #005bab;
    --cian:    #00c1e3;
    --verde:   #00b977;
    --rojo:    #e33a3a;
    --gris:    #9e9e9e;
    --gris-cl: #f0f0f0;
    --blanco:  #ffffff;
    --texto:   #1a1a2e;
    --shadow:  0 4px 18px rgba(0,91,171,.15);
    --radius:  10px;
    --grad:    linear-gradient(135deg, #005bab 0%, #00c1e3 55%, #00b977 100%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Arial, sans-serif; background: #f4f8fc; color: var(--texto); }

/* ── Header ─────────────────────────────────────────── */
header {
    background: var(--grad);
    padding: 14px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: 0 3px 12px rgba(0,0,0,.25);
}
.header-logos { display: flex; align-items: center; gap: 20px; }
.header-logos img { height: 68px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); }
.header-title {
    color: #fff;
    text-align: center;
    flex: 1;
}
.header-title h1      { font-size: 1.35rem; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.35); }
.header-title p       { font-size: .82rem; opacity: .9; margin-top: 2px; }
.header-title .header-fecha { font-size: 1rem; font-weight: 700; opacity: 1; margin-top: 5px; letter-spacing: .3px; }
.header-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-header {
    background: rgba(255,255,255,.2);
    border: 2px solid rgba(255,255,255,.7);
    color: #fff;
    padding: 8px 18px;
    border-radius: 25px;
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    transition: all .25s;
    text-decoration: none;
    display: inline-block;
}
.btn-header:hover { background: rgba(255,255,255,.9); color: var(--azul); }

/* ── Contenedor principal ───────────────────────────── */
.container { max-width: 1300px; margin: 0 auto; padding: 24px 16px; }

/* ── Tarjetas / secciones ───────────────────────────── */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 22px;
}
.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--azul);
    border-bottom: 3px solid var(--cian);
    padding-bottom: 8px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-title::before {
    content: '';
    display: inline-block;
    width: 6px; height: 20px;
    background: var(--grad);
    border-radius: 3px;
}

/* ── Formularios ────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: .82rem; font-weight: 600; color: #555; }
.form-group input,
.form-group select,
.form-group textarea {
    border: 1.5px solid #d0d9e8;
    border-radius: 7px;
    padding: 9px 12px;
    font-size: .9rem;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
    background: #fff;
}
.form-group input:focus,
.form-group select:focus {
    border-color: var(--cian);
    box-shadow: 0 0 0 3px rgba(0,193,227,.15);
}

/* ── Filas múltiples de especialidad ────────────────── */
.selector-row-item {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 14px 16px;
    background: #f4f8fc;
    border-radius: 10px;
    margin-bottom: 10px;
    border: 1.5px solid #d8e6f5;
    flex-wrap: wrap;
    transition: border-color .2s;
}
.selector-row-item:hover { border-color: var(--cian); }
.sr-num {
    width: 30px; height: 30px;
    background: var(--grad);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem;
    flex-shrink: 0; align-self: center;
}
.sr-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    flex: 1;
    align-items: flex-end;
}
.slot-selected-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--gris);
    color: #fff;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: .85rem;
    font-weight: 700;
}
.remove-slot-btn {
    background: rgba(255,255,255,.25);
    border: none;
    color: #fff;
    font-size: 1rem;
    width: 22px; height: 22px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: background .2s;
}
.remove-slot-btn:hover { background: rgba(255,255,255,.5); }
.slot-pending {
    color: #aaa;
    font-size: .8rem;
    font-style: italic;
    padding: 9px 0;
}
.btn-add-row {
    width: 100%;
    background: none;
    border: 2px dashed var(--cian);
    color: var(--cian);
    padding: 11px 22px;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
    margin-top: 4px;
}
.btn-add-row:hover { background: var(--cian); color: #fff; }
.btn-remove-row {
    background: #fdecea;
    border: 1.5px solid #f5c6cb;
    color: var(--rojo);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: .8rem;
    cursor: pointer;
    flex-shrink: 0;
    align-self: flex-end;
    transition: background .2s;
}
.btn-remove-row:hover { background: var(--rojo); color: #fff; }

/* ── Leyenda del grid ───────────────────────────────── */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    margin-bottom: 14px;
    font-size: .82rem;
    font-weight: 600;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-box {
    width: 22px; height: 22px;
    border-radius: 5px;
    border: 1px solid rgba(0,0,0,.12);
}
.lv { background: var(--verde); }
.lr { background: var(--rojo); }
.lg { background: var(--gris); }
.la { background: #c8e6c9; border: 1.5px solid #66bb6a; }

/* ── Grid de citas ──────────────────────────────────── */
.grid-wrapper { overflow-x: auto; }
.grid-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .82rem;
}
.grid-table th {
    background: var(--azul);
    color: #fff;
    padding: 10px 14px;
    text-align: center;
    font-size: .8rem;
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 2;
}
.grid-table th:first-child { background: var(--cian); border-radius: 8px 0 0 0; min-width: 80px; }
.grid-table th:last-child  { border-radius: 0 8px 0 0; }
.grid-table td {
    padding: 8px 10px;
    text-align: center;
    border-bottom: 1px solid #e8edf5;
    vertical-align: middle;
}
.grid-table td:first-child {
    font-weight: 700;
    color: var(--azul);
    background: #eef4fb;
    font-size: .85rem;
    border-right: 2px solid #d0daea;
}
.grid-table tr:hover td { background: rgba(0,193,227,.06); }

.slot-btn {
    display: inline-block;
    width: 100%;
    min-width: 110px;
    padding: 7px 6px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: .75rem;
    font-weight: 600;
    transition: transform .15s, box-shadow .15s;
    line-height: 1.3;
}
.slot-btn:hover:not(:disabled) { transform: scale(1.04); box-shadow: 0 3px 10px rgba(0,0,0,.2); }
.slot-btn:disabled { cursor: not-allowed; }

.slot-disponible      { background: var(--verde); color: #fff; }
.slot-ocupado         { background: var(--rojo);  color: #fff; cursor: not-allowed; }
.slot-seleccionado    { background: var(--gris);  color: #fff; }
.slot-asistio         { background: #388e3c;      color: #fff; }
.slot-bloqueado-doble { background: #fff3cd; border: 2px solid #ffc107; color: #856404; cursor: not-allowed; font-size: .7rem; }

/* ── Carrito de selección ───────────────────────────── */
.cart-list { list-style: none; }
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: 8px;
    background: #eef4fb;
    margin-bottom: 8px;
    font-size: .85rem;
    gap: 10px;
    flex-wrap: wrap;
}
.cart-item .info { flex: 1; }
.cart-item .info strong { color: var(--azul); }
.cart-item .remove-btn {
    background: var(--rojo);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 26px; height: 26px;
    font-size: .9rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity .2s;
}
.cart-item .remove-btn:hover { opacity: .8; }
.cart-empty { color: #888; font-style: italic; font-size: .88rem; }

/* ── Botón Agendar ──────────────────────────────────── */
.btn-book {
    background: var(--grad);
    color: #fff;
    border: none;
    padding: 14px 36px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(0,91,171,.35);
    transition: opacity .2s, transform .15s;
    display: block;
    margin: 0 auto;
}
.btn-book:hover { opacity: .88; transform: translateY(-2px); }
.btn-book:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── Modales ────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border-radius: 14px;
    padding: 30px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0,0,0,.3);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}
.modal h2 {
    font-size: 1.15rem;
    color: var(--azul);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-close {
    position: absolute;
    top: 14px; right: 16px;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #888;
    line-height: 1;
}
.modal-close:hover { color: var(--rojo); }

/* ── Botones generales ──────────────────────────────── */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 25px;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: opacity .2s;
}
.btn:hover { opacity: .85; }
.btn-primary   { background: var(--azul);  color: #fff; }
.btn-secondary { background: var(--gris);  color: #fff; }
.btn-success   { background: var(--verde); color: #fff; }
.btn-danger    { background: var(--rojo);  color: #fff; }
.btn-cian      { background: var(--cian);  color: #fff; }

/* ── Alertas / mensajes ─────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: .88rem;
    font-weight: 500;
}
.alert-success { background: #d4edda; color: #155724; border-left: 4px solid var(--verde); }
.alert-error   { background: #f8d7da; color: #721c24; border-left: 4px solid var(--rojo); }
.alert-info    { background: #d1ecf1; color: #0c5460; border-left: 4px solid var(--cian); }

/* ── Número de cita destacado ───────────────────────── */
.numero-cita-box {
    background: var(--grad);
    color: #fff;
    border-radius: 12px;
    padding: 18px 24px;
    text-align: center;
    margin: 14px 0;
}
.numero-cita-box .numero { font-size: 1.8rem; font-weight: 700; letter-spacing: 2px; }
.numero-cita-box small   { font-size: .8rem; opacity: .9; }

/* ── Tabla de costo ─────────────────────────────────── */
.cost-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: 10px; }
.cost-table th,
.cost-table td { padding: 7px 12px; border: 1px solid #e0e8f5; }
.cost-table th { background: var(--azul); color: #fff; }
.cost-table tr:nth-child(even) { background: #f4f8fc; }

/* ── Panel de administración ────────────────────────── */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid #d0daea; padding-bottom: 0; }
.tab-btn {
    padding: 9px 18px;
    border: none;
    background: #e8edf5;
    border-radius: 8px 8px 0 0;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    color: #555;
    transition: background .2s, color .2s;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.tab-btn:hover   { background: var(--cian); color: #fff; }
.tab-btn.active  { background: var(--azul); color: #fff; border-bottom-color: var(--azul); }
.tab-panel       { display: none; }
.tab-panel.active{ display: block; }

/* ── Tabla de admin ─────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.admin-table th {
    background: var(--azul); color: #fff;
    padding: 9px 10px;
    text-align: left;
    position: sticky; top: 0;
}
.admin-table td { padding: 8px 10px; border-bottom: 1px solid #e0e8f5; vertical-align: middle; }
.admin-table tr.asistio td { background: #c8e6c9 !important; }
.admin-table tr:hover td   { background: rgba(0,193,227,.07); }
.admin-table tr.asistio:hover td { background: #a5d6a7 !important; }

.check-asistio { width: 18px; height: 18px; cursor: pointer; accent-color: var(--verde); }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: .72rem;
    font-weight: 700;
}
.badge-verde { background: #d4edda; color: #155724; }
.badge-rojo  { background: #f8d7da; color: #721c24; }

/* ── Encabezado del PDF imprimible ──────────────────── */
.print-header { text-align: center; margin-bottom: 20px; }

/* ── Separador ──────────────────────────────────────── */
.divider { border: none; border-top: 2px solid #e0e8f5; margin: 18px 0; }

/* ── Barra de herramientas de admin ─────────────────── */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select {
    border: 1.5px solid #d0d9e8;
    border-radius: 7px;
    padding: 7px 12px;
    font-size: .85rem;
    outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--cian); }

/* ── Login form ─────────────────────────────────────── */
.login-card {
    max-width: 380px;
    margin: 60px auto;
    background: #fff;
    border-radius: 16px;
    padding: 36px;
    box-shadow: 0 8px 32px rgba(0,91,171,.2);
    text-align: center;
}
.login-card .logo-row { display: flex; justify-content: center; gap: 20px; margin-bottom: 20px; }
.login-card .logo-row img { height: 60px; }
.login-card h2 { color: var(--azul); margin-bottom: 22px; font-size: 1.1rem; }

/* ── Spinner de carga ───────────────────────────────── */
.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 3px solid #ccc;
    border-top-color: var(--azul);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
    header { padding: 12px 16px; }
    .header-logos img { height: 50px; }
    .header-title h1  { font-size: 1rem; }
    .container { padding: 14px 10px; }
    .btn-book { width: 100%; }
}

/* ── Print ──────────────────────────────────────────── */
@media print {
    header, .btn, .btn-header, .modal-overlay, .tabs,
    .btn-book, .btn-add-cart, .toolbar { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}
