/* ==================== CSS Variables ==================== */
:root {
    --primary: #1976D2;
    --primary-dark: #1565C0;
    --primary-light: #E3F2FD;
    --accent: #FF6F00;
    --success: #2E7D32;
    --danger: #C62828;
    --warning: #F57F17;
    --bg: #F5F5F5;
    --surface: #FFFFFF;
    --text: #212121;
    --text-secondary: #757575;
    --text-light: #BDBDBD;
    --border: #E0E0E0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --bottom-nav-height: 64px;
    --top-bar-height: 56px;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

body {
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* ==================== Screens ==================== */
.screen {
    display: none;
    min-height: 100vh;
    padding-bottom: calc(var(--bottom-nav-height) + 16px);
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ==================== Auth Screen ==================== */
#login-screen {
    background: linear-gradient(135deg, #1976D2 0%, #1565C0 50%, #0D47A1 100%);
    padding-bottom: 0;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 24px;
    margin: auto;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
    color: white;
}

.auth-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-top: 12px;
    color: white;
}

.auth-header .subtitle {
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    margin-top: 4px;
}

.app-icon {
    margin: 0 auto;
    width: 64px;
    height: 64px;
}

.auth-tabs {
    display: flex;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 24px;
}

.auth-tabs .tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-tabs .tab.active {
    background: white;
    color: var(--primary);
}

.auth-form {
    display: none;
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.auth-form.active {
    display: block;
}

.auth-form h2 {
    margin-bottom: 16px;
    font-size: 20px;
    text-align: center;
}

.auth-link {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* ==================== Form Elements ==================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.2s;
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    background: white;
}

.form-group input.error {
    border-color: var(--danger);
}

.consent-box {
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 16px;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    margin-top: 2px;
    width: 16px;
    height: 16px;
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-full {
    width: 100%;
    padding: 14px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.1);
}

/* ==================== Top Bar ==================== */
.top-bar {
    height: var(--top-bar-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.top-bar-title {
    font-size: 18px;
    font-weight: 700;
}

.admin-bar {
    background: #1B1B1B;
}

/* ==================== Bottom Navigation ==================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--surface);
    display: flex;
    border-top: 1px solid var(--border);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-item.active {
    color: var(--primary);
}

.admin-nav .nav-item.active {
    color: #1B1B1B;
}

.nav-icon {
    font-size: 22px;
}

.nav-label {
    font-weight: 500;
}

/* ==================== Main Content ==================== */
.main-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.greeting {
    margin-bottom: 20px;
}

.greeting h2 {
    font-size: 22px;
    font-weight: 700;
}

.text-muted {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ==================== Quick Actions ==================== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.action-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.action-card:active {
    transform: scale(0.96);
}

.action-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.action-text {
    font-size: 14px;
    font-weight: 600;
}

/* ==================== Sections ==================== */
.section {
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.guides-section h3 {
    margin-bottom: 12px;
}

.guide-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.guide-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    color: var(--text);
    font-size: 14px;
    transition: all 0.2s;
}

.guide-link:active {
    transform: scale(0.98);
}

.chevron {
    color: var(--text-light);
    font-size: 20px;
}

/* ==================== Children List ==================== */
.child-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    margin-bottom: 8px;
}

.child-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.child-info {
    flex: 1;
}

.child-name {
    font-weight: 600;
    font-size: 15px;
}

.child-detail {
    font-size: 13px;
    color: var(--text-secondary);
}

.child-status {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
}

.child-status.ok {
    background: #E8F5E9;
    color: var(--success);
}

.child-status.no {
    background: #FFF3E0;
    color: var(--warning);
}

/* ==================== Booking Cards ==================== */
.booking-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.booking-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.booking-number {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.booking-status {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
}

.booking-status.active {
    background: #E8F5E9;
    color: var(--success);
}

.booking-status.cancelled {
    background: #FFEBEE;
    color: var(--danger);
}

.booking-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.booking-detail {
    font-size: 14px;
    color: var(--text);
}

/* ==================== Stats Grid ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ==================== Modal ==================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    padding: 16px;
    align-items: flex-end;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.modal-body {
    padding: 20px;
    min-height: 100px;
}

/* ==================== Slot Cards ==================== */
.slot-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.slot-card:hover {
    border-color: var(--primary);
}

.slot-card.selected {
    background: var(--primary-light);
    border-color: var(--primary);
}

.slot-date {
    font-weight: 600;
    font-size: 15px;
}

.slot-time {
    color: var(--text-secondary);
    font-size: 13px;
}

.slot-available {
    font-size: 12px;
    font-weight: 600;
    color: var(--success);
}

.slot-available.full {
    color: var(--danger);
}

/* ==================== Toast ==================== */
#toast-container {
    position: fixed;
    bottom: 80px;
    left: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 600;
    font-size: 14px;
    animation: fadeInUp 0.3s ease;
    pointer-events: auto;
    text-align: center;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== Guide Content ==================== */
.guide-content {
    line-height: 1.7;
    font-size: 14px;
}

.guide-content b {
    color: var(--primary);
}

.guide-content ul {
    padding-left: 20px;
    margin: 8px 0;
}

.guide-content li {
    margin-bottom: 4px;
}

/* ==================== File Upload ==================== */
.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 16px;
}

.file-upload-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-upload-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.file-upload-text {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ==================== Admin Patients List ==================== */
.patient-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    box-shadow: var(--shadow);
    margin-bottom: 8px;
}

.patient-card .patient-name {
    font-weight: 600;
    font-size: 15px;
}

.patient-card .patient-info {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
    margin-top: 4px;
}

.patient-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* ==================== Responsive ==================== */
@media (min-width: 768px) {
    .quick-actions {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .modal {
        border-radius: var(--radius);
        margin: auto;
    }
    
    .modal-overlay {
        align-items: center;
    }
}