/* CSS Reset and Base Variables */
:root {
    /* Light theme */
    --primary: #007bff;
    --primary-hover: #0056b3;
    --danger: #dc3545;
    --danger-hover: #c82333;
    --success: #28a745;
    --warning: #ffc107;
    --info: #17a2b8;
    --surface-1: #ffffff;
    --surface-2: #f8f9fa;
    --surface-3: #e9ecef;
    --text-1: #212529;
    --text-2: #495057;
    --border: #dee2e6;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

    /* Layout */
    --header-height: 60px;
    --sidebar-width: 250px;
    --container-max: 1200px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --spacing: 20px;
}

/* Dark theme (driven by Bootstrap's data attribute) */
:root[data-bs-theme="dark"] {
    --primary: #0d6efd;
    --primary-hover: #0b5ed7;
    --surface-1: #1a1a1a;
    --surface-2: #2d2d2d;
    --surface-3: #404040;
    --text-1: #e4e4e4;
    --text-2: #ced4da;
    --border: #404040;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
    color: var(--text-1);
    background: var(--surface-1);
    line-height: 1.5;
}

/* Layout Patterns */
.centered-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing);
}

.card {
    background: var(--surface-2);
    padding: var(--spacing);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
}

.form-card {
    width: 100%;
    max-width: 400px;
}

.full-width-layout {
    padding: var(--spacing);
}

/* Navigation */
.top-nav {
    background: var(--surface-2);
    padding: calc(var(--spacing) / 2) var(--spacing);
    border-bottom: 1px solid var(--border);
}

.nav-container {
    max-width: var(--container-max);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-2);
}

.form-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-1);
    color: var(--text-1);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.2s;
}

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

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

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

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

/* Bootstrap icon helper */
.bi {
    vertical-align: -.125em;
    fill: currentColor;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin: var(--spacing) 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}

.table th {
    background: var(--surface-2);
    font-weight: 600;
}

.table tbody tr:nth-child(even) {
    background: var(--surface-2);
}

/* DataTables specific */
.dataTables_wrapper {
    margin: var(--spacing) 0;
}

.dataTables_filter,
.dataTables_length {
    margin-bottom: var(--spacing);
}

/* Messages */
.message {
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

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

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

/* Utilities */
.text-center { text-align: center; }
.w-100 { width: 100%; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    padding: 0.5rem;
    border-radius: 50%;
    border: none;
    background: var(--surface-2);
    color: var(--text-1);
    cursor: pointer;
    box-shadow: var(--shadow);
}

/* --- Sidebar (migrated from sidebars.css) --- */
body { min-height: 100vh; min-height: -webkit-fill-available; }
html { height: -webkit-fill-available; }
main { height: 100vh; height: -webkit-fill-available; max-height: 100vh; overflow-x: auto; overflow-y: hidden; }
.dropdown-toggle { outline: 0; }
.btn-toggle { padding: .25rem .5rem; font-weight: 600; color: var(--bs-emphasis-color); background-color: transparent; }
.btn-toggle:hover, .btn-toggle:focus { color: rgba(var(--bs-emphasis-color-rgb), .85); background-color: var(--bs-tertiary-bg); }
.btn-toggle::before { width: 1.25em; line-height: 0; content: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='rgba%280,0,0,.5%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M5 14l6-6-6-6'/%3e%3c/svg%3e"); transition: transform .35s ease; transform-origin: .5em 50%; }
[data-bs-theme="dark"] .btn-toggle::before { content: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='rgba%28255,255,255,.5%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M5 14l6-6-6-6'/%3e%3c/svg%3e"); }
.btn-toggle[aria-expanded="true"] { color: rgba(var(--bs-emphasis-color-rgb), .85); }
.btn-toggle[aria-expanded="true"]::before { transform: rotate(90deg); }
.btn-toggle-nav a { padding: .1875rem .5rem; margin-top: .125rem; margin-left: 1.25rem; }
.btn-toggle-nav a:hover, .btn-toggle-nav a:focus { background-color: var(--bs-tertiary-bg); }
.scrollarea { overflow-y: auto; }

/* Responsive */
@media (max-width: 768px) {
    :root {
        --spacing: 15px;
    }
    
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
}
