:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 0.5rem;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

:root[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --secondary: #94a3b8;
    --background: #0f172a;
    --surface: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.5);

    /* FullCalendar Dark Mode Overrides */
    --fc-page-bg-color: var(--background);
    --fc-neutral-bg-color: var(--surface);
    --fc-neutral-text-color: var(--text-main);
    --fc-border-color: var(--border);
    --fc-button-text-color: var(--text-main);
    --fc-button-bg-color: var(--surface);
    --fc-button-border-color: var(--border);
    --fc-button-hover-bg-color: var(--border);
    --fc-button-hover-border-color: var(--primary);
    --fc-button-active-bg-color: var(--border);
    --fc-button-active-border-color: var(--primary);
    --fc-today-bg-color: rgba(59, 130, 246, 0.15);
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Auth Pages */
.login-card {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    margin: auto; 
}

/* Dashboard Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    margin-left: 260px; /* Width of sidebar */
    padding: 2rem;
    background-color: var(--background);
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    background-color: #eff6ff;
    color: var(--primary);
}

.nav-icon {
    font-size: 1.25rem;
}

/* Submenu Styles */
.nav-submenu {
    display: none;
    flex-direction: column;
    padding-left: 2.75rem;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.nav-submenu.open {
    display: flex;
}

.nav-submenu-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.nav-submenu-link:hover, .nav-submenu-link.active {
    background-color: #eff6ff;
    color: var(--primary);
}

.nav-link-dropdown {
    justify-content: space-between;
}

.nav-caret {
    transition: transform 0.2s ease;
    font-size: 0.75rem;
}

.nav-link.active .nav-caret, .nav-submenu.open ~ .nav-caret {
    transform: rotate(90deg);
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
}

.stat-info .label {
    display: block;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.stat-info .value {
    display: block;
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 0.25rem;
}

.stat-icon {
    font-size: 2rem;
    opacity: 0.8; 
}

/* Main Grid Access */
.main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.dashboard-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.dashboard-card h3 {
    margin-top: 1rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main);
}

.dashboard-card p {
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.card-icon {
    font-size: 2rem;
    background: #f1f5f9;
    padding: 0.5rem;
    border-radius: 0.5rem;
    display: inline-block;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s;
    border: none;
    font-size: 0.9rem;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* Responsive & Mobile Adaptation */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.open {
    display: block;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin-bottom: 1rem;
    border-radius: var(--radius);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.5rem;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        z-index: 1000;
        width: 280px;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
    .mobile-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius);
        background: var(--surface);
        border: 1px solid var(--border);
    }
    
    .header-project, .page-header, .header-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .new-btn, .new-patient-btn, .btn-primary {
        width: 100%;
        text-align: center;
    }
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.5rem;
    border-radius: 50%;
    color: var(--text-muted);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}
.theme-toggle-btn:hover {
    background-color: var(--border);
    color: var(--text-main);
}
