﻿html[data-theme="cool"] {
    --primary-color: #0066ff;
    --primary-hover: #0052cc;
    --secondary-color: #0052cc;
    --primary-soft: rgba(0, 102, 255, 0.10);
    --canvas: #F4F7FB;
    --surface: #FFFFFF;
    --surface-elevated: #FFFFFF;
    --text-primary: #0F172A;
    --text-secondary: #4B5563;
    --text-muted: #6B7280;
    --border-color: #E2E8F0;
    --ring-color: #0066ff;
    --sidebar-bg: #F4F7FB;
    --sidebar-hover: #FFFFFF;
    --header-bg: #FFFFFF;
    --dark-color: #0F172A;
    --bs-body-bg: #F4F7FB;
    --bs-body-color: #0F172A;
    --card-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    --transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    --sidebar-width: 260px;
    --header-height: 65px;
}

:root,
html[data-theme="warm"] {
    --primary-color: #10B981;
    --primary-hover: #059669;
    --secondary-color: #059669;
    --primary-soft: rgba(16, 185, 129, 0.12);
    --canvas: #F7F4EF;
    --surface: #FFFFFF;
    --surface-elevated: #FFFCF8;
    --text-primary: #1C1917;
    --text-secondary: #57534E;
    --text-muted: #78716C;
    --border-color: #E7E5E4;
    --ring-color: #10B981;
    --sidebar-bg: #F7F4EF;
    --sidebar-hover: #FFFFFF;
    --header-bg: #FFFCF8;
    --dark-color: #1C1917;
    --bs-body-bg: #F7F4EF;
    --bs-body-color: #1C1917;
    --card-shadow: 0 8px 24px rgba(28, 25, 23, 0.06);
    --sidebar-width: 260px;
    --header-height: 65px;
}

html[data-theme="dark"] {
    --primary-color: #3B82F6;
    --primary-hover: #2563EB;
    --secondary-color: #2563EB;
    --primary-soft: rgba(59, 130, 246, 0.18);
    --canvas: #0F172A;
    --surface: #1E293B;
    --surface-elevated: #334155;
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --border-color: #334155;
    --ring-color: #3B82F6;
    --sidebar-bg: #0F172A;
    --sidebar-hover: #1E293B;
    --header-bg: #1E293B;
    --dark-color: #F8FAFC;
    --bs-body-bg: #0F172A;
    --bs-body-color: #F8FAFC;
    --card-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

html {
    color-scheme: light;
}

html[data-theme="dark"] {
    color-scheme: dark;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--canvas);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Top Header Bar */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: var(--header-height);
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: none;
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-brand {
    display: inline-flex;
    align-items: center;
    line-height: 0;
    text-decoration: none;
}

    .logo-brand:hover {
        text-decoration: none;
    }

/* Theme switcher */
.theme-switcher {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--canvas);
    gap: 1px;
}

.theme-switcher-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
}

    .theme-switcher-btn:hover {
        color: var(--text-primary);
        background: var(--surface);
    }

    .theme-switcher-btn.is-on {
        background: var(--surface);
        color: var(--primary-color);
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
    }

    .theme-switcher-btn.is-on[data-theme-value="cool"] { color: #0066ff; }
    .theme-switcher-btn.is-on[data-theme-value="warm"] { color: #10B981; }
    .theme-switcher-btn.is-on[data-theme-value="dark"] { color: #93C5FD; }

    .theme-switcher-btn:focus-visible {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }

html[data-theme="dark"] .theme-switcher-btn.is-on {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 20px;
}

.portal-switch-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 20px;
    background: var(--primary-soft);
    color: var(--primary-color);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}

    .portal-switch-btn:hover {
        background: var(--primary-color);
        color: white;
        text-decoration: none;
    }

.clinic-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
}

    .clinic-switch i {
        color: var(--primary-color);
    }

.clinic-switch-name {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clinic-switch-empty {
    color: var(--text-muted);
    font-weight: 500;
}

.clinic-switch-change {
    color: var(--primary-color);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

    .clinic-switch-change:hover {
        color: #fff;
        background: var(--primary-color);
        border-color: var(--primary-color);
        text-decoration: none;
    }

.notification-bell {
    position: relative;
    cursor: pointer;
}

    .notification-bell i {
        color: var(--text-secondary);
        font-size: 20px;
        transition: var(--transition);
    }

    .notification-bell:hover i {
        color: var(--primary-color);
        transform: rotate(15deg);
    }

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #EF4444;
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px 6px 6px;
    background: var(--canvas);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

    .user-profile:hover {
        background: var(--primary-soft);
        border-color: var(--primary-color);
    }

.user-avatar {
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
}

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

.user-name {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
}

.user-role {
    color: var(--text-secondary);
    font-size: 12px;
}

.dropdown-arrow {
    color: var(--text-secondary);
    margin-left: 8px;
    transition: var(--transition);
}

.user-profile:hover .dropdown-arrow {
    transform: rotate(180deg);
}

/* User Dropdown Menu */
.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: var(--surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
    z-index: 1040;
}

.user-profile:hover .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
    font-size: 14px;
    width: 100%;
    background: transparent;
    border: 0;
    text-align: left;
    cursor: pointer;
}

    .dropdown-item:hover {
        background: var(--primary-color);
        color: white;
    }

    .dropdown-item:first-child {
        border-radius: 12px 12px 0 0;
    }

    .dropdown-item:last-child {
        border-radius: 0 0 12px 12px;
        border-top: 1px solid var(--border-color);
    }

    .dropdown-item i {
        width: 20px;
        text-align: center;
    }

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--transition);
    box-shadow: none;
    border-right: 1px solid var(--border-color);
    z-index: 1020;
}

    .sidebar::-webkit-scrollbar {
        width: 6px;
    }

    .sidebar::-webkit-scrollbar-track {
        background: var(--sidebar-bg);
    }

    .sidebar::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 3px;
    }

        .sidebar::-webkit-scrollbar-thumb:hover {
            background: var(--text-secondary);
        }

.sidebar-menu {
    padding: 20px 0;
}

.menu-section {
    margin-bottom: 25px;
}

.menu-title {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 20px;
    margin-bottom: 10px;
}

.menu-item {
    display: flex;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    position: relative;
    align-items: center;
    gap: 15px;
    margin: 2px 10px;
    border-radius: 12px;
}

    .menu-item i {
        width: 20px;
        text-align: center;
        font-size: 18px;
    }

    .menu-item:hover {
        background: var(--surface);
        color: var(--text-primary);
        text-decoration: none;
        transform: none;
        box-shadow: var(--card-shadow);
    }

    .menu-item:focus-visible {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }

    .menu-item.active,
    .menu-item.active:hover,
    .menu-item.active:focus {
        background: var(--surface);
        color: var(--primary-color);
        text-decoration: none;
        transform: none;
        box-shadow: inset 0 0 0 1.5px var(--primary-color), var(--card-shadow);
    }

        .menu-item.active i,
        .menu-item.active:hover i,
        .menu-item.active:focus i {
            color: var(--primary-color);
        }

        .menu-item.active::before {
            display: none;
        }

.menu-badge {
    margin-left: auto;
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    padding-top: var(--header-height);
    min-height: 100vh;
    background: var(--canvas);
    transition: var(--transition);
}

.content-wrapper {
    padding: 30px;
    max-width: 100%;
}

/* Page Header */
.page-header {
    background: var(--surface);
    border-radius: 16px;
    padding: 25px 30px;
    margin-bottom: 30px;
    box-shadow: var(--card-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 5px 0 0 0;
}

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

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

/* Cards */
.dashboard-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 25px;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    border: 1px solid transparent;
}

    .dashboard-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
        border-color: var(--primary-color);
    }

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: var(--transition);
}

    .stat-card:hover {
        transform: scale(1.02);
    }

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

    .stat-icon.green {
        background: linear-gradient(135deg, #10B981, #059669);
        color: white;
    }

    .stat-icon.blue {
        background: linear-gradient(135deg, #3B82F6, #2563EB);
        color: white;
    }

    .stat-icon.purple {
        background: linear-gradient(135deg, #8B5CF6, #7C3AED);
        color: white;
    }

    .stat-icon.orange {
        background: linear-gradient(135deg, #F59E0B, #D97706);
        color: white;
    }

.stat-details h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.stat-details p {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 5px 0 0 0;
}

/* Toggle Button */
.sidebar-toggle {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: none;
}

    .sidebar-toggle:hover {
        background: var(--primary-hover);
    }

    .sidebar-toggle:focus-visible {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }

    .sidebar-toggle i {
        font-size: 18px;
    }

/* Overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1010;
    opacity: 0;
    transition: opacity 0.3s ease;
}

    .sidebar-overlay.active {
        opacity: 1;
    }

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .sidebar-toggle {
        display: block;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .content-wrapper {
        padding: 20px 15px;
    }
}

@media (max-width: 768px) {
    .top-header {
        padding: 0 15px;
    }

    .logo-brand .xh-logo-header .xh-logo-img {
        height: 34px;
        max-width: 170px;
    }

    .user-info {
        display: none;
    }

    .portal-switch-label {
        display: none;
    }

    .user-menu {
        gap: 10px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 20px;
    }

    .page-title {
        font-size: 20px;
    }

    .content-wrapper {
        padding: 15px 10px;
    }

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

@media (max-width: 480px) {
    .logo-brand .xh-logo-header .xh-logo-img {
        height: 28px;
        max-width: 148px;
    }

    .page-title {
        font-size: 18px;
    }

    .breadcrumb {
        font-size: 12px;
    }

    .clinic-switch-name,
    .clinic-switch-empty {
        display: none;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animated {
    animation: fadeIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

.sidebar.active {
    animation: slideIn 0.3s ease-out;
}
