/* Design System: WeBuy E-Commerce Platform (CRDB Bank Aesthetic) */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #f4f7f5; /* Light grey/green tint background */
    --bg-secondary: #ffffff; /* Solid White cards */
    --bg-tertiary: #e8efe9; /* Subtle grey-green hover backgrounds */
    --text-primary: #1e293b; /* Dark charcoal text */
    --text-secondary: #475569; /* Soft grey body text */
    --accent-primary: #215732; /* Everglade Dark Green (CRDB Primary) */
    --accent-secondary: #43B02A; /* Apple Light Green (CRDB Accent) */
    --accent-gradient: linear-gradient(135deg, #215732 0%, #43B02A 100%);
    --accent-gradient-hover: linear-gradient(135deg, #183e24 0%, #338520 100%);
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: #C1D6CC; /* Conch light grey-green border */
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.08);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.08);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.08);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.08);

    --border-radius-sm: 6px;
    --border-radius-md: 10px;
    --border-radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(33, 87, 50, 0.06);
    --shadow-lg: 0 10px 25px rgba(33, 87, 50, 0.12);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 13px; /* Compact font size like CRDB Bank */
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

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

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: var(--border-radius-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* Utility Classes */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.text-gradient {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Glassmorphism/Corporate Card */
.glass-card {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-md);
    padding: 20px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}
.glass-card:hover {
    border-color: var(--accent-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
    font-family: var(--font-family);
    font-size: 12px; /* Small fonts like CRDB */
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-align: center;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(33, 87, 50, 0.2);
}
.btn-primary:hover {
    background: var(--accent-gradient-hover);
    box-shadow: 0 4px 12px rgba(33, 87, 50, 0.4);
    transform: translateY(-0.5px);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}
.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: var(--success);
    color: #ffffff;
}
.btn-success:hover {
    background: #059669;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
    letter-spacing: 0.2px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 13px;
    transition: var(--transition);
}
.form-input:focus {
    outline: none;
    border-color: var(--accent-secondary);
    box-shadow: 0 0 0 3px rgba(67, 176, 42, 0.15);
}

.form-input[type="file"] {
    padding: 6px;
}

/* Auth Layout */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 30px 20px;
    background: radial-gradient(circle at 10% 20%, rgba(67, 176, 42, 0.05) 0%, transparent 40%),
                radial-gradient(circle at 90% 80%, rgba(33, 87, 50, 0.05) 0%, transparent 40%);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    animation: fadeIn 0.4s ease-out;
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-header h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Badges */
.badge {
    display: inline-flex;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

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

.badge-approved {
    background: var(--success-bg);
    color: var(--success);
}

.badge-rejected {
    background: var(--danger-bg);
    color: var(--danger);
}

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

/* Alerts */
.alert {
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 16px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.2s ease-out;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--accent-primary); /* Forest Green Sidebar like CRDB */
    color: #ffffff;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 10;
    overflow: hidden; /* Prevent entire sidebar from scrolling, only the menu inside */
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed sidebar: icon-only mode */
.sidebar.collapsed {
    width: 62px;
}
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-link span {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease, width 0.2s ease;
}
.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 20px 8px;
}
.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 11px 8px;
    gap: 0;
}
.sidebar.collapsed .sidebar-footer .sidebar-link {
    justify-content: center;
    padding: 11px 8px;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    transition: padding 0.3s ease;
}
.sidebar-link span,
.sidebar-brand span {
    transition: opacity 0.2s ease, width 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand {
    padding: 20px;
    font-size: 22px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.sidebar-menu {
    list-style: none;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
    overflow-y: auto; /* Scroll navigation links if viewport height is too small */
}

.sidebar-footer {
    flex-shrink: 0;
}

/* Youtube-style Top Progress Loading Bar */
#top-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: var(--accent-secondary);
    z-index: 99999;
    opacity: 0;
    transition: width 0.3s ease, opacity 0.2s ease;
    pointer-events: none;
}

/* Card thumbnails swapper on grid */
.card-thumbnails-carousel::-webkit-scrollbar {
    display: none;
}
.card-thumbnails-carousel {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.card-thumb-item:hover {
    border-color: var(--accent-primary) !important;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
    font-weight: 500;
}
.sidebar-link:hover, .sidebar-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-left: 3px solid var(--accent-secondary);
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.main-content {
    flex-grow: 1;
    margin-left: 240px;
    padding: 30px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.main-content.expanded {
    margin-left: 62px;
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    flex-shrink: 0;
    padding: 0;
}
.sidebar-toggle-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 16px;
}

.main-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-primary);
}

/* Dashboard Grid Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    padding: 20px;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 2px;
}

.stat-change {
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* Tables */
.table-responsive,
div[style*="overflow-x: auto"],
div[style*="overflow-x:auto"] {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin-top: 16px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

.table-responsive table,
div[style*="overflow-x: auto"] table,
div[style*="overflow-x:auto"] table {
    display: table !important;
    width: 100% !important;
    min-width: 800px !important;
}

.table th {
    padding: 12px;
    background: #f8faf9;
    border-bottom: 2px solid var(--glass-border);
    color: var(--text-secondary);
    font-weight: 600;
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-primary);
}

.table tr:hover td {
    background: var(--bg-primary);
}

/* Language Swapper Dropdown styling */
.lang-swapper {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}
.lang-btn {
    padding: 3px 6px;
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    cursor: pointer;
    background: var(--bg-secondary);
    font-weight: 500;
}
.lang-btn.active {
    background: var(--accent-primary);
    color: #ffffff;
    border-color: var(--accent-primary);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Mobile Sidebar styling */
@media (max-width: 768px) {
    .sidebar {
        left: -240px !important;
        width: 240px !important;
        box-shadow: none;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }
    
    .sidebar.mobile-open {
        left: 0 !important;
        box-shadow: 0 0 25px rgba(33, 87, 50, 0.25) !important;
    }
    
    .sidebar.mobile-open .sidebar-brand span,
    .sidebar.mobile-open .sidebar-link span,
    .sidebar.mobile-open .sidebar-footer span {
        display: inline-block !important;
        opacity: 1 !important;
        width: auto !important;
    }
    
    /* Make sure text is hidden by default if sidebar is not mobile-open on mobile */
    .sidebar:not(.mobile-open) .sidebar-brand span,
    .sidebar:not(.mobile-open) .sidebar-link span,
    .sidebar:not(.mobile-open) .sidebar-footer span {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 16px;
    }
    
    #sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 9;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
}

/* Collapsible Sidebar Styles */
.sidebar {
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar.collapsed {
    width: 68px !important;
}
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-footer span {
    display: none !important;
}
.sidebar.collapsed .sidebar-brand {
    padding: 20px 10px;
    text-align: center;
    font-size: 14px;
}
.sidebar.collapsed .sidebar-link {
    padding: 10px;
    justify-content: center;
}
.sidebar.collapsed .sidebar-menu {
    padding: 16px 8px;
}

.main-content {
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.main-content.expanded {
    margin-left: 68px !important;
}

/* Sidebar Hamburger Toggle Button */
.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}
.sidebar-toggle-btn:hover {
    background: var(--bg-tertiary);
}

/* Table Filtering & Search Utility Layout */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.table-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.search-box-container {
    position: relative;
    max-width: 260px;
    width: 100%;
}

.search-box-input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    font-size: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    transition: var(--transition);
}
.search-box-input:focus {
    outline: none;
    border-color: var(--accent-secondary);
}

.search-icon-inside {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
    display: flex;
    align-items: center;
}

/* Custom Table Export Button */
.btn-export {
    background: #e2ede8;
    color: var(--accent-primary);
    border: 1px solid var(--glass-border);
    padding: 6px 12px;
    font-size: 11px;
}
.btn-export:hover {
    background: var(--accent-secondary);
    color: #ffffff;
    border-color: var(--accent-secondary);
}

/* Tooltip & Popups */
.tooltip-container {
    position: relative;
    display: inline-block;
}
.tooltip-popup {
    visibility: hidden;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    text-align: center;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid var(--glass-border);
    font-size: 11px;
    box-shadow: var(--shadow-md);
    position: absolute;
    z-index: 100;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
}
.tooltip-container:hover .tooltip-popup {
    visibility: visible;
    opacity: 1;
}

/* Align Lucide Icons nicely inside buttons/links */
.sidebar-link i, .btn i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Product Grid 4 columns per row layout */
.product-grid-display {
    display: grid;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px;
    width: 100%;
}

@media (max-width: 1200px) {
    .product-grid-display {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}
@media (max-width: 768px) {
    .product-grid-display {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
@media (max-width: 480px) {
    .product-grid-display {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    .product-card-buttons {
        flex-direction: column !important;
        gap: 6px !important;
    }
    /* Product details modal mobile fixes */
    .product-details-card {
        width: 94% !important;
        max-height: 95vh !important;
    }
    .product-details-grid {
        padding: 16px !important;
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
}

/* Responsive Storefront Layout & Header utilities */
.storefront-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
    flex-grow: 1;
}

@media (max-width: 768px) {
    .storefront-layout {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }
    
    .top-utility-hide-mobile {
        display: none !important;
    }
    
    .header-middle-container {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        padding: 8px 0 !important;
    }
    
    .header-middle-logo {
        justify-content: center;
    }
    
    .sub-navbar-container {
        justify-content: flex-start !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 6px;
    }
    
    .sub-navbar-scrollable {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 16px !important;
    }
    
    .sub-navbar-scrollable a {
        display: inline-flex !important;
        flex-shrink: 0;
        align-items: center;
    }
    
    .sub-navbar-scrollable span {
        display: inline-block !important;
    }
    
    .header-support-hide-mobile {
        display: none !important;
    }
    
    /* Make Cart drawer fit nicely on mobile screens */
    #cart-drawer {
        width: 100% !important;
        max-width: 320px !important;
    }

    /* Dashboard Container & Content Mobile Responsiveness */
    .dashboard-container {
        display: block !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 16px !important;
        width: 100% !important;
        min-width: 0 !important;
        overflow-x: hidden !important;
    }
    /* Table overflow fix */
    .main-content table, 
    .container table {
        display: table !important;
        width: 100% !important;
    }

    /* Prevent glass-card from stretching beyond the viewport on mobile */
    .glass-card {
        min-width: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    /* Header adjustment */
    .main-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    .main-header > div:last-child {
        margin-right: 0 !important;
        text-align: left !important;
    }

    /* POS Page Mobile Responsiveness */
    .pos-layout-grid {
        grid-template-columns: 1fr !important;
        height: auto !important;
        gap: 16px !important;
    }
    .pos-layout-grid > div {
        height: 80vh !important;
    }

    /* Messages/Chat thread Mobile Responsiveness */
    .chat-layout-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }



    /* Affiliate Page Mobile Forms */
    .affiliate-flex-form {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 6px !important;
    }
    .affiliate-flex-form input {
        width: 100% !important;
        min-width: 0 !important;
    }
    .affiliate-flex-form button, 
    .affiliate-flex-form a {
        width: 100% !important;
    }
}



/* Flash Sale Pulse Animation */
@keyframes pulse-red {
    0%, 100% { color: var(--danger); opacity: 1; }
    50% { color: #ff6b6b; opacity: 0.75; }
}

/* Danger Button */
.btn-danger {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    color: #fff;
    border: 1px solid #c0392b;
}
.btn-danger:hover {
    background: linear-gradient(135deg, #a93226, #c0392b);
    transform: translateY(-1px);
}

/* Block-width button */
.btn-block {
    width: 100%;
    display: flex;
}

