/* =============================================
   🎨 MASTER COLOR SYSTEM
   ============================================= */
:root {
    --theme-primary: #198754;
    --theme-primary-rgb: 25, 135, 84;

    /* Layout */
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --bottombar-height: 46px;

    /* Auto-generated variations */
    --theme-light: color-mix(in srgb, var(--theme-primary) 40%, white);
    --theme-lighter: color-mix(in srgb, var(--theme-primary) 15%, white);
    --theme-dark: color-mix(in srgb, var(--theme-primary) 85%, black);
    --theme-darker: color-mix(in srgb, var(--theme-primary) 70%, black);
    --theme-hover: color-mix(in srgb, var(--theme-primary) 10%, transparent);
    --theme-shadow: rgba(var(--theme-primary-rgb), 0.25);
    --theme-bg-subtle: color-mix(in srgb, var(--theme-primary) 12%, white);
    --theme-bg-dark: color-mix(in srgb, var(--theme-primary) 25%, #111);
}

/* =============================================
   ☀️ LIGHT THEME
   ============================================= */
[data-bs-theme="light"] {
    --bg-body: color-mix(in srgb, var(--theme-primary) 5%, #f9faf8);
    --bg-sidebar: color-mix(in srgb, var(--theme-primary) 8%, #f4f7f0);
    --bg-card: #ffffff;
    --bg-topbar: #ffffff;
    --bg-bottombar: rgba(255, 255, 255, 0.95);
    --text-primary: color-mix(in srgb, var(--theme-primary) 60%, #111);
    --text-secondary: color-mix(in srgb, var(--theme-primary) 40%, #444);
    --border-color: color-mix(in srgb, var(--theme-primary) 25%, #ddd);
    --shadow: 0 2px 8px rgba(var(--theme-primary-rgb), 0.08);
    --nav-hover: var(--theme-hover);
    --sidebar-header-bg: #ffffff;
    --sidebar-footer-bg: #ffffff;
    --input-bg: #ffffff;
    --input-border: var(--border-color);
    --icon-color: var(--text-secondary);
    --avatar-bg: var(--theme-primary);
    --badge-bg: var(--theme-primary);
    --progress-bg: #e9ecef;
    --modal-bg: #ffffff;
    --toast-bg: #ffffff;
    --dropdown-bg: #ffffff;
    --btn-hover-darken: var(--theme-dark);
}

/* =============================================
   🌙 DARK THEME
   ============================================= */
[data-bs-theme="dark"] {
    --bg-body: color-mix(in srgb, var(--theme-primary) 8%, #1a1f1a);
    --bg-sidebar: color-mix(in srgb, var(--theme-primary) 10%, #1e2a1e);
    --bg-card: color-mix(in srgb, var(--theme-primary) 8%, #243024);
    --bg-topbar: var(--bg-sidebar);
    --bg-bottombar: rgba(30, 42, 30, 0.95);
    --text-primary: color-mix(in srgb, var(--theme-primary) 20%, #e8f0e0);
    --text-secondary: color-mix(in srgb, var(--theme-primary) 25%, #a8b8a0);
    --border-color: color-mix(in srgb, var(--theme-primary) 30%, #3a4a38);
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    --nav-hover: rgba(var(--theme-primary-rgb), 0.15);
    --sidebar-header-bg: var(--bg-sidebar);
    --sidebar-footer-bg: var(--bg-sidebar);
    --input-bg: color-mix(in srgb, var(--theme-primary) 10%, #222);
    --input-border: var(--border-color);
    --icon-color: var(--theme-light);
    --avatar-bg: var(--theme-primary);
    --badge-bg: var(--theme-primary);
    --progress-bg: color-mix(in srgb, var(--theme-primary) 15%, #333);
    --modal-bg: var(--bg-card);
    --toast-bg: var(--bg-card);
    --dropdown-bg: var(--bg-card);
    --btn-hover-darken: var(--theme-darker);
}

/* =============================================
   🏗️ BASE LAYOUT
   ============================================= */
body {
    background-color: var(--bg-body);
    overflow: auto;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    color: var(--text-primary);
    transition: background-color 0.3s, color 0.3s;
}

/* =============================================
   📱 SIDEBAR
   ============================================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    transition: transform 0.3s ease, background-color 0.3s;
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.2rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background-color: var(--sidebar-header-bg);
    transition: background-color 0.3s;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 0 1rem 0;
    scrollbar-width: thin;
    scrollbar-color: var(--theme-light) transparent;
    border-right: 1px solid var(--border-color);
}

.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background-color: var(--theme-light);
    border-radius: 20px;
}

.sidebar .nav-link {
    color: var(--text-secondary);
    padding: 0.75rem 1.2rem;
    margin: 0.2rem 0.8rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.sidebar .nav-link i {
    font-size: 1.25rem;
    width: 1.5rem;
    text-align: center;
    color: var(--theme-primary);
    transition: color 0.2s;
}

.sidebar .nav-link:hover {
    background-color: var(--nav-hover);
    color: var(--text-primary);
}

.sidebar .nav-link.active {
    box-shadow: 0 4px 10px var(--theme-shadow);
    border: solid 1px var(--theme-primary);
}

.sidebar .nav-link.active i {
    color: white;
}

.sidebar-footer {
    font-family: sans-serif;
    padding: 0.2rem 1.2rem;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
    background-color: var(--theme-light);
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: background-color 0.3s;
}

/* =============================================
   📄 MAIN WRAPPER
   ============================================= */
.main-wrapper {
    margin-left: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-body);
    transition: background-color 0.3s;
}

/* =============================================
   🔝 TOP NAVBAR
   ============================================= */
.top-navbar {
    height: var(--topbar-height);
    background-color: var(--bg-topbar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    flex-shrink: 0;
    position: sticky;
    z-index: 1025;
    box-shadow: 0 1px 4px rgba(0, 20, 0, 0.04);
    transition: background-color 0.3s;
}

/* =============================================
   📝 MAIN CONTENT
   ============================================= */
.main-content {
    flex: 1;
    overflow-y: auto;
    background-color: var(--bg-body);
    scrollbar-width: thin;
    scrollbar-color: var(--theme-light) transparent;
    padding-bottom: calc(var(--bottombar-height) + 1.5rem);
    transition: background-color 0.3s;
    padding: 0.5rem;
}

.main-content::-webkit-scrollbar {
    width: 6px;
}

.main-content::-webkit-scrollbar-track {
    background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
    background-color: var(--theme-light);
    border-radius: 10px;
}

/* =============================================
   ⬇️ BOTTOM ACTION BAR
   ============================================= */
.bottom-action-bar {
    width: 77vw;
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 11px;
    height: var(--bottombar-height);
    background-color: var(--bg-bottombar);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1025;
    box-shadow: 0 -4px 12px rgba(0, 20, 0, 0.06);
    transition: background-color 0.3s;
}

/* =============================================
   🎯 COMPONENT THEMING
   ============================================= */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    transition: background-color 0.3s, border-color 0.3s;
}

.btn-theme,
.btn-primary {
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
    color: white;
}

.btn-theme:hover,
.btn-primary:hover {
    background-color: var(--btn-hover-darken);
    border-color: var(--btn-hover-darken);
}

.btn-outline-theme,
.btn-outline-primary {
    color: var(--theme-primary);
    border-color: var(--theme-primary);
}

.btn-outline-theme:hover,
.btn-outline-primary:hover {
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
    color: white;
}

.badge-theme {
    background-color: var(--badge-bg) !important;
    color: white;
}

.progress {
    background-color: var(--progress-bg);
}

.progress-bar {
    background-color: var(--theme-primary);
}

.form-control,
.input-group-text,
.form-select {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-primary);
    transition: background-color 0.3s, border-color 0.3s;
}

.form-control::placeholder {
    color: var(--text-secondary);
}

.form-check-input:checked {
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
}

.form-check-input:focus {
    border-color: var(--theme-light);
    box-shadow: 0 0 0 0.2rem var(--theme-shadow);
}

.modal-content {
    background-color: var(--modal-bg);
    border-color: var(--border-color);
}

.toast {
    background-color: var(--toast-bg);
    border-color: var(--border-color);
}

.dropdown-menu {
    background-color: var(--dropdown-bg);
    border-color: var(--border-color);
}

.dropdown-item {
    color: var(--text-primary);
}

.dropdown-item:hover {
    background-color: var(--nav-hover);
    color: var(--text-primary);
}

.list-group-item {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.alert-theme {
    background-color: var(--theme-bg-subtle);
    border-color: var(--theme-light);
    color: var(--text-primary);
}

.theme-icon {
    color: var(--icon-color);
    cursor: pointer;
    transition: color 0.2s;
}

.theme-icon:hover {
    color: var(--theme-primary);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--avatar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
}

/* =============================================
   🎨 UTILITY CLASSES
   ============================================= */
.text-theme {
    color: var(--theme-primary) !important;
}

.bg-theme-subtle {
    background-color: var(--theme-bg-subtle) !important;
}

.border-theme {
    border-color: var(--theme-primary) !important;
}

.stat-icon {
    font-size: 2rem;
    opacity: 0.9;
    color: var(--theme-primary);
}

/* =============================================
   🅱️ BOOTSTRAP SUCCESS OVERRIDES
   ============================================= */
.btn-success {
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
}

.btn-success:hover {
    background-color: var(--btn-hover-darken);
    border-color: var(--btn-hover-darken);
}

.btn-outline-success {
    color: var(--theme-primary);
    border-color: var(--theme-primary);
}

.btn-outline-success:hover {
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
    color: white;
}

.badge.bg-success {
    background-color: var(--badge-bg) !important;
}

.text-success {
    color: var(--theme-primary) !important;
}

.bg-success-subtle {
    background-color: var(--theme-bg-subtle) !important;
}

.text-bg-success {
    background-color: var(--theme-primary) !important;
    color: white;
}

.border-success {
    border-color: var(--theme-primary) !important;
}

.alert-success {
    background-color: var(--theme-bg-subtle);
    border-color: var(--theme-light);
    color: var(--text-primary);
}

.wside {
    display: none !important;
}

/* =============================================
   📱 MOBILE: RESPONSIVE LAYOUT
   ============================================= */
@media (max-width: 768px) {
    .sidebar-header {
        border-right: 1px solid var(--border-color);
    }

    .top-navbar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-body);
    }

    .bottom-action-bar {
        width: 100%;
        border-radius: 0 !important;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .bottom-action-bar {
        left: 0;
    }

    .mobile-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 20, 0, 0.25);
        z-index: 1025;
    }
}