/* =============================================
   TANJIRUL STORE - Dashboard Stylesheet
   ============================================= */

/* Admin Sidebar Toggle Styles */
#adminSidebar {
    position: fixed;
    left: -260px;
    top: 0;
    width: 260px;
    height: 100%;
    background: #fff;
    transition: left 0.3s ease-in-out;
    z-index: 9999;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

#adminSidebar.active {
    left: 0;
}

#adminMainContent {
    transition: margin-left 0.3s ease-in-out;
}

#adminMainContent.shifted {
    margin-left: 260px;
}

/* Admin Sidebar Toggle Button */
#adminSidebarToggle {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 10000;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 18px;
    color: #374151;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

#adminSidebarToggle:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

#adminSidebarToggle:active {
    transform: scale(0.95);
}

/* Mobile Responsive Design */
@media (max-width: 991px) {
    #adminSidebarToggle {
        display: block !important;
    }
    
    #adminMainContent.shifted {
        margin-left: 0;
    }
    
    /* On mobile, content doesn't shift - sidebar overlays */
    body.sidebar-active #adminMainContent {
        margin-left: 0;
    }
    
    /* Fix for mobile: sidebar should be fixed and slide in */
    .dashboard-sidebar {
        position: fixed !important;
        top: 0;
        left: -260px !important;
        width: 260px;
        height: 100%;
        min-height: 100vh;
        z-index: 9999;
        transition: left 0.3s ease-in-out;
        display: flex !important;
    }
    
    .dashboard-sidebar.active,
    .dashboard-sidebar.show {
        left: 0 !important;
    }
    
    /* Main content should not be shifted on mobile */
    .dashboard-main,
    .dashboard-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 15px;
    }
    
    /* Ensure wrapper doesn't interfere */
    .dashboard-wrapper {
        position: relative;
    }
}

/* Dashboard Variables */
:root {
    --dashboard-bg: #F5F7FA;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --header-height: 70px;
    --card-radius: 12px;
    --transition: all 0.3s ease;
}

/* =============================================
   Dashboard Layout
   ============================================= */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
    height: auto;
    background-color: var(--dashboard-bg);
    overflow-x: hidden;
    overflow-y: auto;
}

/* Dashboard Sidebar */
.dashboard-sidebar {
    width: var(--sidebar-width);
    background-color: var(--white);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
}

.dashboard-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.dashboard-sidebar.collapsed .sidebar-brand span,
.dashboard-sidebar.collapsed .sidebar-menu-text,
.dashboard-sidebar.collapsed .user-info {
    display: none;
}

.dashboard-sidebar.collapsed .sidebar-menu-item {
    justify-content: center;
    padding: 12px;
}

/* Sidebar Brand */
.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .brand-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 20px;
    font-weight: 700;
}

.sidebar-brand .brand-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--secondary-color);
}

.sidebar-brand .brand-tagline {
    font-size: 11px;
    color: var(--gray);
}

/* Sidebar Menu */
.sidebar-menu {
    padding: 15px 0;
}

.sidebar-menu-category {
    padding: 15px 20px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray);
    letter-spacing: 1px;
}

.sidebar-menu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--dark-gray);
    text-decoration: none;
    transition: var(--transition);
    gap: 12px;
    position: relative;
}

.sidebar-menu-item:hover {
    background-color: rgba(255, 107, 53, 0.08);
    color: var(--primary-color);
}

.sidebar-menu-item.active {
    background-color: rgba(255, 107, 53, 0.12);
    color: var(--primary-color);
    font-weight: 500;
}

.sidebar-menu-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background-color: var(--primary-color);
    border-radius: 0 4px 4px 0;
}

.sidebar-menu-icon {
    width: 20px;
    font-size: 16px;
    text-align: center;
}

.sidebar-menu-text {
    flex: 1;
    font-size: 14px;
}

.sidebar-menu-badge {
    background-color: var(--primary-color);
    color: var(--white);
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

/* Dashboard Main Content */
.dashboard-main,
.dashboard-content {
    flex: 1;
    min-width: 0;
    transition: var(--transition);
    min-height: 100vh;
}

.dashboard-sidebar.collapsed ~ .dashboard-main,
.dashboard-sidebar.collapsed ~ .dashboard-content {
    /* No margin needed with sticky sidebar */
}

/* Dashboard Header */
.dashboard-header {
    background-color: var(--white);
    height: var(--header-height);
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.menu-toggle {
    width: 40px;
    height: 40px;
    background-color: var(--light-bg);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--secondary-color);
    transition: var(--transition);
}

.menu-toggle:hover {
    background-color: var(--primary-color);
    color: var(--white);
}

.header-page-title h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--secondary-color);
    margin: 0;
}

.header-page-title p {
    font-size: 12px;
    color: var(--gray);
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-search {
    position: relative;
}

.header-search input {
    width: 250px;
    padding: 10px 15px 10px 40px;
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    font-size: 13px;
    transition: var(--transition);
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary-color);
    width: 300px;
}

.header-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
}

.header-notification {
    position: relative;
}

.header-notification .notification-btn {
    width: 40px;
    height: 40px;
    background-color: var(--light-bg);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--secondary-color);
    position: relative;
    transition: var(--transition);
}

.header-notification .notification-btn:hover {
    background-color: rgba(255, 107, 53, 0.1);
    color: var(--primary-color);
}

.header-notification .badge {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    background-color: var(--danger);
    color: var(--white);
    font-size: 10px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    background-color: var(--light-bg);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.header-user:hover {
    background-color: rgba(255, 107, 53, 0.1);
}

.header-user .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
}

.header-user .user-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    font-size: 14px;
}

.header-user .user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--secondary-color);
}

.header-user .user-role {
    font-size: 11px;
    color: var(--gray);
}

/* Dashboard Content */
.dashboard-content {
    padding: 30px;
}

/* Dashboard Body - Main content area */
.dashboard-body {
    min-height: auto;
    height: auto;
    overflow-y: visible;
    overflow-x: hidden;
}

/* Dashboard Footer */
.dashboard-footer {
    padding: 20px 30px;
    background-color: var(--white);
    border-top: 1px solid var(--light-gray);
    margin-top: auto;
}

.dashboard-footer p {
    margin: 0;
    font-size: 13px;
    color: var(--gray);
}

.dashboard-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.dashboard-footer a:hover {
    text-decoration: underline;
}

/* =============================================
   Dashboard Stats Cards
   ============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: var(--white);
    border-radius: var(--card-radius);
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stat-card.primary::before { background-color: var(--primary-color); }
.stat-card.success::before { background-color: var(--success); }
.stat-card.warning::before { background-color: var(--warning); }
.stat-card.info::before { background-color: var(--info); }
.stat-card.danger::before { background-color: var(--danger); }

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 16px;
}

.stat-card.primary .stat-icon {
    background-color: rgba(255, 107, 53, 0.1);
    color: var(--primary-color);
}

.stat-card.success .stat-icon {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--success);
}

.stat-card.warning .stat-icon {
    background-color: rgba(255, 193, 7, 0.1);
    color: var(--warning);
}

.stat-card.info .stat-icon {
    background-color: rgba(23, 162, 184, 0.1);
    color: var(--info);
}

.stat-card.danger .stat-icon {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--danger);
}

.stat-info h4 {
    font-size: 28px;
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 4px;
}

.stat-info p {
    font-size: 13px;
    color: var(--gray);
    margin: 0;
}

.stat-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    margin-top: 8px;
}

.stat-trend.up {
    color: var(--success);
}

.stat-trend.down {
    color: var(--danger);
}

/* =============================================
   Dashboard Charts
   ============================================= */
.chart-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 30px;
}

.chart-card {
    background-color: var(--white);
    border-radius: var(--card-radius);
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--secondary-color);
}

.chart-actions {
    display: flex;
    gap: 8px;
}

.chart-actions button {
    padding: 6px 12px;
    border: 1px solid var(--light-gray);
    background-color: var(--white);
    border-radius: 6px;
    font-size: 12px;
    color: var(--gray);
    cursor: pointer;
    transition: var(--transition);
}

.chart-actions button.active,
.chart-actions button:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--white);
}

.chart-container {
    height: 300px;
    position: relative;
    min-height: 350px;
    overflow: hidden;
}

/* Chart and Table Spacing Fix */
.chart-container::after {
    content: "";
    display: table;
    clear: both;
}

.chart-placeholder {
    min-height: 280px;
    width: 100%;
    overflow: hidden;
}

/* Ensure proper spacing between chart and table sections */
.sales-chart-section,
.chart-container {
    margin-bottom: 0;
}

.sales-chart-section + .recent-orders-section,
.chart-container + .table-card,
.row:has(.chart-container) + .row:has(.table-card) {
    margin-top: 24px;
}

/* =============================================
   Dashboard Tables
   ============================================= */
.table-card {
    background-color: var(--white);
    border-radius: var(--card-radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    overflow: hidden;
}

.table-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--secondary-color);
}

.table-action {
    display: flex;
    gap: 8px;
}

.table {
    margin: 0;
}

.table thead th {
    background-color: var(--light-bg);
    padding: 14px 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray);
    border: none;
}

.table tbody td {
    padding: 16px 20px;
    font-size: 13px;
    color: var(--dark-gray);
    vertical-align: middle;
    border-bottom: 1px solid var(--light-gray);
}

.table tbody tr:hover {
    background-color: rgba(255, 107, 53, 0.02);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.pending {
    background-color: rgba(255, 193, 7, 0.15);
    color: #B38600;
}

.status-badge.processing {
    background-color: rgba(23, 162, 184, 0.15);
    color: var(--info);
}

.status-badge.shipped {
    background-color: rgba(255, 107, 53, 0.15);
    color: var(--primary-color);
}

.status-badge.delivered {
    background-color: rgba(40, 167, 69, 0.15);
    color: var(--success);
}

.status-badge.cancelled {
    background-color: rgba(220, 53, 69, 0.15);
    color: var(--danger);
}

.status-badge.active {
    background-color: rgba(40, 167, 69, 0.15);
    color: var(--success);
}

.status-badge.inactive {
    background-color: rgba(108, 117, 125, 0.15);
    color: var(--gray);
}

/* =============================================
   Dashboard Forms
   ============================================= */
.form-card {
    background-color: var(--white);
    border-radius: var(--card-radius);
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    margin-bottom: 24px;
}

.form-card-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--light-gray);
}

.form-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 4px;
}

.form-card-subtitle {
    font-size: 13px;
    color: var(--gray);
}

/* Profile Form */
.profile-form .avatar-upload {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--light-gray);
}

.profile-avatar-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 36px;
    font-weight: 600;
}

.avatar-upload-btn {
    padding: 10px 20px;
    border: 1px solid var(--light-gray);
    background-color: var(--white);
    border-radius: 8px;
    font-size: 13px;
    color: var(--dark-gray);
    cursor: pointer;
    transition: var(--transition);
}

.avatar-upload-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* =============================================
   Dashboard Cards
   ============================================= */
.dashboard-card {
    background-color: var(--white);
    border-radius: var(--card-radius);
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    margin-bottom: 24px;
}

.dashboard-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--light-gray);
}

.dashboard-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--secondary-color);
}

/* =============================================
   Activity Feed
   ============================================= */
.activity-feed {
    padding: 0;
}

.activity-item {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--light-gray);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.activity-icon.order {
    background-color: rgba(255, 107, 53, 0.1);
    color: var(--primary-color);
}

.activity-icon.payment {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--success);
}

.activity-icon.review {
    background-color: rgba(255, 193, 7, 0.1);
    color: var(--warning);
}

.activity-icon.support {
    background-color: rgba(23, 162, 184, 0.1);
    color: var(--info);
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--secondary-color);
    margin-bottom: 4px;
}

.activity-description {
    font-size: 12px;
    color: var(--gray);
    margin-bottom: 4px;
}

.activity-time {
    font-size: 11px;
    color: var(--gray);
}

/* =============================================
   Quick Actions
   ============================================= */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 30px;
}

.quick-action {
    background-color: var(--white);
    border-radius: var(--card-radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.quick-action:hover {
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
}

.quick-action-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 20px;
    margin: 0 auto 12px;
}

.quick-action-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--secondary-color);
}

/* =============================================
   Sidebar User Profile
   ============================================= */
.sidebar-user {
    padding: 20px;
    border-top: 1px solid var(--light-gray);
    margin-top: auto;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
}

.sidebar-user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--secondary-color);
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--gray);
}

/* =============================================
   Dashboard Responsive
   ============================================= */

/* Desktop Sidebar - Sticky on desktop */
@media (min-width: 992px) {
    .dashboard-sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        width: var(--sidebar-width);
        z-index: 1000;
        flex-shrink: 0;
    }
    
    .dashboard-main,
    .dashboard-content {
        flex: 1;
        min-width: 0;
    }
    
    /* Hide mobile offcanvas toggle on desktop */
    .sidebar-toggle-btn {
        display: none;
    }
}

/* Mobile Sidebar - Show offcanvas, hide fixed sidebar */
@media (max-width: 991.98px) {
    .dashboard-sidebar {
        display: none;
    }
    
    .dashboard-main,
    .dashboard-content {
        margin-left: 0;
    }
    
    .sidebar-toggle-btn {
        display: flex;
    }
}

@media (max-width: 1199px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-grid {
        grid-template-columns: 1fr;
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 991px) {
    .header-search {
        display: none;
    }
}

@media (max-width: 767px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-content {
        padding: 20px;
    }
    
    .dashboard-header {
        padding: 0 15px;
    }
    
    .header-user .user-info {
        display: none;
    }
    
    .table-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}

@media (max-width: 575px) {
    .quick-actions {
        grid-template-columns: 1fr;
    }
    
    .form-card {
        padding: 20px;
    }
    
    .profile-form .avatar-upload {
        flex-direction: column;
        text-align: center;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-info h4 {
        font-size: 24px;
    }
}

/* =============================================
   Collapsed Sidebar State (Desktop only)
   ============================================= */
@media (min-width: 992px) {
    .dashboard-sidebar.collapsed {
        width: var(--sidebar-collapsed-width);
    }
    
    .dashboard-sidebar.collapsed .sidebar-menu-category,
    .dashboard-sidebar.collapsed .sidebar-user {
        display: none;
    }
    
    .dashboard-sidebar.collapsed ~ .dashboard-main,
    .dashboard-sidebar.collapsed ~ .dashboard-content {
        /* No margin needed with sticky sidebar - flexbox handles spacing */
    }
    
    /* =============================================
       LARGE SCREEN SCROLL FIX (992px and above)
       Fix for vertical scroll not reaching full content
       ============================================= */
    html, body {
        height: auto;
        min-height: 100vh;
        overflow-y: auto !important;
        overflow-x: hidden;
    }
    
    body {
        position: relative;
    }
    
    .dashboard-wrapper {
        display: flex;
        min-height: 100vh;
        height: auto;
        overflow-y: auto !important;
        overflow-x: hidden;
    }
    
    .dashboard-main,
    .dashboard-content {
        flex: 1;
        min-height: calc(100vh - var(--header-height, 70px));
        height: auto;
        overflow-y: visible;
        overflow-x: hidden;
    }
    
    .dashboard-header {
        position: sticky;
        top: 0;
        z-index: 100;
        flex-shrink: 0;
    }
    
    .dashboard-body {
        min-height: auto;
        height: auto;
        overflow-y: visible;
    }
    
    .dashboard-footer {
        position: relative;
        margin-top: auto;
        flex-shrink: 0;
    }
}

/* =============================================
   Dark Mode Support (Optional)
   ============================================= */
@media (prefers-color-scheme: dark) {
    :root {
        --dashboard-bg: #1a1a2e;
        --sidebar-bg: #16213e;
    }
    
    .dashboard-wrapper {
        background-color: var(--dashboard-bg);
    }
    
    .dashboard-sidebar,
    .stat-card,
    .chart-card,
    .table-card,
    .dashboard-card,
    .form-card,
    .quick-action,
    .dashboard-header {
        background-color: var(--sidebar-bg);
    }
}

/* =============================================
    COMPREHENSIVE MOBILE RESPONSIVE FIXES
    ============================================= */

/* --- A. MOBILE SIDEBAR OFFCANVAS FIX --- */
/* Hide desktop sidebar on mobile, show offcanvas */
@media (max-width: 991.98px) {
    .dashboard-sidebar {
        display: none !important;
    }
    
    .dashboard-main,
    .dashboard-content {
        margin-left: 0 !important;
        width: 100%;
    }
    
    /* Mobile Sidebar Toggle Button */
    .sidebar-toggle-btn {
        display: flex!important;
        align-items: center;
        justify-content: center;
        /* width: 40px;
        height: 40px; */
        background-color: var(--white);
        border: 1px solid var(--light-gray);
        border-radius: 8px;
        cursor: pointer;
        transition: var(--transition);
        z-index: 1040;
    }
    
    .sidebar-toggle-btn:hover {
        background-color: var(--primary-color);
        color: var(--white);
        border-color: var(--primary-color);
    }
    
    .sidebar-toggle-btn i {
        font-size: 18px;
    }
    
    /* Mobile Offcanvas Sidebar */
    .offcanvas {
        width: 260px !important;
    }
    
    .offcanvas.offcanvas-start {
        transform: translateX(-100%);
    }
    
    .offcanvas.show {
        transform: translateX(0);
    }
    
    .offcanvas-backdrop.show {
        opacity: 0.5;
    }
    
    /* Mobile Sidebar Styles */
    .mobile-sidebar-menu {
        padding: 0;
    }
    
    .mobile-sidebar-menu .sidebar-menu-category {
        padding: 15px 20px 8px;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        color: var(--gray);
        letter-spacing: 1px;
    }
    
    .mobile-sidebar-menu .sidebar-menu-item {
        display: flex;
        align-items: center;
        padding: 12px 20px;
        color: var(--dark-gray);
        text-decoration: none;
        transition: var(--transition);
        gap: 12px;
    }
    
    .mobile-sidebar-menu .sidebar-menu-item:hover,
    .mobile-sidebar-menu .sidebar-menu-item.active {
        background-color: rgba(255, 107, 53, 0.08);
        color: var(--primary-color);
    }
    
    .mobile-sidebar-menu .sidebar-menu-item.active {
        font-weight: 500;
    }
    
    /* Mobile User Profile in Sidebar */
    .mobile-user-profile {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 15px 20px;
        border-bottom: 1px solid var(--light-gray);
        margin-bottom: 10px;
    }
    
    .mobile-user-profile img {
        width: 45px;
        height: 45px;
        border-radius: 8px;
        object-fit: cover;
    }
    
    .mobile-user-profile h6 {
        margin: 0;
        font-size: 14px;
        font-weight: 600;
        color: var(--secondary-color);
    }
    
    .mobile-user-profile span {
        font-size: 12px;
        color: var(--gray);
    }
}

/* --- B. DESKTOP SIDEBAR FIX --- */
/* Sticky sidebar only above 992px */
@media (min-width: 992px) {
    .dashboard-sidebar {
        position: sticky !important;
        top: 0;
        height: 100vh;
        width: var(--sidebar-width);
        z-index: 1000;
        display: block !important;
        transform: none !important;
        flex-shrink: 0;
    }
    
    .dashboard-main,
    .dashboard-content {
        flex: 1;
        min-height: 100vh;
        min-width: 0;
    }
    
    /* Hide mobile toggle on desktop */
    .sidebar-toggle-btn {
        display: none !important;
    }
    
    /* Hide mobile offcanvas on desktop */
    .offcanvas {
        transform: none !important;
    }
}

/* --- C. MOBILE CONTENT FIX --- */
@media (max-width: 991.98px) {
    .dashboard-wrapper {
        overflow-x: hidden;
    }
    
    .dashboard-main,
    .dashboard-content {
        margin-left: 0;
        padding: 15px;
        width: 100%;
    }
    
    /* Remove fixed positioning issues */
    .dashboard-header {
        position: sticky;
        top: 0;
        z-index: 100;
        width: 100%;
    }
}

/* --- D. GRID FIX FOR SIDEBAR/CONTENT LAYOUT --- */
/* Bootstrap grid for dashboard layout */
@media (max-width: 991.98px) {
    .dashboard-layout-row {
        display: flex;
        flex-direction: column;
    }
    
    .dashboard-layout-row > .sidebar-column {
        order: -1;
        width: 100%;
    }
    
    .dashboard-layout-row > .content-column {
        width: 100%;
    }
}

/* --- E. TABLE FIX --- */
/* Wrap tables in .table-responsive */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    min-width: 600px;
}

/* Table mobile improvements */
@media (max-width: 767.98px) {
    .table-card {
        overflow: hidden;
    }
    
    .table-card .table-responsive {
        margin: -20px;
        padding: 0;
    }
    
    .table-card .table {
        font-size: 13px;
    }
    
    .table-card .table thead th,
    .table-card .table tbody td {
        padding: 12px 15px;
        white-space: nowrap;
    }
    
    /* Hide less important columns on mobile */
    .table-mobile-hide {
        display: none;
    }
}

/* --- F. CARD FIX --- */
/* Use Bootstrap grid classes for cards */
.dashboard-card-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1399px) {
    .dashboard-card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1199px) {
    .dashboard-card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767.98px) {
    .dashboard-card-grid {
        grid-template-columns: 1fr;
    }
}

/* Bootstrap column classes for cards */
@media (min-width: 992px) {
    .col-lg-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media (max-width: 767.98px) {
    .col-sm-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* --- G. HEADER FIX --- */
/* Make header responsive with flex */
.dashboard-header,
.dashboard-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.dashboard-header .header-left,
.dashboard-header .header-right,
.dashboard-navbar .nav-left,
.dashboard-navbar .nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

@media (max-width: 991.98px) {
    .dashboard-header,
    .dashboard-navbar {
        padding: 15px;
        min-height: auto;
    }
    
    .dashboard-header .header-page-title h3,
    .dashboard-navbar .navbar-title {
        font-size: 16px;
    }
    
    .dashboard-header .header-page-title p,
    .dashboard-navbar .navbar-subtitle {
        display: none;
    }
    
    .dashboard-header .header-right,
    .dashboard-navbar .nav-right {
        gap: 10px;
    }
    
    .header-search {
        display: none;
    }
    
    .header-user .user-name,
    .header-user .user-role {
        display: none;
    }
    
    /* Navbar specific */
    .dashboard-navbar .search-box {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .dashboard-header,
    .dashboard-navbar {
        padding: 12px 15px;
    }
    
    .dashboard-header .header-right,
    .dashboard-navbar .nav-right {
        gap: 5px;
    }
    
    .header-user,
    .dashboard-navbar .user-dropdown {
        padding: 5px;
    }
}

/* --- H. SCROLL FIX --- */
/* Remove overflow:hidden from parent containers */
body {
    overflow-x: hidden;
}

.dashboard-wrapper {
    overflow-x: visible;
    overflow-y: auto;
}

/* Allow full page scroll */
html, body {
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Fix for fixed header and scrolling */
@media (max-width: 991.98px) {
    html {
        overflow-y: auto;
    }
    
    body {
        padding-top: 0;
    }
    
    .dashboard-main {
        padding-bottom: 30px;
    }
}

/* --- I. MODAL FIX --- */
/* Ensure modals use modal-fullscreen-sm-down */
.modal.fullscreen-modal .modal-dialog {
    max-width: 100%;
    margin: 0;
    height: 100%;
}

.modal.fullscreen-modal .modal-content {
    height: 100%;
    border: 0;
    border-radius: 0;
}

@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-dialog.modal-fullscreen-sm-down {
        max-width: 100%;
        height: 100%;
        margin: 0;
    }
    
    .modal-dialog.modal-fullscreen-sm-down .modal-content {
        height: 100%;
        border-radius: 0;
    }
    
    .modal-body {
        padding: 15px;
        max-height: calc(100vh - 200px);
        overflow-y: auto;
    }
    
    /* Adjust modal header for small screens */
    .modal-header {
        padding: 10px 15px;
        flex-shrink: 0;
    }
    
    .modal-header .modal-title {
        font-size: 1rem;
    }
    
    /* Adjust modal footer for small screens */
    .modal-footer {
        padding: 10px 15px;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .modal-footer .btn {
        flex: 1 1 auto;
        margin: 2px 0;
        min-width: 80px;
    }
    
    /* Stack modal buttons on very small screens */
    .modal-footer .btn + .btn {
        margin-left: 0;
    }
}

/* Extra small devices (landscape phones) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .modal-dialog {
        max-width: 95%;
        margin: 1.75rem auto;
    }

    .modal-body {
        max-height: calc(100vh - 250px);
        overflow-y: auto;
    }
}

/* Medium devices (tablets) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .modal-lg, .modal-xl {
        max-width: 90%;
    }

    .modal-body {
        max-height: calc(100vh - 300px);
        overflow-y: auto;
    }
}

/* --- J. ADDITIONAL MOBILE FIXES --- */

/* Stats Cards on Mobile */
@media (max-width: 767.98px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 15px;
        display: flex;
        align-items: center;
        gap: 15px;
    }
    
    .stat-card .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 20px;
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .stat-card .stat-info {
        flex: 1;
    }
    
    .stat-card .stat-info h4 {
        font-size: 20px;
    }
}

/* Chart Cards on Mobile */
@media (max-width: 991.98px) {
    .chart-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-card {
        margin-bottom: 20px;
    }
}

/* Form Cards on Mobile */
@media (max-width: 575.98px) {
    .form-card {
        padding: 20px 15px;
    }
    
    .form-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .form-card-title {
        font-size: 16px;
    }
    
    .form-card-subtitle {
        font-size: 12px;
    }
}

/* Quick Actions on Mobile */
@media (max-width: 991.98px) {
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .quick-action {
        padding: 15px;
    }
    
    .quick-action-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .quick-action-text {
        font-size: 12px;
    }
}

@media (max-width: 575.98px) {
    .quick-actions {
        grid-template-columns: 1fr;
    }
}

/* Table Header on Mobile */
@media (max-width: 767.98px) {
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .table-title {
        font-size: 14px;
    }
    
    .table-action {
        width: 100%;
        justify-content: flex-start;
    }
}

/* Breadcrumb on Mobile */
.breadcrumb {
    margin-bottom: 15px;
}

@media (max-width: 575.98px) {
    .breadcrumb {
        font-size: 12px;
    }
    
    .breadcrumb-item {
        font-size: 12px;
    }
}

/* Alert on Mobile */
@media (max-width: 575.98px) {
    .alert {
        padding: 12px 15px;
        font-size: 13px;
    }
}

/* Pagination on Mobile */
@media (max-width: 575.98px) {
    .pagination {
        gap: 3px;
    }
    
    .page-link {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Dropdown on Mobile */
@media (max-width: 575.98px) {
    .dropdown-menu {
        width: 100%;
        min-width: 180px;
    }
}

/* Buttons on Mobile */
@media (max-width: 575.98px) {
    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .btn-sm {
        padding: 5px 10px;
        font-size: 12px;
    }
}

/* Sidebar Footer on Mobile */
.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--light-gray);
    margin-top: auto;
}

.back-to-store {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--gray);
    text-decoration: none;
    padding: 10px;
    border-radius: 8px;
    transition: var(--transition);
}

.back-to-store:hover {
    background-color: rgba(255, 107, 53, 0.1);
    color: var(--primary-color);
}

@media (max-width: 991.98px) {
    .sidebar-footer {
        display: none;
    }
}
