:root {
    --primary: #696cff;
    --primary-light: #7c7fff;
    --primary-dark: #5f61e6;
    --secondary: #8592a3;
    --success: #71dd37;
    --info: #03c3ec;
    --warning: #ffab00;
    --danger: #ff3e1d;
    --dark: #233446;
    --light: #f5f5f9;
    --white: #fff;
    --text-primary: #566a7f;
    --text-secondary: #697a8d;
    --border-color: #d9dee3;
    
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 78px;
    --navbar-height: 70px;
    --transition-speed: 0.3s;
}

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

body {
    font-family: 'Public Sans', -apple-system, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #f8f9fa 100%);
    color: var(--text-secondary);
    font-size: 0.9375rem;
    overflow-x: hidden;
}

body.sidebar-collapsed {
    --sidebar-width: var(--sidebar-collapsed-width);
}

/* ===== MAIN LAYOUT STRUCTURE ===== */
.layout-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.layout-container {
    display: flex;
    flex: 1;
    padding-top: var(--navbar-height);
}

/* ===== TOP NAVBAR ===== */
.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: linear-gradient(90deg, #ffffff 0%, #f8f9fb 100%);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    z-index: 1050;
    backdrop-filter: blur(10px);
}

/* Logo Section */
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: var(--sidebar-width);
    padding-right: 1.5rem;
    text-decoration: none;
    transition: width var(--transition-speed) ease;
}

body.sidebar-collapsed .navbar-brand {
    width: var(--sidebar-collapsed-width);
}

.brand-logo {
    font-size: 2rem;
    color: var(--primary);
    transition: all 0.3s ease;
}

.brand-logo:hover {
    transform: scale(1.05);
}

.brand-text {
    font-size: 1.375rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
    transition: opacity var(--transition-speed) ease;
}

body.sidebar-collapsed .brand-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: auto;
    margin-right: 1rem;
    box-shadow: 0 2px 8px rgba(105, 108, 255, 0.3);
}

.sidebar-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(105, 108, 255, 0.4);
}

.sidebar-toggle i {
    font-size: 1.25rem;
    transition: transform var(--transition-speed) ease;
}

body.sidebar-collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* Mobile Menu Toggle */
.menu-toggle-btn {
    display: none;
    font-size: 1.5rem;
    color: #697a8d;
    background: none;
    border: none;
    cursor: pointer;
    margin-right: 1rem;
}

/* Search Box */
.navbar-search {
    flex: 1;
    max-width: 500px;
    position: relative;
}

.navbar-search input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid #d9dee3;
    border-radius: 0.375rem;
    font-size: 0.9375rem;
    transition: all 0.2s;
}

.navbar-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(105, 108, 255, 0.1);
}

.navbar-search i {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: #8592a3;
}

/* Right Section */
.navbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.navbar-icon {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    color: #697a8d;
    transition: all 0.2s;
    cursor: pointer;
}

.navbar-icon:hover {
    background: rgba(105, 108, 255, 0.04);
    color: var(--primary);
}

.navbar-icon i {
    font-size: 1.375rem;
}

.notification-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border: 2px solid var(--white);
    border-radius: 50%;
}

/* User Dropdown */
.user-dropdown {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 0.375rem;
    transition: background 0.2s;
}

.user-dropdown:hover {
    background: rgba(105, 108, 255, 0.04);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--info));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: #566a7f;
    line-height: 1.2;
}

.user-role {
    font-size: 0.75rem;
    color: #8592a3;
}

/* Dropdown Menu */
.dropdown-menu {
    border: none;
    box-shadow: 0 0.25rem 1rem rgba(67, 89, 113, 0.1);
    border-radius: 0.5rem;
    padding: 0.5rem 0;
}

.dropdown-item {
    padding: 0.5rem 1.25rem;
    font-size: 0.9375rem;
    transition: all 0.2s;
}

.dropdown-item i {
    margin-right: 0.5rem;
    width: 1.25rem;
}

.dropdown-item:hover {
    background: rgba(105, 108, 255, 0.04);
    color: var(--primary);
}

.dropdown-item.text-danger:hover {
    background: rgba(255, 62, 29, 0.08);
    color: var(--danger);
}

.dropdown-divider {
    margin: 0.5rem 0;
    border-color: #d9dee3;
}

.dropdown-header {
    padding: 0.5rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #8592a3;
    text-transform: uppercase;
}

/* ===== LEFT SIDEBAR ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--navbar-height);
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fb 100%);
    border-right: 1px solid var(--border-color);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.04);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
    transition: width var(--transition-speed) ease, transform var(--transition-speed) ease;
}

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

/* Sidebar Menu */
.sidebar-menu {
    padding: 1.5rem 0;
}

.menu-header {
    color: var(--secondary);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.75rem 1.5rem 0.5rem;
    margin-top: 1.25rem;
    white-space: nowrap;
    transition: opacity var(--transition-speed) ease;
}

.menu-header:first-child {
    margin-top: 0.5rem;
}

body.sidebar-collapsed .menu-header {
    opacity: 0;
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.menu-item {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.25s ease;
    position: relative;
    white-space: nowrap;
    border-radius: 0.5rem;
    margin: 0.25rem 0.75rem;
}

.menu-link:hover {
    background: linear-gradient(90deg, rgba(105, 108, 255, 0.08) 0%, rgba(105, 108, 255, 0.04) 100%);
    color: var(--primary);
    transform: translateX(4px);
}

.menu-link.active {
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(105, 108, 255, 0.3);
}

.menu-link.active .menu-icon {
    color: white;
}

.menu-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

body.sidebar-collapsed .menu-link {
    padding: 0.75rem 0;
    justify-content: center;
    margin: 0.25rem 0.5rem;
}

body.sidebar-collapsed .menu-link span:not(.menu-icon) {
    display: none;
}

body.sidebar-collapsed .menu-icon {
    margin-right: 0;
}

.menu-icon {
    font-size: 1.375rem;
    margin-right: 0.875rem;
    color: var(--text-secondary);
    transition: all 0.25s ease;
}

/* Submenu */
.menu-sub {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.menu-item.open > .menu-sub {
    max-height: 500px;
}

body.sidebar-collapsed .menu-sub {
    display: none;
}

.menu-sub .menu-link {
    padding-left: 3.5rem;
    font-size: 0.875rem;
}

body.sidebar-collapsed .menu-sub .menu-link {
    padding-left: 0;
}

.menu-toggle::after {
    content: '\ea4e';
    font-family: 'boxicons' !important;
    position: absolute;
    right: 1.5rem;
    font-size: 0.875rem;
    transition: transform 0.3s ease;
    color: var(--secondary);
}

.menu-item.open > .menu-link.menu-toggle::after {
    transform: rotate(90deg);
}

body.sidebar-collapsed .menu-toggle::after {
    display: none;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 1.5rem;
    min-height: calc(100vh - var(--navbar-height));
    transition: margin-left var(--transition-speed) ease;
}

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

/* Page Header */
.page-header {
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #566a7f;
}

.breadcrumb {
    margin-bottom: 0;
    background: transparent;
    padding: 0;
}

.breadcrumb-item {
    font-size: 0.9375rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: '/';
    color: #8592a3;
}

.breadcrumb-item.active {
    color: #566a7f;
}

.breadcrumb-item a {
    color: var(--primary);
    text-decoration: none;
}

/* ===== CARDS ===== */
.card {
    background: linear-gradient(145deg, #ffffff 0%, #fcfcfd 100%);
    border: 1px solid rgba(105, 108, 255, 0.08);
    border-radius: 0.75rem;
    box-shadow: 0 4px 16px rgba(67, 89, 113, 0.08);
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
    overflow: hidden;
}

.card:hover {
    box-shadow: 0 8px 24px rgba(67, 89, 113, 0.12);
    transform: translateY(-4px);
    border-color: rgba(105, 108, 255, 0.15);
}

.card-header {
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, rgba(105, 108, 255, 0.03) 0%, rgba(105, 108, 255, 0.01) 100%);
    border-bottom: 1px solid rgba(105, 108, 255, 0.1);
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ===== TABLES ===== */
.table {
    color: #697a8d;
    margin-bottom: 0;
}

.table thead th {
    border-bottom: 1px solid #d9dee3;
    padding: 0.875rem 1.25rem;
    font-weight: 600;
    color: #566a7f;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    background: transparent;
}

.table tbody td {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid #f0f2f5;
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: rgba(105, 108, 255, 0.02);
}

/* ===== BUTTONS ===== */
.btn {
    padding: 0.5rem 1.25rem;
    font-size: 0.9375rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border: none;
    color: white;
    box-shadow: 0 4px 12px rgba(105, 108, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(105, 108, 255, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline-primary {
    border: 2px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success);
    border: none;
    color: white;
}

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

.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
}

/* ===== BADGES ===== */
.badge {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.25rem;
}

.bg-label-primary { background: rgba(105, 108, 255, 0.16); color: var(--primary); }
.bg-label-success { background: rgba(113, 221, 55, 0.16); color: var(--success); }
.bg-label-info { background: rgba(3, 195, 236, 0.16); color: var(--info); }
.bg-label-warning { background: rgba(255, 171, 0, 0.16); color: var(--warning); }
.bg-label-danger { background: rgba(255, 62, 29, 0.16); color: var(--danger); }

/* ===== FORMS ===== */
.form-label {
    font-weight: 500;
    color: #566a7f;
    margin-bottom: 0.5rem;
}

.form-control,
.form-select {
    border: 1px solid #d9dee3;
    border-radius: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.9375rem;
    transition: all 0.2s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(105, 108, 255, 0.1);
}

/* ===== ALERTS ===== */
.alert {
    border: none;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.alert-success {
    background: rgba(113, 221, 55, 0.16);
    color: var(--success);
}

.alert-danger {
    background: rgba(255, 62, 29, 0.16);
    color: var(--danger);
}

.alert-dismissible .btn-close {
    padding: 1.25rem 1rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .navbar-brand {
        width: auto;
        padding-right: 0;
    }
    
    .menu-toggle-btn {
        display: block;
    }
    
    .navbar-search {
        display: none;
    }
    
    .user-info {
        display: none;
    }
}

/* Overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1039;
}

.sidebar-overlay.show {
    display: block;
}

/* ===== FOOTER ===== */
.content-footer {
    padding: 1rem 1.5rem;
    margin-top: auto;
    background: linear-gradient(135deg, rgba(105, 108, 255, 0.02) 0%, rgba(105, 108, 255, 0.01) 100%);
    border-top: 1px solid rgba(105, 108, 255, 0.08);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer-link {
    color: var(--primary);
    text-decoration: none;
    transition: all 0.2s;
    margin-left: 0.25rem;
}

.footer-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}
