/* ===== Variables ===== */
:root {
    --primary: #2563eb;
    --secondary: #1e40af;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --transition: all 0.2s ease;
}

/* ===== Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

.hidden {
    display: none !important;
}

/* ===== Botones ===== */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover {
    background-color: var(--secondary);
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover {
    background-color: var(--background);
    border-color: var(--muted);
}

.btn-success {
    background-color: #25d366;
    color: white;
}
.btn-success:hover {
    background-color: #1ebe5d;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}
.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 17px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.btn-nav {
    margin-left: 10px;
}

/* ===== Header público ===== */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
}

.logo {
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 20px;
    display: flex;
    align-items: center;
}

.logo img {
    max-height: 40px;
    width: auto;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.main-nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
    transition: var(--transition);
}

.main-nav a:hover {
    color: var(--primary);
}

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 4px;
}

.hamburger span {
    width: 25px;
    height: 2px;
    background: var(--text);
    display: block;
}

/* ===== Hero ===== */
.hero {
    background: linear-gradient(135deg, #1e3a5f, #2563eb);
    color: white;
    padding: 100px 0;
    text-align: center;
    background-size: cover;
    background-position: center;
}

.hero-content h1 {
    font-size: 48px;
    margin-bottom: 16px;
    font-weight: 800;
}

.hero-content p {
    font-size: 20px;
    margin-bottom: 30px;
    opacity: 0.9;
}

/* ===== Servicios ===== */
.services-section {
    padding: 60px 0;
}

.section-title {
    text-align: center;
    font-size: 32px;
    margin-bottom: 40px;
    font-weight: 700;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.service-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.service-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.service-card h3 {
    margin-bottom: 8px;
    font-size: 18px;
}

.service-card p {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 12px;
}

.service-card .duration {
    display: block;
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 16px;
}

/* ===== CTA ===== */
.cta-section {
    background: var(--surface);
    padding: 60px 0;
    text-align: center;
    border-top: 1px solid var(--border);
}

.cta-section h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

.cta-section p {
    color: var(--muted);
    margin-bottom: 24px;
}

/* ===== Footer ===== */
.site-footer {
    background: #1e293b;
    color: white;
    padding: 30px 0;
    text-align: center;
}

.footer-whatsapp {
    color: #25d366;
    text-decoration: none;
    margin-left: 10px;
}

/* ===== Popup ===== */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.popup-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 420px;
    width: 100%;
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    box-shadow: var(--shadow);
}

.popup-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.popup-content {
    padding: 24px;
    text-align: center;
}

.popup-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 12px;
    color: var(--primary);
}

.popup-desc {
    color: var(--muted);
    margin-bottom: 20px;
}

.popup-btn {
    width: 100%;
}

/* ===== Páginas de reserva ===== */
.booking-page, .consult-page, .cancel-page {
    background: var(--background);
    min-height: 100vh;
}

.booking-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.booking-header h1 {
    font-size: 20px;
}

.back-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 15px;
}

.back-link:hover {
    color: var(--primary);
}

.booking-container, .consult-container, .cancel-container {
    padding: 40px 20px;
    max-width: 600px;
}

.booking-step {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow);
}

.booking-step h2 {
    font-size: 22px;
    margin-bottom: 24px;
}

/* Selector de servicio */
.service-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.service-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
    font-family: inherit;
}

.service-option:hover {
    border-color: var(--primary);
}

.service-option.selected {
    border-color: var(--primary);
    background: #eff6ff;
}

.service-duration {
    color: var(--muted);
    font-size: 14px;
}

/* Grid de fechas */
.dates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
    margin-bottom: 20px;
}

.date-option {
    padding: 12px 8px;
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
    font-family: inherit;
}

.date-option:hover {
    border-color: var(--primary);
}

.date-option.selected {
    border-color: var(--primary);
    background: #eff6ff;
}

.date-option .day-name {
    display: block;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
}

.date-option .day-number {
    display: block;
    font-size: 20px;
    font-weight: 700;
}

.date-option .month-short {
    display: block;
    font-size: 10px;
    color: var(--muted);
}

/* Grid de horas */
.times-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-bottom: 20px;
}

.time-option {
    padding: 12px;
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 15px;
    transition: var(--transition);
    font-family: inherit;
}

.time-option:hover {
    border-color: var(--primary);
}

.time-option.selected {
    border-color: var(--primary);
    background: #eff6ff;
}

.time-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.loading {
    color: var(--muted);
    text-align: center;
}

/* ===== Formularios ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
}

.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    transition: var(--transition);
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400 !important;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

.booking-summary {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}

.booking-summary h4 {
    margin-bottom: 8px;
}

.booking-summary p {
    font-size: 14px;
    color: var(--muted);
}

/* ===== Confirmación ===== */
.confirmation-box {
    text-align: center;
}

.success-icon {
    width: 64px;
    height: 64px;
    background: var(--success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 20px;
}

.booking-code-box {
    background: var(--background);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 20px 0;
}

.booking-code-box span {
    display: block;
    color: var(--muted);
    font-size: 14px;
}

.booking-code-box strong {
    font-size: 28px;
    letter-spacing: 2px;
    color: var(--primary);
}

.confirm-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-pendiente { background: #fef3c7; color: #92400e; }
.badge-aprobada { background: #dcfce7; color: #166534; }
.badge-cancelada { background: #fee2e2; color: #991b1b; }
.badge-rechazada { background: #fecaca; color: #7f1d1d; }
.badge-finalizada { background: #e0e7ff; color: #3730a3; }
.badge-expirada { background: #e5e7eb; color: #4b5563; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* ===== Admin ===== */
.admin-body {
    display: flex;
    min-height: 100vh;
    background: var(--background);
}

.admin-sidebar {
    width: 220px;
    background: #1e293b;
    color: white;
    padding: 20px 0;
    flex-shrink: 0;
}

.admin-brand {
    font-size: 24px;
    font-weight: 800;
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
}

.admin-sidebar nav {
    display: flex;
    flex-direction: column;
}

.admin-sidebar nav a {
    color: #cbd5e1;
    text-decoration: none;
    padding: 12px 20px;
    transition: var(--transition);
    font-size: 14px;
}

.admin-sidebar nav a:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.admin-sidebar .logout-link {
    margin-top: auto;
    color: #fca5a5;
}

.admin-main {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.admin-main h2 {
    margin-bottom: 24px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-label {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
}

.stat-value.stat-small {
    font-size: 18px;
}

.stat-detail {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}

/* Tablas admin */
.admin-table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.admin-table table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th, .admin-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.admin-table th {
    background: var(--background);
    font-weight: 600;
    color: var(--muted);
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover td {
    background: #f1f5f9;
}

/* Filtros */
.filtros-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: space-between;
}

.filtros {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.search-form {
    display: flex;
    gap: 6px;
}

.search-form input {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}

/* Detalle de cita */
.cita-info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.cita-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.cita-fecha-hora {
    display: flex;
    gap: 16px;
    color: var(--muted);
}

.cita-details {
    margin-bottom: 20px;
}

.detail-row {
    display: flex;
    padding: 6px 0;
    border-bottom: 1px solid #f1f5f9;
}

.detail-label {
    width: 120px;
    font-weight: 600;
    color: var(--muted);
    flex-shrink: 0;
}

.cita-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.edit-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.edit-section h3 {
    margin-bottom: 20px;
}

/* Formularios admin */
.service-form-card, .content-section, .config-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.service-form-card h3, .content-section h3, .config-section h3 {
    margin-bottom: 20px;
}

/* Horarios */
.day-config {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    background: var(--surface);
}

.day-header {
    margin-bottom: 10px;
}

.day-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
}

.day-toggle input[type="checkbox"] {
    width: auto;
}

.hour-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.time-input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.time-separator {
    color: var(--muted);
}

.btn-add-hour {
    margin-top: 6px;
}

.blocked-section {
    margin-top: 30px;
}

.blocked-list {
    margin-top: 16px;
}

.blocked-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
}

.block-reason {
    color: var(--muted);
    flex: 1;
}

/* Login admin */
.admin-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}

.login-card h1 {
    text-align: center;
    margin-bottom: 4px;
}

.login-card p {
    text-align: center;
    color: var(--muted);
    margin-bottom: 24px;
}

/* Alert */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }
    
    .main-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--surface);
        flex-direction: column;
        padding: 20px;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-md);
    }
    
    .main-nav.open {
        display: flex;
    }
    
    .btn-nav {
        margin-left: 0;
        margin-top: 10px;
    }
    
    .hero-content h1 {
        font-size: 32px;
    }
    
    .hero-content p {
        font-size: 16px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .admin-body {
        flex-direction: column;
    }
    
    .admin-sidebar {
        width: 100%;
        padding: 10px 0;
    }
    
    .admin-sidebar nav {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }
    
    .admin-sidebar nav a {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .admin-main {
        padding: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .cita-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .cita-fecha-hora {
        flex-direction: column;
        gap: 4px;
    }
    
    .filtros-bar {
        flex-direction: column;
    }
    
    .search-form {
        width: 100%;
    }
    
    .search-form input {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }
    
    .booking-container, .consult-container {
        padding: 20px 12px;
    }
    
    .booking-step {
        padding: 20px 16px;
    }
    
    .dates-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 6px;
    }
    
    .times-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 6px;
    }
    
    .date-option {
        padding: 10px 6px;
    }
    
    .date-option .day-number {
        font-size: 16px;
    }
    
    .popup-card {
        max-width: 100%;
        margin: 10px;
    }
}