/* =============================================================================
   GARAGEMWEB - CLEAN MODERN DESIGN SYSTEM
   Simple • Elegant • Professional
   ============================================================================= */

:root {
    /* --- COLOR PALETTE: NEUTRAL & BLUE --- */
    --primary: #2563eb;
    /* Blue 600 */
    --primary-hover: #1d4ed8;
    /* Blue 700 */
    --primary-light: #eff6ff;
    /* Blue 50 */

    --success: #10b981;
    /* Emerald 500 */
    --danger: #ef4444;
    /* Red 500 */
    --warning: #f59e0b;
    /* Amber 500 */
    --info: #3b82f6;
    /* Blue 500 */

    /* Light Theme Defaults */
    --bg-body: #f3f4f6;
    /* Gray 100 */
    --bg-card: #ffffff;
    /* White */
    --bg-sidebar: #ffffff;
    /* White */

    --text-main: #111827;
    /* Gray 900 */
    --text-sec: #4b5563;
    /* Gray 600 */
    --text-muted: #9ca3af;
    /* Gray 400 */

    --border: #e5e7eb;
    /* Gray 200 */
    --border-light: #f3f4f6;
    /* Gray 100 */

    /* Compability Variables (Legacy) */
    --primary-blue: var(--primary);
    --primary-color: var(--primary);
    --text-primary: var(--text-main);
    --text-secondary: var(--text-sec);
    --bg-main: var(--bg-body);

    /* Dimensions & Spacing */
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 70px;
    --header-height: 64px;
    --radius: 0.5rem;
    --radius-sm: 0.375rem;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);

    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

/* --- DARK MODE (Bootstrap Compatible) --- */
[data-bs-theme="dark"] {
    --bg-body: #111827;
    /* Gray 900 */
    --bg-card: #1f2937;
    /* Gray 800 */
    --bg-sidebar: #1f2937;
    /* Gray 800 */

    --text-main: #f9fafb;
    /* Gray 50 */
    --text-sec: #d1d5db;
    /* Gray 300 */
    --text-muted: #6b7280;
    /* Gray 500 */

    --border: #374151;
    /* Gray 700 */
    --border-light: #374151;

    --primary-light: rgba(37, 99, 235, 0.15);
}

/* =============================================================================
   RESET & BASE
   ============================================================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s, color 0.3s;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

button,
input,
select {
    font-family: inherit;
}

/* =============================================================================
   LAYOUT STRUCTURE
   ============================================================================= */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    transition: margin-left 0.3s ease;
}

/* =============================================================================
   SIDEBAR (CLEAN)
   ============================================================================= */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
}

/* Header */
.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border);
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    overflow: hidden;
    white-space: nowrap;
}

.brand-icon {
    font-size: 1.5rem;
    min-width: 24px;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    color: var(--text-sec);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.nav-link i {
    font-size: 1.1rem;
    min-width: 24px;
    margin-right: 0.75rem;
    color: var(--text-muted);
    transition: color 0.2s;
    text-align: center;
}

.nav-link:hover {
    background-color: var(--bg-body);
    color: var(--text-main);
}

.nav-link:hover i {
    color: var(--primary);
}

.nav-link.active {
    background-color: var(--primary-light);
    color: var(--primary);
}

.nav-link.active i {
    color: var(--primary);
}

.nav-arrow {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.nav-link[aria-expanded="true"] .nav-arrow {
    transform: rotate(90deg);
}

/* Submenu */
.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-left: 2.75rem;
    /* Indent under icon */
}

.submenu.open {
    max-height: 500px;
}

.submenu-link {
    display: block;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: var(--text-sec);
    transition: color 0.2s;
}

.submenu-link:hover {
    color: var(--primary);
}

.submenu-link.active {
    color: var(--primary);
    font-weight: 600;
}

/* Footer / User Profile */
.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 1rem;
    background-color: var(--bg-sidebar);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.2s;
}

.user-profile:hover {
    background-color: var(--bg-body);
}

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

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Actions Row (Toggle Theme + Logout) */
.user-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-sec);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.action-btn:hover {
    background-color: var(--bg-body);
    color: var(--text-main);
}

.action-btn.logout:hover {
    border-color: var(--danger);
    color: var(--danger);
    background-color: rgba(239, 68, 68, 0.05);
    /* very light red */
}

/* =============================================================================
   COLLAPSED STATE
   ============================================================================= */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed~.main-content {
    margin-left: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .brand-wrapper span,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-arrow,
.sidebar.collapsed .user-info,
.sidebar.collapsed .user-actions {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .nav-link i {
    margin: 0;
}

.sidebar.collapsed .user-profile {
    justify-content: center;
    padding: 0.5rem 0;
}

/* =============================================================================
   GENERIC COMPONENTS (Cards, Forms, Tables)
   ============================================================================= */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-card);
}

.table th {
    background-color: var(--bg-body);
    color: var(--text-sec);
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
    font-size: 0.9rem;
}

.table tr:hover {
    background-color: var(--bg-body);
}

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

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-sec);
}

.form-control,
.form-select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

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

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

.btn-secondary {
    background: white;
    border-color: var(--border);
    color: var(--text-sec);
}

.btn-secondary:hover {
    background: var(--bg-body);
}

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

/* Utilities */
.text-center {
    text-align: center;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.flex-column {
    flex-direction: column;
}

.d-none {
    display: none !important;
}

@media (max-width: 768px) {
    .sidebar {
        width: 0;
        overflow: hidden;
    }

    .sidebar.mobile-open {
        width: 250px;
    }

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

/* =============================================================================
   DASHBOARD SPECIFIC STYLES
   ============================================================================= */

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.page-subtitle {
    color: var(--text-sec);
    font-size: 1rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* Icon Colors */
.stat-icon.primary {
    background-color: var(--primary-light);
    color: var(--primary);
}

.stat-icon.success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-icon.warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-icon.danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.stat-info h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.stat-info p {
    color: var(--text-sec);
    font-size: 0.875rem;
    margin: 0;
}

/* Quick Actions & Recent Cards Overrides */
.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: transparent;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.card-body {
    padding: 1.5rem;
}

/* Responsive Adjustments */
@media (max-width: 640px) {
    .page-header {
        flex-direction: column;
    }

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

    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}