/* Selah Fisioterapia & Recovery - Styles v3.0 */

/* Light Theme (Default) */
:root, :root.light {
    --primary: #1E5AA8;
    --primary-dark: #154785;
    --primary-light: #3A7BD5;
    --secondary: #E8F4FD;
    --accent: #5BA4E6;
    --accent-light: #D1E9FF;
    --danger: #DC3545;
    --danger-light: #F8D7DA;
    --success: #28A745;
    --success-light: #D4EDDA;
    --warning: #FFC107;
    --warning-light: #FFF3CD;
    --text-dark: #1A2B3C;
    --text-medium: #4A5568;
    --text-light: #8B99A8;
    --border: #D1E0EE;
    --white: #FFFFFF;
    --bg-light: #F5F9FC;
    --bg-main: #EEF3F8;
    --card-bg: #FFFFFF;
    --sidebar-bg: #1E5AA8;
    --sidebar-text: #FFFFFF;
    --shadow: 0 2px 4px rgba(30,90,168,0.08);
    --shadow-md: 0 4px 12px rgba(30,90,168,0.12);
    --shadow-lg: 0 8px 24px rgba(30,90,168,0.15);
    --radius: 8px;
    --radius-lg: 12px;
    --input-bg: #FFFFFF;
    --modal-bg: #FFFFFF;
    --hover-bg: rgba(30,90,168,0.05);
}

/* Dark Theme */
:root.dark {
    --primary: #3A7BD5;
    --primary-dark: #1E5AA8;
    --primary-light: #5BA4E6;
    --secondary: #1a2a3a;
    --accent: #5BA4E6;
    --accent-light: #2a4a6a;
    --danger: #E74C3C;
    --danger-light: #4a2020;
    --success: #2ECC71;
    --success-light: #1a3a2a;
    --warning: #F1C40F;
    --warning-light: #4a4020;
    --text-dark: #E8EEF4;
    --text-medium: #A0AEC0;
    --text-light: #718096;
    --border: #2D3748;
    --white: #1A2332;
    --bg-light: #0F1621;
    --bg-main: #0F1621;
    --card-bg: #1A2332;
    --sidebar-bg: #0F1621;
    --sidebar-text: #E8EEF4;
    --shadow: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    --radius: 8px;
    --radius-lg: 12px;
    --input-bg: #1A2332;
    --modal-bg: #1A2332;
    --hover-bg: rgba(90,180,230,0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Custom Scrollbar - Elegant Style */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* Hide scrollbar on sidebar navigation */
.nav-menu::-webkit-scrollbar {
    width: 4px;
}

.nav-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.nav-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: var(--bg-main);
    color: var(--text-dark);
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Base element styles using variables */
.card {
    background: var(--card-bg);
    color: var(--text-dark);
    transition: background 0.3s ease, color 0.3s ease;
}

input, select, textarea {
    background: var(--input-bg);
    color: var(--text-dark);
    border-color: var(--border);
    transition: background 0.3s ease, color 0.3s ease;
}

input::placeholder, textarea::placeholder {
    color: var(--text-light);
}

.modal-content {
    background: var(--modal-bg);
    color: var(--text-dark);
    transition: background 0.3s ease, color 0.3s ease;
}

.main-content {
    background: var(--bg-main);
    transition: background 0.3s ease;
}

.stat-card {
    background: var(--card-bg);
    color: var(--text-dark);
    transition: background 0.3s ease, color 0.3s ease;
}

.section-header {
    color: var(--text-dark);
}

.patient-card, .user-card, .appointment-card {
    background: var(--card-bg);
    color: var(--text-dark);
    transition: background 0.3s ease, color 0.3s ease;
}

.patient-card:hover, .user-card:hover, .appointment-card:hover {
    background: var(--hover-bg);
}

.settings-section {
    background: var(--card-bg);
    color: var(--text-dark);
    transition: background 0.3s ease, color 0.3s ease;
}

/* Theme toggle button */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    margin-bottom: 12px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.theme-toggle:hover {
    background: var(--hover-bg);
}

.theme-toggle-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle-info span {
    color: var(--text-dark);
    font-weight: 500;
}

.theme-toggle-icons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-icon {
    width: 24px;
    height: 24px;
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

.theme-icon.active {
    opacity: 1;
}

.theme-icon.light-icon {
    color: #F1C40F;
}

.theme-icon.dark-icon {
    color: #3498DB;
}

/* Toggle switch */
.theme-switch {
    position: relative;
    width: 56px;
    height: 28px;
    background: var(--border);
    border-radius: 14px;
    transition: background 0.3s ease;
}

.theme-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: var(--white);
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: var(--shadow);
}

:root.dark .theme-switch::after {
    transform: translateX(28px);
}

:root.dark .theme-switch {
    background: var(--primary);
}

/* App Container */
.app-container { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}

.logo-icon {
    width: 45px;
    height: 55px;
    color: var(--white);
}

.logo-text { display: flex; flex-direction: column; }

.logo-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--white);
    letter-spacing: 0.5px;
}

.logo-tagline {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.75);
    letter-spacing: 0.3px;
}

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(255,255,255,0.1);
    margin: 12px;
    border-radius: var(--radius);
    color: var(--white);
    font-size: 0.85rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #F59E0B;
}

.status-dot.online { background: #10B981; }
.status-dot.offline { background: #EF4444; }
.status-dot.syncing { background: #F59E0B; animation: pulse 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.nav-menu {
    list-style: none;
    padding: 12px;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    color: rgba(255,255,255,0.8);
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.15);
    color: var(--white);
}

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

.nav-item svg { width: 20px; height: 20px; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.15);
}

.sync-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--white);
    border: none;
    border-radius: var(--radius);
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.sync-btn:hover {
    background: var(--secondary);
    transform: translateY(-1px);
}

.sync-btn.syncing svg { animation: spin 1s linear infinite; }

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.sync-btn svg { width: 18px; height: 18px; }

.sync-status {
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.7);
    margin-top: 8px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px;
    max-width: calc(100% - 260px);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    background: var(--white);
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-light);
    padding: 10px 16px;
    border-radius: var(--radius);
    flex: 1;
    max-width: 400px;
    border: 1px solid var(--border);
}

.search-bar svg { width: 20px; height: 20px; color: var(--text-light); }

.search-bar input {
    border: none;
    background: none;
    outline: none;
    font-size: 0.95rem;
    width: 100%;
    color: var(--text-dark);
}

.header-date { font-weight: 500; color: var(--text-medium); }

/* Sections */
.section { display: none; }
.section.active { display: block; }

.section h1 {
    font-size: 1.75rem;
    margin-bottom: 24px;
    color: var(--primary);
}

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

.section-header h1 { margin-bottom: 0; }

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary svg { width: 18px; height: 18px; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--white);
    color: var(--text-medium);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-light);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
}

.btn-danger:hover { background: #C82333; }

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    border-left: 4px solid var(--primary);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg { width: 28px; height: 28px; }

.patients-icon { background: var(--secondary); color: var(--primary); }
.today-icon { background: var(--success-light); color: var(--success); }
.pending-icon { background: var(--warning-light); color: #D97706; }
.week-icon { background: var(--accent-light); color: var(--accent); }

.stat-info { display: flex; flex-direction: column; }

.stat-number { font-size: 1.75rem; font-weight: 700; color: var(--text-dark); }
.stat-label { color: var(--text-light); font-size: 0.9rem; }

.dashboard-columns {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.today-schedule, .next-patient {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.today-schedule h2, .next-patient h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--primary);
    padding-bottom: 12px;
    border-bottom: 2px solid var(--secondary);
}

.appointment-list { max-height: 400px; overflow-y: auto; }

.appointment-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    background: var(--bg-light);
    gap: 12px;
    border: 1px solid var(--border);
}

.appointment-time {
    font-weight: 600;
    color: var(--primary);
    min-width: 70px;
}

.appointment-info { flex: 1; }
.appointment-info .name { font-weight: 500; color: var(--text-dark); }
.appointment-info .therapy { font-size: 0.85rem; color: var(--text-light); }

.appointment-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-confirmed { background: var(--success-light); color: var(--success); }
.status-pending { background: var(--warning-light); color: #D97706; }
.status-completed { background: var(--secondary); color: var(--primary); }
.status-cancelled { background: var(--danger-light); color: var(--danger); }

.appointment-actions { display: flex; gap: 8px; }

.whatsapp-btn {
    background: #25D366;
    color: white;
    border: none;
    padding: 8px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.whatsapp-btn:hover { background: #128C7E; }
.whatsapp-btn svg { width: 18px; height: 18px; }

.next-patient-card { text-align: center; padding: 20px; }
.next-patient-card .patient-name { font-size: 1.25rem; font-weight: 600; color: var(--text-dark); margin-bottom: 8px; }
.next-patient-card .patient-time { font-size: 2rem; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.next-patient-card .patient-therapy { color: var(--text-light); margin-bottom: 16px; }

.no-data { color: var(--text-light); text-align: center; padding: 40px 20px; }

/* Calendar */
.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: var(--white);
    padding: 16px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.view-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg-light);
    padding: 4px;
    border-radius: var(--radius);
}

.view-btn {
    padding: 8px 16px;
    border: none;
    background: none;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-medium);
    font-weight: 500;
}

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

.date-nav { display: flex; align-items: center; gap: 12px; }

.date-nav button {
    padding: 8px;
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.date-nav button:hover { background: var(--bg-light); }
.date-nav button svg { width: 18px; height: 18px; }

#calendarTitle { font-weight: 600; min-width: 150px; text-align: center; color: var(--primary); }

.today-btn {
    padding: 8px 16px !important;
    background: var(--primary) !important;
    color: var(--white) !important;
    border: none !important;
}

.calendar-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.week-view { display: grid; grid-template-columns: 80px repeat(7, 1fr); }
.week-header { display: contents; }

.week-header-cell {
    padding: 16px 8px;
    text-align: center;
    background: var(--secondary);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--primary);
}

.week-header-cell.today { background: var(--primary); color: var(--white); }
.week-header-cell .day-name { font-size: 0.8rem; text-transform: uppercase; }
.week-header-cell.today .day-name { color: rgba(255,255,255,0.8); }
.week-header-cell .day-number { font-size: 1.25rem; }

.time-column { background: var(--bg-light); }

.time-slot {
    height: 60px;
    padding: 4px 8px;
    font-size: 0.8rem;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
    text-align: right;
}

.day-column { border-left: 1px solid var(--border); position: relative; }

.day-slot {
    height: 60px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.day-slot:hover { background: var(--secondary); }

.calendar-event {
    position: absolute;
    left: 2px;
    right: 2px;
    background: var(--primary);
    color: var(--white);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    overflow: hidden;
    z-index: 10;
}

.calendar-event:hover { z-index: 20; box-shadow: var(--shadow-md); }
.calendar-event.status-pending { background: #D97706; }
.calendar-event.status-confirmed { background: var(--primary); }
.calendar-event.status-completed { background: var(--success); }
.calendar-event.status-cancelled { background: var(--text-light); text-decoration: line-through; }

/* Patients Grid */
.patients-filters { display: flex; gap: 16px; margin-bottom: 20px; }

.patients-filters input,
.patients-filters select {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--white);
}

.patients-filters input { flex: 1; max-width: 300px; }

.patients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.patient-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: all 0.2s;
    border-top: 4px solid var(--primary);
}

.patient-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

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

.patient-card-header h3 { font-size: 1.1rem; margin-bottom: 4px; color: var(--primary); }
.patient-card-header .diagnosis { font-size: 0.9rem; color: var(--text-light); }

.patient-card-body { padding: 20px; }

.patient-detail {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--text-medium);
}

.patient-detail svg { width: 16px; height: 16px; color: var(--text-light); }

.patient-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.tag {
    padding: 4px 10px;
    background: var(--secondary);
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.patient-card-footer {
    padding: 16px 20px;
    background: var(--bg-light);
    display: flex;
    gap: 8px;
}

.patient-card-footer button {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.patient-card-footer button svg { width: 16px; height: 16px; }

.btn-edit { background: var(--white); border: 1px solid var(--border); color: var(--text-medium); }
.btn-edit:hover { background: var(--primary); color: var(--white); border-color: var(--primary); }

.btn-schedule { background: var(--primary); border: none; color: var(--white); }
.btn-schedule:hover { background: var(--primary-dark); }

.btn-whatsapp { background: #25D366; border: none; color: var(--white); }
.btn-whatsapp:hover { background: #128C7E; }

/* Templates */
.templates-info {
    background: var(--secondary);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    color: var(--text-medium);
}

.templates-info code {
    background: var(--white);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--primary);
}

.templates-list { display: grid; gap: 16px; }

.template-card {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.template-card h3 { margin-bottom: 8px; color: var(--primary); }
.template-card p { color: var(--text-medium); font-size: 0.95rem; }

.template-actions { display: flex; gap: 8px; }

.template-actions button {
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
}

/* Settings */
.settings-card {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.settings-card h2 { color: var(--primary); margin-bottom: 8px; }
.settings-description { color: var(--text-light); margin-bottom: 20px; }

.settings-actions { display: flex; gap: 12px; margin-top: 20px; }

.data-stats { display: flex; gap: 24px; margin-bottom: 20px; }

.data-stat { text-align: center; }
.data-stat-number { display: block; font-size: 2rem; font-weight: 700; color: var(--primary); }
.data-stat-label { font-size: 0.85rem; color: var(--text-light); }

.connection-test-result { margin-top: 16px; padding: 12px; border-radius: var(--radius); }
.connection-test-result.success { background: var(--success-light); color: var(--success); }
.connection-test-result.error { background: var(--danger-light); color: var(--danger); }

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large { max-width: 700px; }

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--primary);
    color: var(--white);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h2 { font-size: 1.25rem; }

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--white);
    padding: 0;
    line-height: 1;
    opacity: 0.8;
}

.close-btn:hover { opacity: 1; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Form Elements */
.form-group { padding: 0 24px; margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text-dark); }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,90,168,0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 0 24px;
    margin-bottom: 16px;
}

.form-row .form-group { padding: 0; margin-bottom: 0; }

/* Form Tabs */
.form-tabs {
    display: flex;
    padding: 0 24px;
    margin: 16px 0;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab-btn {
    padding: 12px 16px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-light);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text-medium); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content { display: none; padding-top: 16px; }
.tab-content.active { display: block; }

/* Timeline */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    margin-bottom: 16px;
}

.history-header h3 { font-size: 1rem; color: var(--text-dark); }

.timeline { padding: 0 24px; max-height: 300px; overflow-y: auto; }

.timeline-item {
    position: relative;
    padding-left: 24px;
    padding-bottom: 20px;
    border-left: 2px solid var(--border);
    margin-left: 8px;
}

.timeline-item:last-child { border-left-color: transparent; }

.timeline-item::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--white);
}

.timeline-date { font-weight: 600; color: var(--primary); margin-bottom: 8px; }

.timeline-content {
    background: var(--bg-light);
    padding: 12px;
    border-radius: var(--radius);
}

.timeline-content p { margin-bottom: 8px; font-size: 0.9rem; }
.timeline-content p:last-child { margin-bottom: 0; }
.timeline-content strong { color: var(--text-dark); }

/* Search Results */
.search-results {
    position: fixed;
    top: 80px;
    left: 300px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 200;
    display: none;
}

.search-results.active { display: block; }

.search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.search-result-item:hover { background: var(--bg-light); }
.search-result-item:last-child { border-bottom: none; }

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 16px 24px;
    background: var(--primary);
    color: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: #D97706; }

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-columns { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { width: 80px; }
    .sidebar .logo-text,
    .sidebar .nav-item span,
    .sidebar .sync-btn span,
    .sidebar .logout-btn span,
    .sidebar .connection-status span { display: none; }
    .connection-status { justify-content: center; }
    .main-content { margin-left: 80px; max-width: calc(100% - 80px); }
    .form-row { grid-template-columns: 1fr; }
}

/* ========== SPLASH SCREEN ========== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s, visibility 0.5s;
}

.splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.splash-content {
    text-align: center;
    color: var(--white);
}

.splash-logo {
    width: 120px;
    height: 140px;
    color: var(--white);
    animation: float 2s ease-in-out infinite;
    margin-bottom: 20px;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.splash-title {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 8px;
    animation: fadeIn 1s ease-out;
}

.splash-tagline {
    font-size: 1rem;
    opacity: 0.85;
    margin-bottom: 40px;
    animation: fadeIn 1s ease-out 0.3s both;
}

.splash-loader {
    width: 200px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    margin: 0 auto 20px;
    overflow: hidden;
}

.loader-bar {
    height: 100%;
    width: 0%;
    background: var(--white);
    border-radius: 2px;
    animation: loading 2s ease-in-out forwards;
}

@keyframes loading {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

.splash-status {
    font-size: 0.9rem;
    opacity: 0.7;
    animation: pulse 1.5s infinite;
}

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

/* ========== LOGIN SCREEN ========== */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 360px;
    padding: 32px;
    animation: slideUp 0.5s ease-out;
}

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

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo {
    width: 50px;
    height: 60px;
    color: var(--primary);
    margin-bottom: 12px;
}

.login-header h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.login-header p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.login-field {
    margin-bottom: 14px;
}

.login-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 0.9rem;
}

.login-field input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(30,90,168,0.1);
}

.login-remember {
    display: flex;
    align-items: center;
    margin-bottom: 18px;
}

.login-remember label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-medium);
    font-size: 0.9rem;
    cursor: pointer;
}

.login-remember input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

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

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

.login-error {
    color: var(--danger);
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    min-height: 20px;
}

.login-success {
    color: var(--success);
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    min-height: 20px;
}

.login-divider {
    display: flex;
    align-items: center;
    margin: 16px 0;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.login-divider span {
    padding: 0 16px;
    color: var(--text-light);
    font-size: 0.85rem;
}

.login-toggle-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-medium);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.login-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--secondary);
}

.login-toggle-btn strong {
    color: var(--primary);
}

.register-card {
    animation: slideUp 0.4s ease-out;
}

/* ========== LOGOUT BUTTON ========== */
.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius);
    color: rgba(255,255,255,0.8);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 12px;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
    color: var(--white);
}

.logout-btn svg {
    width: 18px;
    height: 18px;
}

/* ========== SETTINGS IMPROVEMENTS ========== */
.connection-status-card {
    background: var(--bg-light);
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    border-left: 4px solid var(--success);
}

.connection-status-card.disconnected {
    border-left-color: var(--danger);
}

.connection-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.connection-indicator .indicator-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--success);
    animation: glow 2s infinite;
}

.connection-indicator.offline .indicator-dot {
    background: var(--danger);
    animation: none;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(40, 167, 69, 0); }
}

.connection-indicator span {
    font-weight: 600;
    color: var(--success);
}

.connection-indicator.offline span {
    color: var(--danger);
}

.connection-details {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Language Selector */
.language-selector {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.language-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: var(--bg-light);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    min-width: 150px;
}

.language-option:hover {
    border-color: var(--primary);
    background: var(--secondary);
}

.language-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--secondary);
}

.language-option input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.language-flag {
    font-size: 1.5rem;
}

.language-option span:last-child {
    font-weight: 500;
    color: var(--text-dark);
}


/* ========== USER INFO IN SIDEBAR ========== */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(255,255,255,0.1);
    margin: 12px;
    border-radius: var(--radius);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--white);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    color: var(--white);
    font-weight: 600;
    font-size: 0.95rem;
}

.user-role {
    color: rgba(255,255,255,0.7);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========== ADMIN-ONLY ELEMENTS ========== */
.admin-only {
    display: none;
}

body.role-admin .admin-only {
    display: flex;
}

body.role-admin .stat-card.admin-only {
    display: flex;
}

/* Money stat icon */
.money-icon {
    background: #D1FAE5;
    color: #059669;
}

/* ========== FINANCES SECTION ========== */
.finance-period-selector {
    display: flex;
    gap: 8px;
}

.period-btn {
    padding: 10px 20px;
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-medium);
    transition: all 0.2s;
}

.period-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

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

.finance-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.finance-stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.finance-stat-card.income {
    border-left: 4px solid #059669;
}

.finance-stat-card.pending-payments {
    border-left: 4px solid #D97706;
}

.finance-stat-card.appointments-count {
    border-left: 4px solid var(--primary);
}

.finance-stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.finance-stat-icon svg {
    width: 28px;
    height: 28px;
}

.finance-stat-card.income .finance-stat-icon {
    background: #D1FAE5;
    color: #059669;
}

.finance-stat-card.pending-payments .finance-stat-icon {
    background: var(--warning-light);
    color: #D97706;
}

.finance-stat-card.appointments-count .finance-stat-icon {
    background: var(--secondary);
    color: var(--primary);
}

.finance-stat-info {
    display: flex;
    flex-direction: column;
}

.finance-stat-label {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.finance-stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-dark);
}

.finance-chart-container {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.finance-chart-container h3 {
    margin-bottom: 16px;
    color: var(--primary);
}

.finance-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.finance-card {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.finance-card h3 {
    margin-bottom: 16px;
    color: var(--primary);
    font-size: 1.1rem;
}

.payment-methods-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.payment-method-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-light);
    border-radius: var(--radius);
}

.payment-method-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.payment-method-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.payment-method-icon.efectivo {
    background: #D1FAE5;
    color: #059669;
}

.payment-method-icon.tarjeta {
    background: var(--secondary);
    color: var(--primary);
}

.payment-method-icon.transferencia {
    background: #DDD6FE;
    color: #7C3AED;
}

.payment-method-icon svg {
    width: 20px;
    height: 20px;
}

.payment-method-name {
    font-weight: 500;
    color: var(--text-dark);
}

.payment-method-amount {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-dark);
}

.pending-payments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.pending-payment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-light);
    border-radius: var(--radius);
    border-left: 3px solid #D97706;
}

.pending-payment-info {
    display: flex;
    flex-direction: column;
}

.pending-payment-name {
    font-weight: 500;
    color: var(--text-dark);
}

.pending-payment-date {
    font-size: 0.85rem;
    color: var(--text-light);
}

.pending-payment-amount {
    font-weight: 600;
    color: #D97706;
}

/* ========== USERS SECTION ========== */
.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.user-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-top: 4px solid var(--primary);
}

.user-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-card-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
}

.user-card-info h3 {
    margin-bottom: 4px;
    color: var(--text-dark);
}

.user-card-info p {
    font-size: 0.85rem;
    color: var(--text-light);
}

.user-card-role {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-card-role.admin {
    background: #FEE2E2;
    color: #DC2626;
}

.user-card-role.asistente {
    background: var(--secondary);
    color: var(--primary);
}

.user-card-footer {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.user-card-footer button {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
}

/* ========== WHATSAPP SECTION IMPROVEMENTS ========== */
.whatsapp-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.whatsapp-card {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.whatsapp-card h3 {
    margin-bottom: 8px;
    color: var(--primary);
}

.card-description {
    color: var(--text-light);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.quick-send-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-whatsapp-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #25D366;
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-whatsapp-action:hover {
    background: #128C7E;
}

.message-history {
    max-height: 300px;
    overflow-y: auto;
}

.message-history-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px;
    background: var(--bg-light);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.message-info {
    flex: 1;
}

.message-recipient {
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.message-preview {
    font-size: 0.85rem;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .finance-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .user-info .user-details { display: none; }
    .admin-only { display: none !important; }
}


/* ===== VERSION CONTROL STYLES ===== */
.version-info {
    background: var(--bg-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin: 16px 0;
}

.version-current {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.version-badge {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.version-label {
    font-size: 0.8rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.version-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Courier New', monospace;
}

.version-date {
    display: flex;
    flex-direction: column;
    text-align: right;
    font-size: 0.9rem;
    color: var(--text-medium);
}

.version-date span:last-child {
    font-weight: 600;
    color: var(--text-dark);
}

.version-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.version-status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.version-status-icon.checking {
    background: var(--secondary);
    color: var(--primary);
    animation: spin 1s linear infinite;
}

.version-status-icon.up-to-date {
    background: var(--success-light);
    color: var(--success);
}

.version-status-icon.update-available {
    background: var(--warning-light);
    color: #B45309;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.update-available {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    border: 1px solid #F59E0B;
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-top: 16px;
}

.update-info {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #92400E;
}

.update-info svg {
    flex-shrink: 0;
}

.update-info strong {
    display: block;
    margin-bottom: 4px;
}

.update-info p {
    font-size: 0.85rem;
    margin: 0;
    opacity: 0.9;
}

.btn-success {
    background: var(--success);
    color: var(--white);
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-1px);
}

/* Version History */
.version-history {
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.version-history summary {
    padding: 14px 16px;
    background: var(--bg-light);
    cursor: pointer;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.version-history summary:hover {
    background: var(--secondary);
}

.version-history summary::marker {
    color: var(--primary);
}

.version-history[open] summary {
    border-bottom: 1px solid var(--border);
}

.version-history-list {
    padding: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.version-history-item {
    display: grid;
    grid-template-columns: 80px 100px 1fr;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius);
    transition: background 0.2s;
    font-size: 0.9rem;
}

.version-history-item:hover {
    background: var(--bg-light);
}

.version-history-item.current {
    background: var(--secondary);
    border-left: 3px solid var(--primary);
}

.vh-version {
    font-weight: 600;
    color: var(--primary);
    font-family: 'Courier New', monospace;
}

.vh-date {
    color: var(--text-light);
}

.vh-notes {
    color: var(--text-medium);
}

/* Responsive for version section */
@media (max-width: 600px) {
    .version-current {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .version-date {
        text-align: left;
    }
    
    .update-available {
        flex-direction: column;
        align-items: stretch;
    }

    .version-history-item {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    display: none;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Tablet and below */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .main-content {
        margin-left: 220px;
    }
}

/* Mobile landscape */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    /* Mobile header */
    .mobile-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        background: var(--primary);
        color: white;
        position: sticky;
        top: 0;
        z-index: 50;
    }

    .menu-toggle {
        display: flex !important;
        background: none;
        border: none;
        color: white;
        font-size: 24px;
        cursor: pointer;
        padding: 8px;
    }

    .main-header {
        display: none !important;
    }

    /* Cards */
    .card {
        padding: 16px;
        margin-bottom: 12px;
    }

    .card-grid {
        grid-template-columns: 1fr !important;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 1.8rem;
    }

    /* Forms */
    .form-group {
        margin-bottom: 16px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Buttons */
    .btn {
        padding: 12px 20px;
        font-size: 15px;
    }

    .btn-block {
        width: 100%;
    }

    /* Modal */
    .modal-content {
        width: 95% !important;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal {
        padding: 10px;
    }

    /* Patient cards */
    .patient-card {
        padding: 16px;
    }

    .patient-card-header h3 {
        font-size: 1.1rem;
    }

    /* User cards */
    .user-card {
        padding: 16px;
    }

    /* Tables */
    .table-container {
        overflow-x: auto;
    }

    table {
        font-size: 14px;
    }

    th, td {
        padding: 10px 8px;
    }

    /* Dashboard sections */
    .dashboard-section {
        margin-bottom: 20px;
    }

    .section-header {
        font-size: 1.2rem;
        margin-bottom: 12px;
    }

    /* Calendar */
    .calendar-header {
        flex-direction: column;
        gap: 10px;
    }

    .calendar-nav {
        gap: 8px;
    }

    .calendar-grid {
        font-size: 14px;
    }

    /* Charts */
    .chart-container {
        padding: 16px;
        min-height: 250px;
    }

    /* Login screen */
    .login-container {
        padding: 20px;
    }

    .login-card {
        padding: 24px;
        margin: 10px;
    }

    .login-card h1 {
        font-size: 1.5rem;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    :root {
        font-size: 14px;
    }

    .sidebar {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .main-content {
        padding: 12px;
    }

    /* Nav items */
    .nav-item {
        padding: 12px 16px;
    }

    /* Search bar */
    .search-container {
        margin-bottom: 12px;
    }

    .search-input {
        padding: 10px 12px;
    }

    /* Page sections */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    /* Toast notifications */
    .toast {
        left: 10px;
        right: 10px;
        bottom: 80px;
    }

    /* Bottom nav for mobile */
    .bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 90;
        padding: 8px;
        justify-content: space-around;
    }

    .bottom-nav .nav-item {
        flex-direction: column;
        padding: 8px;
        font-size: 11px;
        gap: 4px;
    }

    .bottom-nav .nav-item svg {
        width: 20px;
        height: 20px;
    }

    /* Adjust main content for bottom nav */
    .main-content {
        padding-bottom: 80px;
    }

    /* Modal full screen on mobile */
    .modal-content {
        width: 100% !important;
        height: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    .modal {
        padding: 0;
    }

    /* Form tabs */
    .form-tabs {
        overflow-x: auto;
        white-space: nowrap;
    }

    .form-tab {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* Action buttons row */
    .modal-actions {
        flex-direction: column;
        gap: 10px;
    }

    .modal-actions .btn {
        width: 100%;
    }

    /* Patient/Appointment lists */
    .patients-list,
    .appointments-list {
        gap: 10px;
    }

    /* Finance cards */
    .finance-summary {
        grid-template-columns: 1fr;
    }

    /* Version info */
    .version-current {
        padding: 16px;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .logo h2 {
        font-size: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

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

/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        width: 200px;
    }

    .mobile-header {
        padding: 8px 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .mobile-header,
    .bottom-nav,
    .modal,
    .toast {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }
}

/* Dark mode specific element overrides */
:root.dark {
    /* Login screen */
    .login-screen {
        background: linear-gradient(135deg, var(--bg-main) 0%, #0a1520 100%);
    }

    .login-card {
        background: var(--card-bg);
        box-shadow: var(--shadow-lg);
    }

    .login-card h1 {
        color: var(--text-dark);
    }

    /* Splash screen */
    .splash-screen {
        background: var(--bg-main);
    }

    /* Settings section */
    .settings-card {
        background: var(--card-bg);
        border-color: var(--border);
    }

    .settings-description {
        color: var(--text-medium);
    }

    .settings-card h2 {
        color: var(--text-dark);
    }

    /* Connection status */
    .connection-status-card {
        background: var(--bg-light);
        border-color: var(--border);
    }

    /* Navigation items */
    .nav-item {
        color: var(--sidebar-text);
    }

    .nav-item.active {
        background: rgba(255, 255, 255, 0.15);
    }

    .nav-item:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    /* Stats sync */
    .sync-stats {
        background: var(--bg-light);
    }

    .sync-stat-label {
        color: var(--text-medium);
    }

    /* Language selector */
    .language-option {
        background: var(--bg-light);
        border-color: var(--border);
        color: var(--text-dark);
    }

    .language-option.active {
        background: var(--primary);
        color: white;
    }

    /* Version info */
    .version-current {
        background: var(--card-bg);
        border-color: var(--border);
    }

    .update-available {
        background: var(--accent-light);
        border-color: var(--accent);
    }

    /* Form elements */
    .form-label {
        color: var(--text-dark);
    }

    /* Calendar */
    .calendar-day {
        background: var(--card-bg);
        border-color: var(--border);
        color: var(--text-dark);
    }

    .calendar-day.today {
        background: var(--primary);
        color: white;
    }

    .calendar-day.has-appointments {
        border-color: var(--accent);
    }

    .calendar-controls {
        color: var(--text-dark);
    }

    /* Charts */
    .chart-container {
        background: var(--card-bg);
        border-color: var(--border);
    }

    /* Bottom nav dark mode */
    :root.dark .bottom-nav {
        background: var(--card-bg);
        border-top: 1px solid var(--border);
    }

    :root.dark .bottom-nav .nav-item {
        color: var(--text-medium);
    }

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

    /* Sidebar overlay dark */
    .sidebar-overlay {
        background: rgba(0, 0, 0, 0.7);
    }

    /* Search bar */
    .search-input {
        background: var(--input-bg);
        color: var(--text-dark);
        border-color: var(--border);
    }

    .search-input:focus {
        border-color: var(--primary);
    }

    /* Filter select */
    .filter-select {
        background: var(--input-bg);
        color: var(--text-dark);
        border-color: var(--border);
    }

    /* Tab active states */
    .form-tab.active {
        background: var(--primary);
        color: white;
    }

    /* Status badges */
    .status-badge {
        background: var(--bg-light);
        color: var(--text-medium);
    }

    /* Page header */
    .page-header h1 {
        color: var(--text-dark);
    }

    /* Toast dark mode */
    .toast {
        background: var(--card-bg);
        color: var(--text-dark);
        border: 1px solid var(--border);
    }

    .toast.success {
        border-color: var(--success);
    }

    .toast.error {
        border-color: var(--danger);
    }
}
