﻿/* ===============================================
   Lá»˜C THIÃŠN ERP - DESIGN SYSTEM V3
   Based on reference UI screenshots
   =============================================== */

/* === CSS Variables === */
:root {
    /* Colors */
    --sidebar-bg: #3c4d71;
    --sidebar-active: #5a6e94;
    --sidebar-text: rgba(255, 255, 255, 0.85);
    --sidebar-text-muted: rgba(255, 255, 255, 0.6);

    --primary: #7c5cff;
    --primary-light: rgba(124, 92, 255, 0.1);
    --info: #4dabf7;
    --info-light: rgba(77, 171, 247, 0.1);
    --success: #51cf66;
    --success-light: rgba(81, 207, 102, 0.1);
    --warning: #ffc107;
    --warning-light: rgba(255, 193, 7, 0.1);
    --danger: #ff6b6b;
    --danger-light: rgba(255, 107, 107, 0.1);

    --body-bg: #f5f7fa;
    --card-bg: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-color: #e9ecef;

    /* Spacing */
    --sidebar-width: 240px;
    --header-height: 60px;
    --card-radius: 12px;
    --btn-radius: 8px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* === Reset & Base === */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* === Layout === */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: white;
}

.sidebar-brand-text {
    font-weight: 600;
    font-size: 16px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-item {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
    background: var(--sidebar-active);
    color: white;
}

.nav-link i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-submenu {
    margin-left: 36px;
    margin-top: 4px;
}

.nav-submenu .nav-link {
    padding: 10px 16px;
    font-size: 13px;
}

.nav-group-toggle::after {
    content: '\f282';
    font-family: 'bootstrap-icons';
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.2s ease;
}

.nav-group-toggle.expanded::after {
    transform: rotate(180deg);
}

/* === Main Content === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* === Header === */
.main-header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
}

.page-title i {
    color: var(--primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
}

.header-btn:hover {
    background: var(--body-bg);
    color: var(--primary);
}

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

/* === Page Content === */
.page-content {
    flex: 1;
    padding: 24px;
    min-height: calc(100vh - var(--header-height));
    overflow-x: hidden;
}

.page-heading {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
}

/* === Sections === */
.page-content section {
    width: 100%;
    contain: layout;
}

#dispatch-order-list {
    width: 100%;
    min-height: 200px;
}

/* === Cards === */
.card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 20px;
}

/* === Stat Cards === */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.stat-card-content {
    flex: 1;
}

.stat-card-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.stat-card-change {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

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

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

.stat-card-change.neutral {
    color: var(--text-muted);
}

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

.stat-card-icon.purple {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-card-icon.blue {
    background: var(--info-light);
    color: var(--info);
}

.stat-card-icon.orange {
    background: var(--warning-light);
    color: var(--warning);
}

.stat-card-icon.red {
    background: var(--danger-light);
    color: var(--danger);
}

/* === Tab Navigation === */
.tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    border-radius: var(--btn-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-secondary);
    white-space: nowrap;
}

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

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

/* === Search Input === */
.search-input {
    position: relative;
    margin-bottom: 20px;
}

.search-input i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 1px solid var(--border-color);
    border-radius: var(--btn-radius);
    font-size: 14px;
    transition: all 0.2s ease;
}

.search-input input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}


/* === Order Cards === */
.order-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--info);
    width: 100%;
    position: relative;
    contain: content;
}

/* === History Cards Container === */
#history-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 16px;
}

/* === History Order Card === */
.history-order-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--info);
    transition: all 0.2s ease;
    cursor: pointer;
}

.history-order-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-left-color: var(--primary);
}

.history-order-card.status-completed {
    border-left-color: var(--success);
}

.history-order-card.status-cancelled {
    border-left-color: var(--danger);
}

.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.order-id {
    color: var(--info);
    font-weight: 700;
    font-size: 15px;
}

.order-customer {
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 4px;
}

.order-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.order-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.order-meta-item i {
    width: 16px;
    color: var(--text-muted);
}

.order-total {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.order-card-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
    align-items: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.btn-view-detail {
    padding: 6px 16px;
    background: var(--info);
    color: white;
    border: none;
    border-radius: var(--btn-radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-view-detail:hover {
    background: #3b9ae1;
    transform: scale(1.05);
}


/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--btn-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

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

.btn-primary:hover {
    background: #6b4de6;
}

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

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

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* === Status Badge === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-pending {
    background: var(--warning-light);
    color: #b8860b;
}

.badge-processing {
    background: var(--info-light);
    color: var(--info);
}

.badge-completed {
    background: var(--success-light);
    color: var(--success);
}

.badge-cancelled {
    background: var(--danger-light);
    color: var(--danger);
}

/* === Chat Badge (Unread Message Count) === */
.chat-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: linear-gradient(135deg, #ff4757, #ff6b81);
    color: white;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
    animation: pulse-badge 2s infinite;
}

.chat-badge-container {
    position: relative;
    display: inline-flex;
}

@keyframes pulse-badge {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* Nav Badge for sidebar menu items */
.nav-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: linear-gradient(135deg, #ff4757, #ff6b81);
    color: white;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 600;
    display: none;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    box-shadow: 0 2px 6px rgba(255, 71, 87, 0.3);
    animation: pulse-badge 2s infinite;
}

.nav-badge.show {
    display: inline-flex;
}

/* ===== TOAST NOTIFICATIONS ===== */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
}

.notification-toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-left: 4px solid var(--primary);
    animation: slideIn 0.3s ease;
}

.notification-toast.fade-out {
    animation: slideOut 0.3s ease forwards;
}

.toast-icon {
    font-size: 24px;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.toast-body {
    font-size: 14px;
    color: var(--text-muted);
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.toast-close:hover {
    color: var(--text-primary);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* === Form Styles === */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-label i {
    color: var(--primary);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--btn-radius);
    font-size: 14px;
    transition: all 0.2s ease;
}

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

.form-hint {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: var(--info-light);
    border-radius: var(--btn-radius);
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 20px;
}

.form-hint i {
    color: var(--info);
    font-size: 18px;
    margin-top: 2px;
}

/* === Two Column Layout === */
.two-col-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* === Product List (Empty State) === */
.product-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}

.product-list-empty i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.product-list-empty h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.product-list-empty p {
    font-size: 13px;
}

/* === Table Styles === */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: var(--body-bg);
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.data-table tbody tr:hover {
    background: rgba(124, 92, 255, 0.02);
}

/* === Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 20px;
}

.pagination-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

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

.pagination-info {
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* === Chart Container === */
.chart-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.chart-card-header {
    margin-bottom: 24px;
}

.chart-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.chart-card-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

/* Ensure canvas fills container */
.chart-card canvas {
    width: 100% !important;
    height: 100% !important;
}

/* === Analytics Lists === */
.analytics-list-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
    min-width: 0;
    /* Critical for flex truncation */
}

.analytics-list-item:last-child {
    border-bottom: none;
}

.analytics-rank {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.analytics-content {
    flex: 1;
    min-width: 0;
    /* Critical for text truncation */
    overflow: hidden;
}

.analytics-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-primary);
}

.analytics-meta {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.analytics-value {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
    margin-left: 8px;
    text-align: right;
}

/* === Loading Overlay === */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* === Login View === */
.login-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 48px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--info), #6bc5f8);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.login-logo i {
    font-size: 32px;
    color: white;
}

.login-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.login-form .form-group {
    text-align: left;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--sidebar-bg), #4a5d83);
    color: white;
    border: none;
    border-radius: var(--btn-radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.login-demo {
    margin-top: 20px;
    font-size: 12px;
    color: var(--text-muted);
}

/* === Hidden === */
.hidden {
    display: none !important;
}

/* ===============================================
   RESPONSIVE DESIGN SYSTEM V3.0
   Complete Mobile-First Responsive Layout
   =============================================== */

/* === Mobile Menu Components === */
.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    transition: color 0.2s ease;
}

.mobile-menu-toggle:hover {
    color: var(--primary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ===============================================
   BREAKPOINT 1: LARGE DESKTOP (â‰¥1400px)
   =============================================== */
@media (min-width: 1400px) {
    .page-content {
        max-width: 1600px;
        margin: 0 auto;
    }
}

/* ===============================================
   BREAKPOINT 2: TABLET LANDSCAPE (768px - 991px)
   =============================================== */
@media (max-width: 991px) {

    /* === Layout Adjustments === */
    :root {
        --sidebar-width: 200px;
    }

    /* === Stat Cards: 4 â†’ 2 columns === */
    .stat-cards {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px;
    }

    /* === Charts: Stack Vertically === */
    .page-content>div[style*="grid-template-columns:1fr 1fr"],
    .page-content>section>div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    /* === Analytics Row: 3 â†’ 1 column === */
    .analytics-row {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    /* === Two Column Forms: Keep 2 columns on tablet === */
    .two-col-layout {
        gap: 20px;
    }

    /* === Reduce Spacing === */
    .page-content {
        padding: 20px;
    }

    .card-body {
        padding: 16px;
    }

    .chart-card {
        padding: 20px;
    }

    /* === Typography === */
    .page-heading {
        font-size: 20px;
    }

    /* === Tables === */
    .data-table {
        font-size: 13px;
    }

    .data-table th,
    .data-table td {
        padding: 12px;
    }

    /* Override inline styles on dashboard analytics row for responsive layout */
    #section-dashboard>div[style*="grid-template-columns:1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
}

/* ===============================================
   BREAKPOINT 3: MOBILE (â‰¤767px)
   =============================================== */
@media (max-width: 767px) {

    /* === Show Mobile Menu Toggle === */
    .mobile-menu-toggle {
        display: flex;
    }

    /* === Sidebar: Hidden by Default === */
    .sidebar {
        transform: translateX(-100%);
        z-index: 100;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    /* === Main Content: Full Width === */
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* === Header Adjustments === */
    .main-header {
        padding: 0 16px;
    }

    .page-title {
        font-size: 14px;
    }

    .page-title span {
        display: none;
        /* Hide title text on small screens */
    }

    .header-btn[title="ThÃ´ng bÃ¡o"] {
        display: none;
        /* Hide notification button */
    }

    /* === Stat Cards: Stack to 1 Column === */
    .stat-cards {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card-value {
        font-size: 20px;
        line-height: 1.3;
    }

    .stat-card-label {
        font-size: 13px;
    }

    .stat-card-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    /* === Page Content === */
    .page-content {
        padding: 16px;
    }

    .page-heading {
        font-size: 18px;
        margin-bottom: 16px;
    }

    /* === Cards === */
    .card {
        border-radius: 8px;
    }

    .card-header {
        padding: 12px 16px;
        font-size: 14px;
    }

    .card-body {
        padding: 16px;
    }

    /* === Charts: Stack Vertically === */
    .chart-card {
        padding: 16px;
    }

    .chart-card-title {
        font-size: 14px;
    }

    .chart-card-subtitle {
        font-size: 12px;
    }

    /* === Analytics Row: Stack === */
    .analytics-row {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    /* Override inline styles on dashboard analytics row */
    #section-dashboard .analytics-row,
    #section-dashboard>div.analytics-row {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* === Analytics Cards === */
    .analytics-card {
        padding: 16px;
    }

    .analytics-card-title {
        font-size: 14px;
        margin-bottom: 12px;
    }

    /* === Analytics List Items === */
    .analytics-list-item {
        padding: 10px 0;
        gap: 10px;
        flex-wrap: nowrap;
        /* Prevent wrapping */
    }

    .analytics-rank {
        width: 24px;
        height: 24px;
        font-size: 11px;
        flex-shrink: 0;
    }

    .analytics-content {
        flex: 1;
        min-width: 0;
        overflow: hidden;
    }

    .analytics-name {
        font-size: 13px;
        line-height: 1.3;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .analytics-meta {
        font-size: 11px;
        margin-top: 3px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .analytics-value {
        font-size: 12px;
        flex-shrink: 0;
        white-space: nowrap;
        text-align: right;
        min-width: 60px;
    }

    /* === Forms: Stack to 1 Column === */
    .two-col-layout {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .form-control {
        font-size: 16px;
        /* Prevent iOS zoom */
        padding: 12px 14px;
    }

    .form-label {
        font-size: 12px;
    }

    /* === Buttons === */
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .btn-sm {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* === Tab Navigation === */
    .tab-nav {
        flex-wrap: wrap;
        gap: 8px;
    }

    .tab-btn {
        padding: 10px 16px;
        font-size: 13px;
        flex: 1 1 calc(50% - 4px);
        /* 2 buttons per row */
        min-width: 120px;
    }

    /* === Search and Filters === */
    .search-input {
        width: 100% !important;
        min-width: 100% !important;
        flex: none !important;
        margin-bottom: 12px;
    }

    /* === Order Cards === */
    .order-card {
        padding: 16px;
        margin-bottom: 12px;
    }

    .order-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .order-card-footer {
        flex-direction: column;
        gap: 12px;
    }

    .order-card-footer .btn {
        width: 100%;
    }

    .order-id {
        font-size: 14px;
    }

    .order-customer {
        font-size: 14px;
    }

    .order-meta {
        font-size: 12px;
    }

    .order-total {
        font-size: 16px;
    }

    /* === Tables: Horizontal Scroll === */
    .card-body:has(.data-table) {
        padding: 0;
        overflow-x: auto;
    }

    .data-table {
        min-width: 600px;
        font-size: 12px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 12px;
        white-space: nowrap;
    }

    /* === Modals === */
    .modal-content {
        max-width: 95%;
        margin: 0 10px;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-header h3 {
        font-size: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 16px;
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }

    /* === Login Card === */
    .login-card {
        padding: 32px 24px;
        margin: 0 16px;
    }

    .login-title {
        font-size: 20px;
    }

    .login-logo {
        width: 56px;
        height: 56px;
    }

    .login-logo i {
        font-size: 28px;
    }

    /* === Pagination === */
    .pagination {
        padding: 16px;
        gap: 6px;
    }

    .pagination-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .pagination-info {
        font-size: 12px;
        padding: 6px 12px;
    }

    /* === Badges === */
    .badge {
        font-size: 11px;
        padding: 3px 10px;
    }

    /* === Product List Empty State === */
    .product-list-empty {
        padding: 40px 16px;
    }

    .product-list-empty i {
        font-size: 36px;
    }

    .product-list-empty h4 {
        font-size: 14px;
    }

    .product-list-empty p {
        font-size: 12px;
    }

    /* === Form Hints === */
    .form-hint {
        padding: 10px 12px;
        font-size: 12px;
    }

    /* === User Menu Dropdown === */
    .user-menu-dropdown {
        right: -10px;
        min-width: 180px;
    }

    /* === Dashboard Specific === */
    #section-dashboard>div[style*="grid-template-columns:1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    #section-dashboard>div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Ensure analytics row cards are full width */
    #section-dashboard .analytics-row .chart-card {
        width: 100% !important;
        min-width: 100% !important;
    }

    /* === Dispatch Section === */
    #section-dispatch>div[style*="display:flex"] {
        flex-wrap: wrap;
    }

    /* === Flex Containers: Stack on Mobile === */
    .page-content>section>div[style*="display:flex"][style*="justify-content:space-between"] {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }

    .page-content>section>div[style*="display:flex"][style*="gap"] {
        flex-wrap: wrap;
    }
}

/* ===============================================
   BREAKPOINT 4: SMALL MOBILE (â‰¤480px)
   =============================================== */
@media (max-width: 480px) {

    /* === Further Reduce Spacing === */
    .page-content {
        padding: 12px;
    }

    /* === Stat Cards: More Compact === */
    .stat-card {
        padding: 12px;
    }

    .stat-card-value {
        font-size: 18px;
        line-height: 1.2;
    }

    .stat-card-label {
        font-size: 11px;
    }

    .stat-card-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    /* === Analytics: Even More Compact === */
    .analytics-list-item {
        padding: 8px 0;
        gap: 8px;
    }

    .analytics-rank {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }

    .analytics-name {
        font-size: 12px;
    }

    .analytics-meta {
        font-size: 10px;
    }

    .analytics-value {
        font-size: 11px;
        min-width: 50px;
    }

    /* === Buttons: More Compact === */
    .btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .btn-sm {
        padding: 5px 8px;
        font-size: 11px;
    }

    /* === Page Heading === */
    .page-heading {
        font-size: 16px;
        margin-bottom: 12px;
    }

    /* === Cards === */
    .card-header {
        padding: 10px 12px;
        font-size: 13px;
    }

    .card-body {
        padding: 12px;
    }

    .chart-card {
        padding: 12px;
    }

    /* === Order Cards === */
    .order-card {
        padding: 12px;
    }

    .order-id {
        font-size: 13px;
    }

    .order-customer {
        font-size: 13px;
    }

    .order-meta {
        font-size: 11px;
    }

    .order-total {
        font-size: 15px;
    }

    /* === Login === */
    .login-card {
        padding: 24px 20px;
    }

    .login-logo {
        width: 48px;
        height: 48px;
    }

    .login-logo i {
        font-size: 24px;
    }

    .login-title {
        font-size: 18px;
    }

    .login-subtitle {
        font-size: 12px;
    }

    /* === Sidebar === */
    .sidebar-brand {
        padding: 16px;
    }

    .sidebar-brand-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .sidebar-brand-text {
        font-size: 14px;
    }

    .nav-link {
        padding: 10px 14px;
        font-size: 13px;
    }

    .nav-link i {
        font-size: 16px;
        width: 20px;
    }

    /* === Modal: Bottom Sheet Style === */
    .modal-content {
        max-width: 100%;
        margin: 0;
        border-radius: 12px 12px 0 0;
        max-height: 95vh;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
    }

    .modal-overlay {
        align-items: flex-end;
    }

    /* === Tab Navigation: Full Width === */
    .tab-btn {
        flex: 1 1 100%;
        min-width: 100%;
    }

    /* === Header === */
    .main-header {
        padding: 0 12px;
    }

    .header-actions {
        gap: 8px;
    }

    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }

    /* === Analytics === */
    .analytics-rank {
        width: 20px;
        height: 20px;
        font-size: 11px;
    }

    .analytics-name {
        font-size: 12px;
    }

    .analytics-meta {
        font-size: 10px;
    }

    .analytics-value {
        font-size: 11px;
    }
}

/* ===============================================
   BREAKPOINT 5: LANDSCAPE MOBILE (max-height: 500px)
   =============================================== */
@media (max-height: 500px) and (orientation: landscape) {

    /* === Reduce Header Height === */
    :root {
        --header-height: 50px;
    }

    .main-header {
        height: 50px;
    }

    /* === Compact Sidebar === */
    .sidebar-brand {
        padding: 12px 16px;
    }

    .sidebar-brand-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .sidebar-brand-text {
        font-size: 14px;
    }

    .nav-link {
        padding: 8px 12px;
        font-size: 13px;
    }

    .nav-link i {
        font-size: 16px;
    }

    /* === Reduce Page Content Padding === */
    .page-content {
        padding: 16px;
    }

    /* === Compact Stat Cards === */
    .stat-card {
        padding: 12px;
    }

    .stat-card-value {
        font-size: 20px;
    }

    .stat-card-label {
        font-size: 12px;
    }

    /* === Compact Charts === */
    .chart-card {
        padding: 16px;
    }

    /* === Modal Adjustments === */
    .modal-content {
        max-height: 85vh;
    }

    .modal-body {
        max-height: calc(85vh - 140px);
    }
}

/* ===============================================
   PRINT STYLES
   =============================================== */
@media print {

    .sidebar,
    .main-header,
    .btn,
    .pagination,
    .modal-overlay,
    .mobile-menu-toggle,
    .sidebar-overlay {
        display: none !important;
    }

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

    .page-content {
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }

    .stat-cards,
    .analytics-row {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===============================================
   UTILITY CLASSES FOR RESPONSIVE
   =============================================== */

/* Hide on specific breakpoints */
.hide-on-mobile {
    display: block;
}

@media (max-width: 767px) {
    .hide-on-mobile {
        display: none !important;
    }
}

.hide-on-desktop {
    display: none;
}

@media (max-width: 767px) {
    .hide-on-desktop {
        display: block !important;
    }
}

/* Responsive text alignment */
@media (max-width: 767px) {
    .text-center-mobile {
        text-align: center !important;
    }

    .text-left-mobile {
        text-align: left !important;
    }
}

/* Full width on mobile */
@media (max-width: 767px) {
    .full-width-mobile {
        width: 100% !important;
    }
}

/* ===============================================
   MODAL STYLES
   =============================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--primary) 0%, #9c7cff 100%);
    color: white;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-body {
    padding: 20px;
}

/* Order Detail Grid */
.order-detail-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-row:last-child {
    border-bottom: none;
}


.detail-row label {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 120px;
}

.detail-row span {
    font-size: 14px;
    color: var(--text-primary);
    text-align: right;
    flex: 1;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.data-table th {
    background: var(--body-bg);
    font-weight: 600;
    color: var(--text-secondary);
}

.data-table td {
    color: var(--text-primary);
}

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

/* Responsive Modal */
@media (max-width: 767px) {
    .modal-content {
        max-width: 95%;
        margin: 10px;
    }

    .modal-body {
        padding: 16px;
    }

    .detail-row {
        flex-direction: column;
        gap: 4px;
    }

    .detail-row span {
        text-align: left;
    }

    /* History Cards Responsive */
    #history-cards-container {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .history-order-card {
        padding: 16px;
    }
}

/* Tablet Responsive */
@media (min-width: 768px) and (max-width: 1024px) {
    #history-cards-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

/* Large Desktop (1200px+) */
@media (min-width: 1200px) {
    .stat-cards {
        grid-template-columns: repeat(4, 1fr);
    }

    .tab-nav {
        justify-content: flex-start;
    }

    .tab-btn {
        flex: none;
        min-width: auto;
    }

    .two-col-layout {
        grid-template-columns: 1fr 1fr;
    }
}

/* Medium Desktop (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .stat-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablet (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .sidebar {
        width: 200px;
    }

    :root {
        --sidebar-width: 200px;
    }

    .two-col-layout {
        grid-template-columns: 1fr;
    }
}

/* Mobile (max-width: 767px) */
@media (max-width: 767px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

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

    .page-content {
        padding: 16px;
    }

    .stat-cards {
        grid-template-columns: 1fr;
    }

    .page-heading {
        font-size: 20px;
    }

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

    .tab-btn {
        width: 100%;
        text-align: center;
    }

    .data-table {
        font-size: 12px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 6px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .order-card {
        padding: 16px;
    }

    .header-actions {
        gap: 8px;
    }
}

/* Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
    .page-heading {
        font-size: 18px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card-value {
        font-size: 24px;
    }

    .main-header {
        padding: 0 12px;
    }

    .page-title {
        font-size: 14px;
    }
}