/* Omni-CRM Design System 2025 */

:root {
    /* Color Palette */
    --primary: #3B86D1;
    --primary-hover: #2d6ba8;
    --success: #21BF06;
    --warning: #f59e0b;
    --error: #ef4444;
    --neutral: #6C7293;
    
    /* Neutral Grays */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Layout */
    --sidebar-width: 260px;
    --header-height: 60px;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --spacing-2xl: 4rem;
    
    /* Typography */
    --font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    /* Transitions */
    --transition: all 0.2s ease;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1f2937;
        --surface: #374151;
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
    }
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    line-height: 1;
}

.status-badge.pending { background: #fef3c7; color: #92400e; }
.status-badge.processing { background: #fed7aa; color: #9a3412; }
.status-badge.completed { background: #d1fae5; color: #065f46; }
.status-badge.cancelled, .status-badge.failed { background: #fee2e2; color: #991b1b; }
.status-badge.refunded { background: #e0e7ff; color: #3730a3; }

.status-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-badge.pending::before { content: '⏰'; width: auto; height: auto; }
.status-badge.processing::before { content: '⚙️'; width: auto; height: auto; }
.status-badge.completed::before { content: '✓'; width: auto; height: auto; }
.status-badge.cancelled::before, .status-badge.failed::before { content: '⚠️'; width: auto; height: auto; }

/* Metric Cards */
.metric-card {
    background: white;
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    transition: var(--transition);
}
.metric-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.metric-card.large { padding: var(--spacing-xl); }
.metric-value { font-size: var(--font-size-3xl); font-weight: 700; color: var(--gray-900); margin: var(--spacing-sm) 0; line-height: 1.2; }
.metric-label { font-size: var(--font-size-sm); color: var(--neutral); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.metric-trend { display: inline-flex; align-items: center; gap: 0.25rem; font-size: var(--font-size-sm); font-weight: 600; margin-top: var(--spacing-xs); }
.metric-trend.up { color: var(--success); }
.metric-trend.down { color: var(--error); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--border-radius);
    font-size: var(--font-size-base);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--error); color: white; }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }

/* Table Improvements */
.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: var(--border-radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.data-table th { background: var(--gray-50); padding: var(--spacing-md); text-align: left; font-weight: 600; font-size: var(--font-size-sm); color: var(--neutral); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 2px solid var(--gray-200); }
.data-table td { padding: var(--spacing-md); border-bottom: 1px solid var(--gray-200); color: var(--gray-700); }
.data-table tr:hover { background: var(--gray-50); }

/* Inline Filters */
.filter-header { display: flex; align-items: center; gap: 0.5rem; position: relative; }
.filter-input { padding: 0.375rem 0.75rem; border: 1px solid var(--gray-300); border-radius: var(--border-radius); font-size: var(--font-size-sm); width: 150px; }

/* Quick View Panel */
.quick-view-panel { position: fixed; right: 0; top: 0; width: 400px; height: 100vh; background: white; box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1); z-index: 1000; transform: translateX(100%); transition: transform 0.3s ease; overflow-y: auto; }
.quick-view-panel.open { transform: translateX(0); }

/* Notification Badge */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 0.375rem; background: var(--error); color: white; border-radius: 10px; font-size: var(--font-size-xs); font-weight: 700; margin-left: 0.5rem; }

/* Workbench Tabs */
.workbench-tabs { display: flex; gap: 0.5rem; border-bottom: 2px solid var(--gray-200); margin-bottom: var(--spacing-lg); }
.workbench-tab { padding: var(--spacing-sm) var(--spacing-md); background: none; border: none; border-bottom: 3px solid transparent; font-size: var(--font-size-base); font-weight: 600; color: var(--neutral); cursor: pointer; transition: var(--transition); position: relative; bottom: -2px; }
.workbench-tab:hover { color: var(--primary); }
.workbench-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.workbench-tab-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 0.5rem; background: var(--gray-200); color: var(--gray-700); border-radius: 12px; font-size: var(--font-size-xs); font-weight: 700; margin-left: 0.5rem; }
.workbench-tab.active .workbench-tab-badge { background: var(--primary); color: white; }

/* Stock Status Colors */
.stock-high { color: var(--success); font-weight: 600; }
.stock-medium { color: var(--warning); font-weight: 600; }
.stock-low { color: var(--error); font-weight: 600; }

/* Product Thumbnail */
.product-thumbnail { width: 40px; height: 40px; border-radius: var(--border-radius); object-fit: cover; border: 1px solid var(--gray-200); }

/* Utility Classes */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.text-neutral { color: var(--neutral); }
.bg-primary { background: var(--primary); }
.bg-success { background: var(--success); }
.bg-warning { background: var(--warning); }
.bg-error { background: var(--error); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }

/* ============================================================
   LAYOUT: Body, Sidebar, Main Content
   ============================================================ */

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    background: var(--gray-50);
    overflow-x: hidden;
}

/* ---- Desktop Sidebar (always visible >= 1025px) ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
    color: white;
    overflow-y: auto;
    z-index: 900;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    font-family: var(--font-family);
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

.sidebar .brand { display: flex; align-items: center; gap: 0.75rem; padding: 1.5rem 1.25rem; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.sidebar .brand-icon { font-size: 2rem; line-height: 1; }
.sidebar .brand-text { flex: 1; min-width: 0; }
.sidebar .brand-title { font-family: var(--font-family); font-size: 1.125rem; font-weight: 700; line-height: 1.2; color: white; }
.sidebar .brand-subtitle { font-family: var(--font-family); font-size: 0.75rem; color: rgba(255, 255, 255, 0.6); margin-top: 0.125rem; }

.sidebar .nav { padding: 0.5rem 0 1rem 0; }
.sidebar .nav-section { margin-bottom: 0.5rem; }
.sidebar .nav-section-title { padding: 1rem 1.25rem 0.5rem; font-family: var(--font-family); font-size: 0.625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255, 255, 255, 0.4); }

.sidebar .nav-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.625rem 1.25rem; color: rgba(255, 255, 255, 0.7); text-decoration: none; transition: all 0.2s ease; border-left: 3px solid transparent; margin: 0.125rem 0; }
.sidebar .nav-icon { font-size: 22px; line-height: 1; width: 1.5rem; text-align: center; }
.sidebar .nav-label { font-family: var(--font-family); font-size: 0.875rem; font-weight: 500; }
.sidebar .nav-item:hover { background: rgba(255, 255, 255, 0.08); color: white; border-left-color: rgba(255, 255, 255, 0.3); }
.sidebar .nav-item.active { background: rgba(59, 134, 209, 0.15); color: #60a5fa; border-left-color: #60a5fa; }
.sidebar .nav-item.active .nav-icon { transform: scale(1.1); }

.sidebar .nav-item-highlight { position: relative; }
.sidebar .nav-item-highlight::after { content: ''; position: absolute; right: 1.25rem; top: 50%; transform: translateY(-50%); width: 6px; height: 6px; background: #22c55e; border-radius: 50%; box-shadow: 0 0 8px #22c55e; }
.sidebar .nav-item-danger { color: rgba(239, 68, 68, 0.8); }
.sidebar .nav-item-danger:hover { background: rgba(239, 68, 68, 0.1); color: #ef4444; border-left-color: #ef4444; }

.sidebar .nav-section-bottom { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, 0.1); }

/* Close button inside sidebar — hidden on desktop */
.sidebar-close-btn {
    display: none;
}

/* ---- Main content ---- */
.main-content,
.main {
    margin-left: 260px;
    min-height: 100vh;
    padding: 2rem;
    transition: margin-left 0.3s ease;
}

/* ---- Mobile toggle button — hidden on desktop ---- */
.mobile-nav-toggle {
    display: none;
}

/* ---- Overlay — hidden on desktop ---- */
.sidebar-overlay {
    display: none;
}

/* ============================================================
   MOBILE / TABLET (max-width: 1024px)
   ============================================================ */
@media (max-width: 1024px) {

    /* Toggle button: always visible, always on top */
    .mobile-nav-toggle {
        display: flex;
        position: fixed;
        top: 0.75rem;
        left: 0.75rem;
        z-index: 1100;
        width: 40px;
        height: 40px;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        background: #ffffff;
        color: #1e293b;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
        cursor: pointer;
        font-size: 1.25rem;
        line-height: 1;
        -webkit-tap-highlight-color: transparent;
    }

    /* Overlay: covers entire screen behind sidebar */
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1200;
        background: rgba(15, 23, 42, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }

    body.mobile-sidebar-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }

    /* Sidebar: white drawer, slides in from left, ABOVE overlay */
    .sidebar {
        width: min(82vw, 320px);
        z-index: 1300;
        background: #ffffff;
        color: #1f2937;
        box-shadow: 8px 0 24px rgba(15, 23, 42, 0.18);
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

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

    /* White theme overrides for mobile sidebar */
    .sidebar .brand {
        padding: 1rem 1rem 0.85rem;
        border-bottom: 1px solid #edf2f7;
        background: #ffffff;
    }
    .sidebar .brand-title { color: #111827; font-size: 1rem; }
    .sidebar .brand-subtitle { color: #64748b; font-size: 0.75rem; }
    .sidebar .brand-icon { color: #4f46e5; }

    .sidebar-close-btn {
        display: inline-flex;
        border: 1px solid #e2e8f0;
        background: #f8fafc;
        color: #475569;
        width: 32px;
        height: 32px;
        border-radius: 8px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        margin-left: auto;
        font-size: 0.9rem;
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
    }

    .sidebar .nav { padding: 0.7rem 0.6rem 1rem; }
    .sidebar .nav-section { margin-bottom: 0.8rem; }
    .sidebar .nav-section-title { padding: 0.6rem 0.5rem 0.35rem; color: #94a3b8; font-size: 0.7rem; font-family: var(--font-family); }

    .sidebar .nav-item {
        color: #334155;
        border-left: none;
        border-radius: 10px;
        margin: 0.1rem 0;
        padding: 0.65rem 0.75rem;
        background: transparent;
    }
    .sidebar .nav-icon { color: #64748b; font-size: 1.25rem; }
    .sidebar .nav-label { font-size: 0.9rem; font-weight: 500; font-family: var(--font-family); }

    .sidebar .nav-item:hover { background: #f1f5f9; color: #0f172a; }
    .sidebar .nav-item.active { background: #eef2ff; color: #4338ca; }
    .sidebar .nav-item.active .nav-icon { color: #4f46e5; transform: none; }

    .sidebar .nav-section-bottom { margin-top: 1rem; border-top: 1px solid #edf2f7; padding-top: 0.8rem; }
    .sidebar .nav-item-danger { color: #dc2626; }
    .sidebar .nav-item-danger:hover { background: #fef2f2; color: #b91c1c; }

    .sidebar .nav-item-highlight::after { right: 0.8rem; background: #22c55e; }

    .sidebar::-webkit-scrollbar-track { background: #f1f5f9; }
    .sidebar::-webkit-scrollbar-thumb { background: #cbd5e1; }

    /* Main content: no sidebar offset */
    .main-content,
    .main,
    .pos-container {
        margin-left: 0 !important;
    }
}

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