:root {
    --azul-oscuro: #1e3a8a;
    --azul-medio: #2563eb;
    --cyan: #06b6d4;
    --azul-claro: #38bdf8;
    --azul-fondo: #eff6ff;
    --bg: #f0f7ff;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #bfdbfe;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --gradiente: linear-gradient(135deg, #1e3a8a 0%, #06b6d4 100%);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ===== HEADER ===== */
.header {
    background: var(--gradiente);
    color: white;
    padding: 20px 40px;
    box-shadow: 0 4px 15px rgba(30,58,138,0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -60%;
    left: 20%;
    width: 200px;
    height: 200px;
    background: rgba(6,182,212,0.1);
    border-radius: 50%;
}

.header h1 { 
    font-size: 24px; 
    display: flex; 
    align-items: center; 
    gap: 12px;
    position: relative;
    z-index: 1;
}

.header .logo-svg {
    width: 50px;
    height: 50px;
}

/* ===== LOGO SVG ===== */
.logo-container {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* ===== CONTAINER ===== */
.container { 
    padding: 30px 40px; 
    max-width: 1400px; 
    margin: 0 auto; 
}

/* ===== CARDS ===== */
.card {
    background: var(--card);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 15px rgba(30,58,138,0.08);
    margin-bottom: 20px;
    border-top: 4px solid var(--cyan);
}

.card h2 {
    color: var(--azul-oscuro);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== BOTONES ===== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(0); }

.btn-primary { 
    background: var(--azul-oscuro); 
    color: white; 
}
.btn-primary:hover { background: #1e40af; }

.btn-cyan { 
    background: var(--cyan); 
    color: white; 
}
.btn-cyan:hover { background: #0891b2; }

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }

/* ===== INPUTS ===== */
input, select {
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    width: 100%;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(6,182,212,0.15);
}

/* ===== TABLAS ===== */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

th {
    background: var(--azul-oscuro);
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

th:first-child { border-radius: 8px 0 0 0; }
th:last-child { border-radius: 0 8px 0 0; }

td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

tr:hover { background: var(--azul-fondo); }

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-espera { background: #fef3c7; color: #92400e; }
.badge-llamado { background: #dbeafe; color: #1e40af; }
.badge-atendido { background: #d1fae5; color: #065f46; }
.badge-cancelado { background: #fee2e2; color: #991b1b; }

/* ===== FORMULARIOS ===== */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--azul-oscuro);
    font-size: 13px;
}

.alert {
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
}
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid var(--success); }
.alert-error { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }

/* ============================================
   PANTALLA PACIENTES
   ============================================ */
.pantalla-pacientes {
    background: var(--gradiente);
    min-height: 100vh;
    color: white;
    padding: 0;
}

.pantalla-pacientes .header {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.pantalla-pacientes .container {
    max-width: 1600px;
}

.grid-consultorios {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.consultorio-card {
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 16px;
    padding: 25px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.consultorio-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--cyan), var(--azul-claro));
}

.consultorio-card.llamando {
    background: rgba(255,255,255,0.25);
    border-color: #fbbf24;
    animation: pulse 1.5s infinite;
}

.consultorio-card.llamando::before {
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
    height: 6px;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(251,191,36,0.4); }
    50% { transform: scale(1.02); box-shadow: 0 0 20px 5px rgba(251,191,36,0.2); }
}

.consultorio-card .numero {
    font-size: 52px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.consultorio-card .nombre {
    text-align: center;
    font-size: 15px;
    opacity: 0.9;
    margin-bottom: 15px;
    font-weight: 500;
}

.consultorio-card .paciente {
    background: rgba(255,255,255,0.2);
    padding: 14px;
    border-radius: 10px;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    min-height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.3;
}

.consultorio-card .paciente.vacio {
    opacity: 0.6;
    font-style: italic;
}

/* Modal de llamado */
.modal-llamado {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(30,58,138,0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-llamado.activo { display: flex; }

.modal-contenido {
    background: white;
    color: var(--text);
    padding: 50px 80px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 25px 80px rgba(0,0,0,0.5);
    animation: slideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-top: 6px solid var(--cyan);
    position: relative;
    max-width: 600px;
    width: 90%;
}

@keyframes slideIn {
    from { transform: translateY(-80px) scale(0.8); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-contenido .turno-num {
    font-size: 90px;
    font-weight: bold;
    background: var(--gradiente);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 15px 0;
    line-height: 1;
}

.modal-contenido .paciente-nombre {
    font-size: 34px;
    color: var(--azul-oscuro);
    margin: 20px 0;
    font-weight: 600;
}

.modal-contenido .consultorio-destino {
    font-size: 26px;
    color: var(--cyan);
    font-weight: 700;
    background: var(--azul-fondo);
    padding: 18px 35px;
    border-radius: 12px;
    margin-top: 20px;
    border: 2px solid var(--border);
}

.modal-contenido .subtitulo {
    font-size: 18px;
    color: var(--text-light);
    margin-bottom: 5px;
}

.modal-contenido .timer-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 6px;
    background: var(--cyan);
    border-radius: 0 0 24px 24px;
    animation: timerShrink 10s linear forwards;
}

@keyframes timerShrink {
    from { width: 100%; }
    to { width: 0%; }
}

/* Historial */
.historial-section {
    margin-top: 30px;
}

.historial-section h3 {
    color: white;
    margin-bottom: 15px;
    font-size: 20px;
    opacity: 0.95;
}

.historial-lista {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid rgba(255,255,255,0.15);
}

.historial-item {
    background: rgba(255,255,255,0.15);
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--cyan);
    transition: all 0.2s;
}

.historial-item:hover {
    background: rgba(255,255,255,0.25);
    transform: translateX(5px);
}

.historial-item .turno {
    background: white;
    color: var(--azul-oscuro);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: bold;
    margin-right: 15px;
    font-size: 14px;
}

.historial-item .nombre {
    flex: 1;
    font-weight: 500;
}

.historial-item .consultorio {
    background: rgba(6,182,212,0.3);
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 13px;
    font-weight: 600;
}

/* ============================================
   VISTA MÉDICO
   ============================================ */
.consultorio-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.consultorio-option {
    background: white;
    padding: 25px 20px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    border: 2px solid var(--border);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.consultorio-option::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 4px;
    background: var(--cyan);
}

.consultorio-option:hover { 
    border-color: var(--cyan);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(6,182,212,0.2);
}

.consultorio-option.active {
    background: var(--azul-oscuro);
    color: white;
    border-color: var(--azul-oscuro);
}

.consultorio-option.active::before {
    background: var(--cyan);
}

.consultorio-option .num { 
    font-size: 36px; 
    font-weight: bold;
    color: var(--azul-oscuro);
}

.consultorio-option.active .num {
    color: white;
}

.consultorio-option .esp {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 5px;
}

.consultorio-option.active .esp {
    color: rgba(255,255,255,0.8);
}

.paciente-item {
    background: white;
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--cyan);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.04);
}

.paciente-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(6,182,212,0.15);
}

.paciente-item.selected {
    border-left-color: var(--warning);
    background: #fffbeb;
    box-shadow: 0 4px 15px rgba(217,119,6,0.2);
}

.paciente-item .info { flex: 1; }
.paciente-item .info .nombre { font-weight: 600; font-size: 18px; color: var(--azul-oscuro); }
.paciente-item .info .cedula { color: var(--text-light); font-size: 20px; margin-top: 3px; }
.paciente-item .turno-num {
    background: var(--gradiente);
    color: white;
    padding: 8px 18px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 15px;
}

/* ============================================
   PANEL ADMIN
   ============================================ */
.tabs-container {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 12px 24px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--azul-oscuro);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    border-color: var(--cyan);
    background: var(--azul-fondo);
}

.tab-btn.active {
    background: var(--azul-oscuro);
    color: white;
    border-color: var(--azul-oscuro);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Responsive */
@media (max-width: 768px) {
    .container { padding: 15px; }
    .header { padding: 15px 20px; }
    .header h1 { font-size: 18px; }
    .modal-contenido { padding: 30px 40px; }
    .modal-contenido .turno-num { font-size: 60px; }
    .modal-contenido .paciente-nombre { font-size: 24px; }
    .consultorio-card .numero { font-size: 40px; }
}