/* ============================================
   CSS VARIABLES & ROOT STYLES
   ============================================ */
:root {
    /* Primary Colors */
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    
    /* Secondary Colors */
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    
    /* Neutral Colors */
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    
    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    
    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    /* Border Colors */
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    
    /* Shadow */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    
    /* Layout Dimensions */
    --header-height: 64px;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Font */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Dark Theme Variables */
[data-bs-theme="dark"] {
    --bg-primary: #1e293b;
    --bg-secondary: #0f172a;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #475569;
    --gray-100: #334155;
    --gray-200: #475569;
    --gray-50: #1e293b;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-color);
}

/* ============================================
   HEADER / TOP NAVIGATION BAR
   ============================================ */
.header-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    z-index: 1030;
    transition: all var(--transition-normal);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1rem;
    gap: 1rem;
}

/* Logo Section */
.header-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: calc(var(--sidebar-width) - 2rem);
    transition: min-width var(--transition-normal);
}

.sidebar-collapsed .header-logo {
    min-width: calc(var(--sidebar-collapsed-width) - 2rem);
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.logo-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    border-radius: var(--radius-md);
    color: white;
    font-size: 1.25rem;
}

.logo-text {
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-toggle-btn {
    display: none;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.sidebar-toggle-btn:hover {
    background-color: var(--gray-100);
    color: var(--text-primary);
}

/* Search Bar */
.header-search {
    flex: 1;
    max-width: 480px;
}

.search-form {
    width: 100%;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    font-size: 1rem;
}

.search-input {
    width: 100%;
    height: 42px;
    text-indent: 25px;
    padding: 0 3rem 0 2.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background-color: var(--bg-secondary);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-shortcut {
    position: absolute;
    right: 1rem;
    padding: 0.25rem 0.5rem;
    background-color: var(--gray-100);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: inherit;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-action-item {
    position: relative;
}

.action-btn {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background-color: var(--gray-100);
    color: var(--text-primary);
}

.action-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background-color: var(--danger-color);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-badge.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

/* Theme Toggle */
.theme-toggle-btn {
    position: relative;
}

.theme-icon-dark {
    display: none;
}

[data-bs-theme="dark"] .theme-icon-light {
    display: none;
}

[data-bs-theme="dark"] .theme-icon-dark {
    display: block;
}

/* Header Divider */
.header-divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
    margin: 0 0.5rem;
}

/* User Profile Dropdown */
.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem;
    padding-right: 0.75rem;
    border: none;
    background: transparent;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-profile-btn:hover {
    background-color: var(--gray-100);
}

.user-avatar {
    position: relative;
    width: 40px;
    height: 40px;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.user-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border: 2px solid var(--bg-primary);
    border-radius: var(--radius-full);
}

.user-status.online {
    background-color: var(--success-color);
}

.user-status.away {
    background-color: var(--warning-color);
}

.user-status.busy {
    background-color: var(--danger-color);
}

.user-status.offline {
    background-color: var(--gray-400);
}

.user-info {
    text-align: left;
}

.user-name {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.user-plan {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--primary-color);
}

.user-plan i {
    font-size: 0.625rem;
}

.user-dropdown-icon {
    color: var(--text-muted);
    font-size: 0.75rem;
    transition: transform var(--transition-fast);
}

.user-dropdown.show .user-dropdown-icon {
    transform: rotate(180deg);
}

/* ============================================
   DROPDOWN MENUS - SMOOTH ANIMATION
   ============================================ */
.dropdown-menu {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    background-color: var(--bg-primary);
    margin-top: 0.5rem !important;
    opacity: 0;
    transform: scale(0.95);
    transform-origin: top right;
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: block !important;
    visibility: hidden;
    pointer-events: none;
}

.dropdown-menu.show {
    opacity: 1;
    transform: scale(1);
    visibility: visible;
    pointer-events: auto;
}

.dropdown-menu-end {
    transform-origin: top right;
}

.dropdown-menu:not(.dropdown-menu-end) {
    transform-origin: top left;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    background-color: var(--gray-100);
    color: var(--text-primary);
}

.dropdown-item i {
    font-size: 1rem;
    color: var(--text-secondary);
}

.dropdown-item.text-danger {
    color: var(--danger-color);
}

.dropdown-item.text-danger i {
    color: var(--danger-color);
}

.dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
}

.dropdown-header h6 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.dropdown-footer {
    padding: 0.75rem 1rem;
    text-align: center;
}

.dropdown-footer a {
    font-size: 0.875rem;
    color: var(--primary-color);
    font-weight: 500;
}

.dropdown-divider {
    margin: 0.375rem 0;
    border-color: var(--border-color);
}

.mark-all-read {
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 500;
}

/* Notification Dropdown */
.notification-dropdown {
    width: 360px;
    max-width: calc(100vw - 2rem);
}

.notification-list {
    max-height: 320px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
    position: relative;
}

.notification-item:hover {
    background-color: var(--gray-100);
}

.notification-item.unread {
    background-color: rgba(99, 102, 241, 0.05);
}

.notification-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 40%;
    background-color: var(--primary-color);
    border-radius: var(--radius-full);
}

.notification-avatar,
.notification-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.notification-icon {
    font-size: 1rem;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-text {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.4;
}

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

/* Apps Dropdown */
.apps-dropdown {
    width: 320px;
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    padding: 0.5rem;
}

.app-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
    text-align: center;
}

.app-item:hover {
    background-color: var(--gray-100);
}

.app-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.app-item span {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* User Menu */
.user-menu {
    width: 280px;
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem;
}

.user-menu-header img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
}

.user-menu-info h6 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-menu-info p {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.plan-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    color: white;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    margin-top: 0.375rem;
}

/* ============================================
   SIDEBAR NAVIGATION
   ============================================ */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background-color: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    z-index: 1020;
    transition: width var(--transition-normal);
    display: flex;
    flex-direction: column;
}

.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
}

/* Custom Scrollbar */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

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

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: var(--radius-full);
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Nav Section */
.nav-section {
    margin-bottom: 1.5rem;
}

/* Nav Section Header */
.nav-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem 0 1.25rem;
    margin-bottom: 0.5rem;
    min-height: 24px;
}

.nav-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--transition-normal);
}

/* Sidebar Collapse Button */
.sidebar-collapse-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--gray-100);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.sidebar-collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

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

.nav-item {
    position: relative;
}

/* Nav Link - Default State */
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0;
    transition: all var(--transition-fast);
    position: relative;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background-color: var(--primary-color);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: height var(--transition-fast);
}

.nav-link:hover {
    color: var(--text-primary);
    background-color: var(--gray-100);
}

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

.nav-link.active::before {
    height: 60%;
}

/* Nav Icon - Fixed size for consistent alignment */
.nav-icon {
    width: 24px;
    height: 24px;
    min-width: 24px;
    font-size: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.nav-arrow {
    font-size: 0.75rem;
    transition: transform var(--transition-fast), opacity var(--transition-normal);
    margin-left: auto;
}

.nav-badge {
    padding: 0.125rem 0.5rem;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    transition: opacity var(--transition-normal);
}

/* Nav Tooltip for Collapsed Sidebar */
.nav-tooltip {
    position: absolute;
    left: calc(var(--sidebar-collapsed-width) + 6px);
    top: 50%;
    transform: translateY(-50%);
    padding: 0.5rem 0.75rem;
    background-color: var(--gray-800);
    color: white;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all var(--transition-fast);
    z-index: 1050;
}

.nav-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: var(--gray-800);
}

/* Submenu - Default State (Expanded Sidebar) */
.nav-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-normal);
    background-color: var(--bg-primary);
}

.nav-item.has-submenu.open > .nav-link .nav-arrow {
    transform: rotate(90deg);
}

.nav-item.has-submenu.open > .nav-submenu {
    max-height: 500px;
}

.nav-submenu li a {
    display: block;
    padding: 0.5rem 1.25rem 0.5rem 3.5rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    transition: all var(--transition-fast);
}

.nav-submenu li a:hover {
    color: var(--primary-color);
    background-color: var(--gray-50);
}

.nav-submenu li a.active {
    color: var(--primary-color);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.storage-widget {
    padding: 1rem;
    background-color: var(--gray-100);
    border-radius: var(--radius-lg);
}

.storage-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
}

.storage-info i {
    font-size: 1rem;
}

.storage-progress .progress {
    height: 6px;
    background-color: var(--gray-200);
    border-radius: var(--radius-full);
    margin-bottom: 0.5rem;
}

.storage-progress .progress-bar {
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    border-radius: var(--radius-full);
}

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

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

.sidebar-collapsed .nav-section-title {
    opacity: 0;
    visibility: hidden;
    width: 0;
}

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

/* Collapsed Nav Link - Centered Icons */
.sidebar-collapsed .nav-link {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0.875rem 0.5rem;
    gap: 0;
    text-align: center;
}

.sidebar-collapsed .nav-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    font-size: 1.25rem;
}

.sidebar-collapsed .nav-text {
    opacity: 0;
    visibility: hidden;
    width: 0;
    height: 0;
    overflow: hidden;
    position: absolute;
}

.sidebar-collapsed .nav-arrow {
    opacity: 0;
    visibility: hidden;
    position: absolute;
}

.sidebar-collapsed .nav-badge {
    position: absolute;
    top: 6px;
    right: 12px;
    padding: 0.1rem 0.35rem;
    font-size: 0.6rem;
}

.sidebar-collapsed .sidebar-footer {
    opacity: 0;
    visibility: hidden;
    padding: 0;
    height: 0;
    overflow: hidden;
}

/* Show tooltip on hover in collapsed mode (only for non-submenu items) */
.sidebar-collapsed .nav-item:not(.has-submenu):hover .nav-tooltip {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   COLLAPSED SIDEBAR - FLYOUT SUBMENU
   ============================================ */
.sidebar-collapsed .nav-item.has-submenu {
    position: relative;
}

/* Hide inline submenu in collapsed mode */
.sidebar-collapsed .nav-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    width: 220px;
    max-height: none !important;
    height: auto;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 0.5rem;
    margin-left: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.2s ease;
    z-index: 1060;
    overflow: visible;
}

/* Flyout arrow */
.sidebar-collapsed .nav-submenu::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 12px;
    border: 6px solid transparent;
    border-right-color: var(--border-color);
}

.sidebar-collapsed .nav-submenu::after {
    content: '';
    position: absolute;
    left: -5px;
    top: 13px;
    border: 5px solid transparent;
    border-right-color: var(--bg-primary);
}

/* Show submenu flyout on hover */
.sidebar-collapsed .nav-item.has-submenu:hover > .nav-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Flyout submenu header (menu name) */
.sidebar-collapsed .nav-submenu::before {
    content: '';
}

/* Style flyout submenu items */
.sidebar-collapsed .nav-submenu li a {
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    margin: 0;
}

.sidebar-collapsed .nav-submenu li a:hover {
    background-color: var(--gray-100);
}

/* Add menu title to flyout */
.sidebar-collapsed .nav-item.has-submenu .nav-submenu {
    padding-top: 0;
}

.sidebar-collapsed .nav-item.has-submenu .nav-submenu li:first-child::before {
    content: attr(data-title);
}

/* ============================================
   COLLAPSED SIDEBAR - HOVER EXPAND
   ============================================ */
.sidebar-collapsed .sidebar:hover {
    width: var(--sidebar-width);
    box-shadow: var(--shadow-xl);
}

.sidebar-collapsed .sidebar:hover .nav-section-title {
    opacity: 1;
    visibility: visible;
    width: auto;
}

.sidebar-collapsed .sidebar:hover .nav-section-header {
    justify-content: space-between;
    padding: 0 1rem 0 1.25rem;
}

.sidebar-collapsed .sidebar:hover .nav-link {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    padding: 0.75rem 1.25rem;
    gap: 0.75rem;
    text-align: left;
}

.sidebar-collapsed .sidebar:hover .nav-text {
    opacity: 1;
    visibility: visible;
    width: auto;
    height: auto;
    overflow: visible;
    position: static;
}

.sidebar-collapsed .sidebar:hover .nav-arrow {
    opacity: 1;
    visibility: visible;
    position: static;
}

.sidebar-collapsed .sidebar:hover .nav-badge {
    position: static;
    padding: 0.125rem 0.5rem;
    font-size: 0.6875rem;
}

.sidebar-collapsed .sidebar:hover .sidebar-footer {
    opacity: 1;
    visibility: visible;
    padding: 1rem;
    height: auto;
}

.sidebar-collapsed .sidebar:hover .nav-tooltip {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Reset submenu to inline when sidebar is hovered */
.sidebar-collapsed .sidebar:hover .nav-submenu {
    position: static;
    width: auto;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin-left: 0;
    opacity: 1;
    visibility: visible;
    transform: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-normal);
}

.sidebar-collapsed .sidebar:hover .nav-submenu::before,
.sidebar-collapsed .sidebar:hover .nav-submenu::after {
    display: none;
}

.sidebar-collapsed .sidebar:hover .nav-item.has-submenu.open > .nav-submenu {
    max-height: 500px;
}

.sidebar-collapsed .sidebar:hover .nav-submenu li a {
    padding: 0.5rem 1.25rem 0.5rem 3.5rem;
    border-radius: 0;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    z-index: 1015;
    transition: all var(--transition-normal);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    transition: margin-left var(--transition-normal);
    display: flex;
    flex-direction: column;
}

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

.content-wrapper {
    flex: 1;
    padding: 1.5rem;
}

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

.page-header-content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.25rem;
}

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

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

.breadcrumb-item a {
    color: var(--text-secondary);
}

.breadcrumb-item a:hover {
    color: var(--primary-color);
}

.breadcrumb-item.active {
    color: var(--text-muted);
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    color: var(--text-muted);
}

.page-actions {
    display: flex;
    gap: 0.75rem;
}

/* ============================================
   WIDGET CARDS
   ============================================ */
.widget-card {
    background-color: var(--bg-primary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all var(--transition-normal);
}

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

.widget-card-body {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem;
}

.widget-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    font-size: 1.5rem;
    color: white;
    flex-shrink: 0;
}

.bg-primary-gradient {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.bg-success-gradient {
    background: linear-gradient(135deg, #10b981, #34d399);
}

.bg-warning-gradient {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.bg-danger-gradient {
    background: linear-gradient(135deg, #ef4444, #f87171);
}

.widget-content {
    flex: 1;
    min-width: 0;
}

.widget-label {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.widget-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.widget-change {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

.widget-change.positive {
    color: var(--success-color);
}

.widget-change.negative {
    color: var(--danger-color);
}

.widget-footer {
    padding: 0.75rem 1.5rem;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.widget-footer a {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--primary-color);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.widget-footer a:hover {
    text-decoration: underline;
}

/* ============================================
   DASHBOARD CARDS
   ============================================ */
.dashboard-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    height: 100%;
}

.dashboard-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
}

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

.dashboard-card .card-body {
    padding: 1.5rem;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

/* Chart Container */
.chart-container {
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-placeholder {
    width: 100%;
    height: 100%;
}

.chart-svg {
    width: 100%;
    height: 100%;
}

.chart-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-top: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
}

/* Category List */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.category-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.category-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
}

.category-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.category-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

.category-progress .progress {
    height: 6px;
    background-color: var(--gray-100);
    border-radius: var(--radius-full);
}

.category-progress .progress-bar {
    border-radius: var(--radius-full);
}

/* ============================================
   DATA TABLES
   ============================================ */
.dashboard-table {
    margin: 0;
}

.dashboard-table th {
    padding: 1rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.dashboard-table td {
    padding: 1rem 1.5rem;
    vertical-align: middle;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

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

.dashboard-table tbody tr:hover {
    background-color: var(--gray-50);
}

.customer-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.customer-cell img {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
}

/* Custom Badges for Table */
.badge {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-full);
}

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

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

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

.badge-info {
    background-color: rgba(6, 182, 212, 0.1);
    color: var(--info-color);
}

/* Soft Badges */
.badge-soft-primary {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

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

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

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

.badge-soft-info {
    background-color: rgba(6, 182, 212, 0.1);
    color: var(--info-color);
}

/* ============================================
   ACTIVITY FEED
   ============================================ */
.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-item {
    display: flex;
    gap: 0.875rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
}

.activity-item:hover {
    background-color: var(--gray-50);
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
}

.activity-content p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.4;
}

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

/* ============================================
   UI COMPONENTS SECTION
   ============================================ */
.component-section {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.component-section:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.component-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

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

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

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

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

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border-color);
    background-color: transparent;
}

.btn-outline-secondary:hover {
    background-color: var(--gray-100);
    color: var(--text-primary);
    border-color: var(--gray-300);
}

.btn-outline-secondary.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-control,
.form-select {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-primary);
    transition: all var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-group-text {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    border-color: var(--primary-color);
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    border: none;
    font-size: 0.875rem;
}

.alert-primary {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

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

.alert-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: #b45309;
}

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

/* ============================================
   PROGRESS BARS
   ============================================ */
.progress {
    background-color: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    background-color: var(--primary-color);
    transition: width var(--transition-normal);
}

/* ============================================
   FOOTER
   ============================================ */
.main-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    margin-top: auto;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-content p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer-links a:hover {
    color: var(--primary-color);
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */

/* Large Devices (Desktops) */
@media (max-width: 1199.98px) {
    .widget-value {
        font-size: 1.5rem;
    }
}

/* Medium Devices (Tablets) */
@media (max-width: 991.98px) {
    .header-search {
        display: none;
    }
    
    .sidebar-toggle-btn {
        display: flex;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
        width: var(--sidebar-width);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar-collapsed .main-content {
        margin-left: 0;
    }
    
    .sidebar-collapse-btn {
        display: none;
    }
}

/* Small Devices (Landscape Phones) */
@media (max-width: 767.98px) {
    :root {
        --header-height: 60px;
    }
    
    .header-container {
        padding: 0 0.75rem;
    }
    
    .header-logo {
        min-width: auto;
    }
    
    .logo-text {
        display: none;
    }
    
    .header-divider {
        display: none;
    }
    
    .user-info {
        display: none !important;
    }
    
    .user-dropdown-icon {
        display: none !important;
    }
    
    .content-wrapper {
        padding: 1rem;
    }
    
    .page-header-content {
        flex-direction: column;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .page-actions {
        width: 100%;
    }
    
    .page-actions .btn {
        flex: 1;
    }
    
    .widget-card-body {
        flex-direction: column;
        text-align: center;
    }
    
    .widget-icon {
        margin: 0 auto;
    }
    
    .notification-dropdown,
    .apps-dropdown,
    .user-menu {
        width: calc(100vw - 2rem);
        max-width: 360px;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
}

/* Extra Small Devices (Portrait Phones) */
@media (max-width: 575.98px) {
    .page-actions .btn span {
        display: none;
    }
    
    .dashboard-table th,
    .dashboard-table td {
        padding: 0.75rem 1rem;
    }
    
    .customer-cell span {
        display: none;
    }
    
    .apps-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Landscape Mode for Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        height: 100vh;
        top: 0;
        padding-top: var(--header-height);
    }
}

/* Print Styles */
@media print {
    .header-navbar,
    .sidebar,
    .sidebar-overlay,
    .page-actions {
        display: none !important;
    }
    
    .main-content {
        margin: 0;
    }
    
    .dashboard-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
    }
    
    .btn {
        border-width: 2px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
