* {
    box-sizing: border-box;
}

:root {
    /* Light Theme (Default) */
    --primary-color: #6200ee;
    --primary-variant: #3700b3;
    --secondary-color: #03dac6;
    --background-color: #f5f5f5;
    --surface-color: #ffffff;
    --error-color: #b00020;
    --on-primary: #ffffff;
    --on-surface: #000000;
    --on-surface-variant: #666666;
    --border-color: #eeeeee;
    --shadow-1: 0 2px 1px -1px rgba(0, 0, 0, 0.2), 0 1px 1px 0 rgba(0, 0, 0, 0.14), 0 1px 3px 0 rgba(0, 0, 0, 0.12);
    --shadow-2: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
    --table-header-bg: #f8f9fa;
    --table-row-border: #f0f0f0;
    --input-bg: #f9f9f9;
    --input-border: #ccc;
}

/* Dark Theme Variables */
body.dark-mode,
html.dark-mode body {
    --primary-color: #bb86fc;
    /* Lighter purple for dark mode */
    --primary-variant: #9955e8;
    --secondary-color: #03dac6;
    --background-color: #121212;
    --surface-color: #1e1e1e;
    --error-color: #cf6679;
    --on-primary: #000000;
    --on-surface: #ffffff;
    --on-surface-variant: #b0b0b0;
    --border-color: #333333;
    --shadow-1: 0 2px 1px -1px rgba(0, 0, 0, 0.4), 0 1px 1px 0 rgba(0, 0, 0, 0.24), 0 1px 3px 0 rgba(0, 0, 0, 0.22);
    --shadow-2: 0 3px 1px -2px rgba(0, 0, 0, 0.4), 0 2px 2px 0 rgba(0, 0, 0, 0.24), 0 1px 5px 0 rgba(0, 0, 0, 0.22);
    --table-header-bg: #2c2c2c;
    --table-row-border: #333333;
    --input-bg: #2c2c2c;
    --input-border: #444;
}

body {
    margin: 0;
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    color: var(--on-surface);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 16px;
    color: var(--on-surface);
}

a {
    transition: color 0.2s;
}

/* Material Card */
.card {
    background-color: var(--surface-color);
    border-radius: 4px;
    box-shadow: var(--shadow-1);
    padding: 16px;
    margin: 16px;
    color: var(--on-surface);
    transition: background-color 0.3s;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
    position: relative;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--on-surface-variant);
    font-size: 0.9rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    padding: 12px 12px;
    box-sizing: border-box;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--on-surface);
    transition: border-color 0.3s, background-color 0.3s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--surface-color);
    /* Or keep input-bg slightly lighter/darker */
    border-width: 2px;
    padding: 11px 11px;
}

/* Buttons */
.btn {
    background-color: var(--primary-color);
    color: var(--on-primary);
    border: none;
    padding: 10px 16px;
    border-radius: 4px;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1.25px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s, opacity 0.2s;
    box-shadow: var(--shadow-1);
}

.btn:hover {
    background-color: var(--primary-variant);
    box-shadow: var(--shadow-2);
    /* In dark mode, simply dimming or shifting brightness works better than explicit colors sometimes */
    opacity: 0.9;
}

/* Secondary Button Variant */
.btn-secondary {
    background-color: var(--input-border);
    /* Fallback */
    background-color: #e0e0e0;
    color: #333;
}

body.dark-mode .btn-secondary {
    background-color: #333;
    color: #eee;
}

.btn-text {
    background: none;
    color: var(--primary-color);
    box-shadow: none;
}

.btn-text:hover {
    background-color: rgba(98, 0, 238, 0.04);
    box-shadow: none;
}

body.dark-mode .btn-text:hover {
    background-color: rgba(187, 134, 252, 0.08);
    /* Adjusted for light purple */
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-error {
    color: var(--error-color);
}

.mt-2 {
    margin-top: 16px;
}

/* Theming Utility Classes (to replace inline styles) */
.bg-surface {
    background-color: var(--surface-color) !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.text-muted {
    color: var(--on-surface-variant) !important;
}

.border-bottom-light {
    border-bottom: 1px solid var(--border-color) !important;
}

/* Sidebar Specifics */
.sidebar {
    background-color: var(--surface-color) !important;
    transition: background-color 0.3s;
}

.sidebar-link {
    color: var(--on-surface-variant) !important;
}

.sidebar-link.active {
    color: var(--primary-color) !important;
    background-color: rgba(98, 0, 238, 0.05);
    /* Subtle highlight */
}

body.dark-mode .sidebar-link.active {
    background-color: rgba(187, 134, 252, 0.1);
}

/* Auth Container */
.auth-container {
    margin: 60px auto;
    padding: 24px;
}

/* Global Layout Fix */
@media (min-width: 769px) {
    .main-content {
        margin-left: 270px !important;
        padding: 40px !important;
        width: auto !important;
        /* Let block layout handle width */
        max-width: 100%;
        overflow-x: hidden;
    }
}