/* =====================================================
   MPProfit - Xintra-Inspired Dark Sidebar Theme
   Modern SaaS Design with Dark Menu
   ===================================================== */

:root {
    /* Primary Brand - Blue */
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-lighter: #60a5fa;
    --primary-dark: #1d4ed8;
    --primary-50: #eff6ff;
    
    /* Secondary - Slate */
    --secondary: #64748b;
    --secondary-light: #94a3b8;
    --secondary-dark: #475569;
    
    /* Accent Colors */
    --success: #10b981;
    --success-light: #34d399;
    --success-bg: #d1fae5;
    
    --danger: #ef4444;
    --danger-light: #f87171;
    --danger-bg: #fee2e2;
    
    --warning: #f59e0b;
    --warning-light: #fbbf24;
    --warning-bg: #fef3c7;
    
    --info: #06b6d4;
    --info-light: #22d3ee;
    --info-bg: #cffafe;
    
    /* Marketplace Colors */
    --wb-color: #ffb800;
    --ozon-color: #005bff;
    
    /* Neutrals */
    --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;
    
    /* Sidebar Colors - Dark Theme */
    --sidebar-bg: #1e2e4a;
    --sidebar-hover: #2a3f5f;
    --sidebar-active: #3d5a80;
    --sidebar-text: #cbd5e1;
    --sidebar-text-muted: #94a3b8;
    --sidebar-border: rgba(255, 255, 255, 0.08);
    
    /* Background */
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #fafbfc;
    
    /* Layout */
    --sidebar-width: 280px;
    --header-height: 72px;
    
    /* Effects */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
}

/* =====================================================
   Base Styles
   ===================================================== */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    font-size: 14px;
    color: var(--gray-700);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse 100% 100% at 0% 0%, rgba(37, 99, 235, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse 100% 100% at 100% 100%, rgba(6, 182, 212, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* =====================================================
   Layout
   ===================================================== */

.wrapper {
    display: flex;
    min-height: 100vh;
}

/* =====================================================
   Sidebar - Dark Theme (Xintra Style)
   ===================================================== */

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform var(--transition-slow);
}

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

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

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
    background: var(--sidebar-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-header h4 {
    color: var(--white);
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.sidebar-header h4 i {
    color: var(--primary-light);
    font-size: 1.5rem;
}

.sidebar .nav {
    padding: 1rem 0.75rem;
}

.sidebar .nav-item {
    margin-bottom: 0.25rem;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all var(--transition-base);
    font-weight: 500;
    font-size: 0.9rem;
    text-decoration: none;
}

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

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

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

.sidebar .nav-link i {
    font-size: 1.125rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: var(--sidebar-text-muted);
    transition: color var(--transition-base);
}

.sidebar .nav-link:hover i {
    color: var(--white);
}

/* =====================================================
   Main Content
   ===================================================== */

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

/* =====================================================
   Header
   ===================================================== */

.header {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.btn-toggle-sidebar {
    background: none;
    border: 1px solid var(--gray-200);
    font-size: 1.25rem;
    color: var(--gray-600);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.content {
    padding: 1.5rem 2rem;
    flex: 1;
}

/* =====================================================
   Cards - Modern Xintra Style
   ===================================================== */

.card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    background: var(--white);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--gray-300);
}

.card-header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-100);
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.9375rem;
}

.card-body {
    padding: 1.25rem;
    color: var(--gray-700);
}

/* =====================================================
   Metric Cards - Xintra Style with Colored Icons
   ===================================================== */

.metric-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--gray-300);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    flex-shrink: 0;
}

.metric-orders .metric-icon {
    background: var(--primary-50);
    color: var(--primary);
}

.metric-orders::before {
    background: var(--primary);
}

.metric-sales .metric-icon {
    background: var(--success-bg);
    color: var(--success);
}

.metric-sales::before {
    background: var(--success);
}

.metric-revenue .metric-icon {
    background: var(--info-bg);
    color: var(--info);
}

.metric-revenue::before {
    background: var(--info);
}

.metric-profit .metric-icon {
    background: var(--warning-bg);
    color: var(--warning);
}

.metric-profit::before {
    background: var(--warning);
}

.metric-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.metric-label {
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.metric-change {
    font-size: 0.8125rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.375rem;
}

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

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

/* =====================================================
   Tables
   ===================================================== */

.table {
    font-size: 0.875rem;
    color: var(--gray-700);
}

.table thead th {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    color: var(--gray-600);
    padding: 0.875rem 1rem;
    white-space: nowrap;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-100);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

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

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

/* =====================================================
   Status Badges
   ===================================================== */

.badge-status {
    padding: 0.3125rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.badge-delivered {
    background: var(--success-bg);
    color: #047857;
}

.badge-pending {
    background: var(--warning-bg);
    color: #b45309;
}

.badge-cancelled {
    background: var(--danger-bg);
    color: #b91c1c;
}

.badge-processing {
    background: var(--info-bg);
    color: #0e7490;
}

/* Marketplace Badges */
.badge-wb {
    background: rgba(255, 184, 0, 0.15);
    color: #b8860b;
}

.badge-ozon {
    background: rgba(0, 91, 255, 0.1);
    color: var(--ozon-color);
}

/* =====================================================
   Form Controls
   ===================================================== */

.form-select,
.form-control {
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    padding: 0.5rem 2.5rem 0.5rem 0.875rem;
    color: var(--gray-700);
    transition: all var(--transition-base);
    font-weight: 500;
}

.form-select:focus,
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
    color: var(--gray-900);
}

.form-select option {
    background: var(--white);
    color: var(--gray-700);
}

.form-control::placeholder {
    color: var(--gray-400);
}

/* =====================================================
   Buttons
   ===================================================== */

.btn {
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

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

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-outline-secondary {
    color: var(--gray-600);
    border-color: var(--gray-300);
    background: var(--white);
}

.btn-outline-secondary:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
    color: var(--gray-800);
}

.btn-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

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

.btn-group .btn {
    border-radius: 0;
}

.btn-group .btn:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.btn-group .btn:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

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

/* =====================================================
   Charts Container
   ===================================================== */

.chart-container {
    position: relative;
    height: 300px;
}

/* =====================================================
   Stats Grid
   ===================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: all var(--transition-base);
}

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

.stat-box-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    font-size: 1.25rem;
    background: var(--primary-50);
    color: var(--primary);
}

.stat-box-value {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
    margin-bottom: 0.375rem;
    letter-spacing: -0.02em;
}

.stat-box-label {
    font-size: 0.8125rem;
    color: var(--gray-500);
    font-weight: 500;
}

.stat-box-change {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

/* =====================================================
   Navigation Tabs
   ===================================================== */

.nav-tabs {
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 1.5rem;
}

.nav-tabs .nav-link {
    border: none;
    color: var(--gray-500);
    padding: 0.75rem 1.25rem;
    font-weight: 500;
    position: relative;
    transition: all var(--transition-base);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.nav-tabs .nav-link:hover {
    color: var(--gray-700);
    background: var(--gray-50);
    border: none;
}

.nav-tabs .nav-link.active {
    color: var(--primary);
    background: var(--white);
    border: none;
    font-weight: 600;
}

.nav-tabs .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

/* =====================================================
   Page Header
   ===================================================== */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.page-title {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
    letter-spacing: -0.02em;
}

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

/* =====================================================
   Filters Bar
   ===================================================== */

.filters-bar {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* =====================================================
   Progress Bars
   ===================================================== */

.progress {
    background: var(--gray-200);
    border-radius: var(--radius-full);
    height: 8px;
    overflow: hidden;
}

.progress-bar {
    border-radius: var(--radius-full);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-bar.bg-primary {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.progress-bar.bg-success {
    background: linear-gradient(90deg, var(--success), var(--success-light));
}

.progress-bar.bg-warning {
    background: linear-gradient(90deg, var(--warning), var(--warning-light));
}

.progress-bar.bg-danger {
    background: linear-gradient(90deg, var(--danger), var(--danger-light));
}

/* =====================================================
   Empty State
   ===================================================== */

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* =====================================================
   Pagination
   ===================================================== */

.pagination {
    margin: 0;
}

.page-link {
    color: var(--gray-600);
    background: var(--white);
    border-color: var(--gray-200);
    border-radius: var(--radius-md);
    margin: 0 0.125rem;
    padding: 0.375rem 0.75rem;
    font-weight: 500;
    transition: all var(--transition-base);
}

.page-link:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
    color: var(--gray-800);
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.page-item.disabled .page-link {
    background: var(--gray-100);
    border-color: var(--gray-200);
    color: var(--gray-400);
}

/* =====================================================
   Search Box
   ===================================================== */

.search-box {
    position: relative;
}

.search-box input {
    padding-left: 2.5rem;
}

.search-box i {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

/* =====================================================
   Modal
   ===================================================== */

.modal-content {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

.modal-header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-900);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 1.25rem 1.5rem;
    font-weight: 600;
}

.modal-header .btn-close {
    opacity: 0.5;
}

.modal-header .btn-close:hover {
    opacity: 1;
}

/* =====================================================
   Dropdown Menu
   ===================================================== */

.dropdown-menu {
    background: var(--white);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    min-width: 180px;
}

.dropdown-item {
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    color: var(--gray-700);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    font-weight: 500;
}

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

/* =====================================================
   List Group
   ===================================================== */

.list-group-item {
    background: var(--white);
    border-color: var(--gray-200);
    color: var(--gray-700);
    padding: 0.875rem 1.25rem;
}

.list-group-item.active {
    background: var(--primary-50);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

/* =====================================================
   Notification Container
   ===================================================== */

.notification-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    max-width: 380px;
}

.notification {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    font-size: 0.875rem;
}

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

.notification-success {
    background: var(--success-bg);
    color: #047857;
    border: 1px solid #a7f3d0;
}

.notification-error {
    background: var(--danger-bg);
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.notification-warning {
    background: var(--warning-bg);
    color: #b45309;
    border: 1px solid #fde68a;
}

.notification-info {
    background: var(--info-bg);
    color: #0e7490;
    border: 1px solid #a5f3fc;
}

.notification i {
    font-size: 1.125rem;
    flex-shrink: 0;
}

/* =====================================================
   Loading Spinner
   ===================================================== */

.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
}

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

/* =====================================================
   ABC Analysis Colors
   ===================================================== */

.abc-a {
    background: var(--success-bg);
    color: #047857;
    border: 1px solid #a7f3d0;
}

.abc-b {
    background: var(--warning-bg);
    color: #b45309;
    border: 1px solid #fde68a;
}

.abc-c {
    background: var(--danger-bg);
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* =====================================================
   Scrollbar Styles
   ===================================================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

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

/* =====================================================
   Overlay for Mobile
   ===================================================== */

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

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

/* =====================================================
   Stat Card (legacy)
   ===================================================== */

.stat-card {
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Spin animation utility */
.spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}

/* =====================================================
   Sync Button Loading State
   ===================================================== */

#syncBtn.loading {
    pointer-events: none;
    opacity: 0.7;
}

#syncBtn.loading i {
    display: inline-block;
    animation: spin 1s linear infinite;
}

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

/* =====================================================
   Responsive Design
   ===================================================== */

@media (max-width: 1199.98px) {
    .metric-card {
        padding: 1.125rem;
    }
    
    .metric-icon {
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
    }
    
    .metric-value {
        font-size: 1.375rem;
    }
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .btn-toggle-sidebar {
        display: flex;
    }
    
    .content {
        padding: 1.25rem;
    }
    
    .header {
        padding: 0 1.25rem;
    }
}

@media (max-width: 767.98px) {
    .metric-card {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .metric-icon {
        width: 40px;
        height: 40px;
        font-size: 1.125rem;
    }
    
    .metric-value {
        font-size: 1.25rem;
    }
    
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-group .form-select,
    .filter-group .form-control {
        width: 100%;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 575.98px) {
    .content {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .card-header {
        padding: 0.875rem 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Navbar adjustments */
    .navbar .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* Prevent btn-group overflow */
    .btn-group {
        flex-wrap: wrap;
    }

    /* Page header stacks on mobile */
    .row.mb-4.align-items-center > .col-auto {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Ensure container-fluid doesn't add excessive padding on mobile */
@media (max-width: 767.98px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Shrink page titles */
    h2.mb-0 {
        font-size: 1.375rem;
    }

    /* Make all cards allow horizontal scroll for tables */
    .card {
        overflow: visible;
    }

    /* Make card-body a scroll container for tables */
    .card-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Keep table cells from wrapping — forces horizontal scroll */
    .card-body .table th,
    .card-body .table td {
        white-space: nowrap;
    }

    /* Restore card border-radius clipping for header/footer */
    .card-header,
    .card-footer {
        overflow: hidden;
    }
}

/* =====================================================
   Animations
   ===================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
    opacity: 0;
}

.animate-fade-in:nth-child(1) { animation-delay: 0ms; }
.animate-fade-in:nth-child(2) { animation-delay: 50ms; }
.animate-fade-in:nth-child(3) { animation-delay: 100ms; }
.animate-fade-in:nth-child(4) { animation-delay: 150ms; }
.animate-fade-in:nth-child(5) { animation-delay: 200ms; }
.animate-fade-in:nth-child(6) { animation-delay: 250ms; }

/* =====================================================
   Utility Classes
   ===================================================== */

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

.text-muted {
    color: var(--gray-500) !important;
}

.text-success {
    color: var(--success) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-primary {
    color: var(--primary) !important;
}

/* =====================================================
   Stats in Cards
   ===================================================== */

.conversion-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.conversion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversion-label {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.conversion-value {
    font-weight: 600;
    color: var(--gray-900);
}

.conversion-progress {
    margin-top: 0.5rem;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* =====================================================
   Rating Stats
   ===================================================== */

.rating-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rating-item {
    display: flex;
    flex-direction: column;
}

/* =====================================================
   Inventory Stats
   ===================================================== */

.inventory-stats {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.inventory-item {
    padding: 0.375rem 0;
}

.inventory-item .text-success { color: var(--success) !important; }
.inventory-item .text-primary { color: var(--info) !important; }
.inventory-item .text-warning { color: var(--warning) !important; }
.inventory-item .text-danger { color: var(--danger) !important; }

/* =====================================================
   Additional Elements
   ===================================================== */

hr {
    border: none;
    height: 1px;
    background: var(--gray-200);
    margin: 1rem 0;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive::-webkit-scrollbar {
    width: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: var(--gray-100);
}

.table-responsive::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

/* Tooltip */
.tooltip-inner {
    background: var(--gray-800);
    border-radius: var(--radius-sm);
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
}

/* Page title in header */
.header h5 {
    color: var(--gray-900);
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Dropdown toggle arrow */
.dropdown-toggle::after {
    border: none;
    content: '\f282';
    font-family: 'bootstrap-icons';
    vertical-align: middle;
    margin-left: 0.375rem;
    font-size: 0.75rem;
}

/* Chart canvas */
canvas {
    max-width: 100%;
}

/* User avatar in header */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-50);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}
