/* === HACSTOR Master Unified Design System (Modern Light & Clean Slate Theme) === */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Cairo:wght@300;400;600;700;800&display=swap');

:root {
    /* --- Master Ice Slate Color Palette (No Harsh Whites, No Night Dark) --- */
    --bg-body: #eef2f6;                /* Soothing Ice Slate (Relieves eye strain) */
    --bg-surface: #ffffff;             /* Surface */
    --bg-card: #ffffff;                /* Card Surface */
    --bg-card-subtle: #f1f5f9;         /* Slate 100 */
    --bg-hover: #e2e8f0;               /* Slate 200 Hover */
    --bg-dark: #eef2f6;                /* Legacy alias redirected to ice slate */

    /* Typography Colors (High Contrast & Sharp Readability) */
    --text-main: #0f172a;              /* Slate 900 */
    --text-heading: #0f172a;           /* Deep Midnight Slate */
    --text-secondary: #334155;         /* Slate 700 */
    --text-muted: #64748b;             /* Slate 500 (Clean, not washed out) */

    /* Core Brand Accents */
    --primary-color: #0284c7;          /* Ice Cerulean / Royal Blue */
    --primary-dark: #0369a1;           /* Deep Ocean */
    --primary-light: #e0f2fe;          /* Soft Ice Blue Tint */
    
    --accent-orange: #f59e0b;          /* Automotive Amber */
    --accent-orange-dark: #d97706;     /* Deep Amber */
    --accent-orange-light: #fffbeb;
    
    --accent-success: #10b981;         /* Emerald */
    --accent-success-dark: #059669;
    --accent-success-light: #ecfdf5;

    --accent-danger: #ef4444;          /* Crimson Red */
    --accent-danger-dark: #dc2626;
    --accent-danger-light: #fef2f2;

    --accent-info: #0284c7;            /* Sky Blue */
    --accent-info-light: #f0f9ff;

    /* Borders & Outlines */
    --border-color: #dce4ed;           /* Soft Ice Border */
    --border-subtle: #eef2f6;          /* Subtlest divider */
    --border-input: #cbd5e1;           /* Slate 300 */
    --border-hover: #93c5fd;           /* Soft Blue Hover */
    --glass-border: 1px solid #dce4ed;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --shadow-card: 0 2px 10px rgba(15, 23, 42, 0.05);
    --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.15);

    --sidebar-width: 270px;
    --sidebar-collapsed-width: 80px;
    --transition-speed: 0.22s;
    --font-primary: 'Outfit', 'Plus Jakarta Sans', 'Cairo', sans-serif;
}

/* === Global Base Styles === */
body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
    line-height: 1.6;
    min-height: 100vh;
    background-image: 
        radial-gradient(circle at 10% 10%, rgba(37, 99, 235, 0.03) 0%, transparent 25%),
        radial-gradient(circle at 90% 90%, rgba(245, 158, 11, 0.03) 0%, transparent 25%);
}

/* Typography Headings */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-heading) !important;
    font-weight: 700;
    letter-spacing: -0.02em;
}

p {
    color: var(--text-secondary);
}

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

/* Override text-white safely on light backgrounds so text never vanishes */
.text-white:not(.btn):not(.btn *):not(.badge):not(.badge *):not(.bg-primary *):not(.bg-danger *):not(.bg-success *):not(.bg-dark *):not(.store-footer-glass *):not(.alert *):not(.dropdown-menu.bg-dark *) {
    color: #0f172a !important;
}

.text-white-50:not(.btn):not(.btn *):not(.badge):not(.badge *):not(.store-footer-glass *):not(.bg-primary *):not(.bg-danger *):not(.bg-dark *) {
    color: #64748b !important;
}

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

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

/* === Global Custom Scrollbar (Light Modern) === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* === Cards & Surfaces === */
.card, .glass-card {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 14px;
    box-shadow: var(--shadow-card) !important;
    transition: all var(--transition-speed) ease;
}

.card:hover, .glass-card:hover {
    box-shadow: var(--shadow-md) !important;
}

.card-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    font-weight: 700;
    color: var(--text-heading);
}

.card-footer {
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

/* ==========================================================================
   === MASTER BUTTON SYSTEM: 100% EXPLICIT CONTRAST & LEGIBILITY ===
   ========================================================================== */
.btn {
    font-weight: 600;
    border-radius: 8px;
    padding: 0.55rem 1.15rem;
    font-size: 0.92rem;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    line-height: 1.4;
}

/* --- Solid Primary Button --- */
.btn-primary {
    background-color: #2563eb !important;
    border: 1px solid #2563eb !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: #1d4ed8 !important;
    border-color: #1d4ed8 !important;
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

/* --- Outline Primary Button --- */
.btn-outline-primary {
    background-color: #eff6ff !important;
    border: 1px solid #93c5fd !important;
    color: #1d4ed8 !important;
}
.btn-outline-primary:hover, .btn-outline-primary:active {
    background-color: #2563eb !important;
    border-color: #2563eb !important;
    color: #ffffff !important;
    transform: translateY(-1px);
}

/* --- Solid Secondary Button --- */
.btn-secondary {
    background-color: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: #334155 !important;
}
.btn-secondary:hover {
    background-color: #e2e8f0 !important;
    border-color: #94a3b8 !important;
    color: #0f172a !important;
}

/* --- Outline Secondary Button --- */
.btn-outline-secondary {
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #475569 !important;
}
.btn-outline-secondary:hover, .btn-outline-secondary.active {
    background-color: #f1f5f9 !important;
    border-color: #94a3b8 !important;
    color: #0f172a !important;
}

/* --- Solid Info Button --- */
.btn-info {
    background-color: #0284c7 !important;
    border: 1px solid #0369a1 !important;
    color: #ffffff !important;
}
.btn-info:hover {
    background-color: #0369a1 !important;
    border-color: #075985 !important;
    color: #ffffff !important;
}

/* --- Outline Info Button (Fix for the invisible text issue) --- */
.btn-outline-info {
    background-color: #f0f9ff !important;
    border: 1px solid #7dd3fc !important;
    color: #0369a1 !important;
    font-weight: 600;
}
.btn-outline-info:hover {
    background-color: #0284c7 !important;
    border-color: #0284c7 !important;
    color: #ffffff !important;
    transform: translateY(-1px);
}

/* --- Solid Success Button --- */
.btn-success {
    background-color: #16a34a !important;
    border: 1px solid #15803d !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.25);
}
.btn-success:hover {
    background-color: #15803d !important;
    border-color: #166534 !important;
    color: #ffffff !important;
    transform: translateY(-1px);
}

/* --- Outline Success Button --- */
.btn-outline-success {
    background-color: #f0fdf4 !important;
    border: 1px solid #86efac !important;
    color: #15803d !important;
    font-weight: 600;
}
.btn-outline-success:hover {
    background-color: #16a34a !important;
    border-color: #16a34a !important;
    color: #ffffff !important;
    transform: translateY(-1px);
}

/* --- Solid Warning Button --- */
.btn-warning {
    background-color: #f59e0b !important;
    border: 1px solid #d97706 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.25);
}
.btn-warning:hover {
    background-color: #d97706 !important;
    border-color: #b45309 !important;
    color: #ffffff !important;
}

/* --- Outline Warning Button --- */
.btn-outline-warning {
    background-color: #fffbeb !important;
    border: 1px solid #fcd34d !important;
    color: #b45309 !important;
    font-weight: 600;
}
.btn-outline-warning:hover {
    background-color: #f59e0b !important;
    border-color: #f59e0b !important;
    color: #ffffff !important;
}

/* --- Solid Danger Button --- */
.btn-danger {
    background-color: #dc2626 !important;
    border: 1px solid #b91c1c !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.25);
}
.btn-danger:hover {
    background-color: #b91c1c !important;
    border-color: #991b1b !important;
    color: #ffffff !important;
}

/* --- Outline Danger Button --- */
.btn-outline-danger {
    background-color: #fef2f2 !important;
    border: 1px solid #fca5a5 !important;
    color: #b91c1c !important;
    font-weight: 600;
}
.btn-outline-danger:hover {
    background-color: #dc2626 !important;
    border-color: #dc2626 !important;
    color: #ffffff !important;
}

/* --- Outline Light Button (Critical: ensure dark text on light background) --- */
.btn-outline-light {
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #334155 !important;
}
.btn-outline-light:hover {
    background-color: #f8fafc !important;
    border-color: #94a3b8 !important;
    color: #0f172a !important;
}

/* --- Solid Dark Button --- */
.btn-dark {
    background-color: #0f172a !important;
    border: 1px solid #0f172a !important;
    color: #ffffff !important;
}
.btn-dark:hover {
    background-color: #1e293b !important;
    border-color: #1e293b !important;
    color: #ffffff !important;
}

/* --- Brand Orange Gradient Button --- */
.btn-brand-orange {
    background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%) !important;
    color: #ffffff !important;
    border: none !important;
    font-weight: 700;
    box-shadow: 0 3px 10px rgba(234, 88, 12, 0.25);
}
.btn-brand-orange:hover {
    background: linear-gradient(135deg, #fbbf24 0%, #f97316 100%) !important;
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(234, 88, 12, 0.35);
}

/* --- Text / Link Button --- */
.btn-link {
    color: #2563eb !important;
    text-decoration: none !important;
}
.btn-link:hover {
    color: #1d4ed8 !important;
    text-decoration: underline !important;
}

/* ==========================================================================
   === FORMS, INPUTS & CONTROLS ===
   ========================================================================== */
label {
    color: #334155 !important;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}

.form-control,
.form-select,
.input-group-text,
.form-control-glass,
.form-select-glass {
    background-color: #ffffff !important;
    border: 1px solid var(--border-input) !important;
    color: #0f172a !important;
    border-radius: 8px;
    padding: 0.65rem 0.95rem;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.form-control::placeholder,
.search-input::placeholder {
    color: #94a3b8 !important;
    opacity: 1;
}

.form-control:focus,
.form-select:focus,
.form-control-glass:focus,
.form-select-glass:focus {
    background-color: #ffffff !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
    color: #0f172a !important;
    outline: none;
}

.input-group-text {
    background-color: #f8fafc !important;
    border-color: var(--border-input) !important;
    color: #64748b !important;
}

/* Normalize residual dark classes inside forms and inputs */
input.bg-dark, select.bg-dark, .input-group-text.bg-dark {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border-color: var(--border-input) !important;
}

.search-input-glass {
    background-color: #ffffff !important;
    border: 1px solid var(--border-input) !important;
    color: #0f172a !important;
    border-radius: 50px;
    box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   === TABLES ===
   ========================================================================== */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: #1e293b;
    --bs-table-border-color: var(--border-color);
}

.table thead th,
.table-glass thead th {
    background-color: #f8fafc !important;
    color: #475569 !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 0.9rem 1rem;
}

.table tbody td,
.table-glass tbody td {
    padding: 0.9rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9 !important;
    color: #1e293b !important;
}

.table tbody tr:hover,
.table-glass tbody tr:hover {
    background-color: #f8fafc !important;
}

/* ==========================================================================
   === MODALS & DIALOGS ===
   ========================================================================== */
.modal-content,
.modal-glass .modal-content {
    background: #ffffff !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15) !important;
    color: #0f172a !important;
}

.modal-header {
    border-bottom: 1px solid var(--border-color) !important;
    padding: 1.25rem 1.5rem;
}

.modal-title {
    color: #0f172a !important;
    font-weight: 700;
}

.modal-footer {
    border-top: 1px solid var(--border-color) !important;
    padding: 1rem 1.5rem;
}

.btn-close-white {
    filter: none !important;
}

/* ==========================================================================
   === ERP / ADMIN SIDEBAR (Clean Luminous White) ===
   ========================================================================== */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 20px 0;
    box-shadow: 2px 0 15px rgba(15, 23, 42, 0.04);
    background: #ffffff !important;
    border-right: 1px solid var(--border-color) !important;
    width: var(--sidebar-width);
    transition: transform var(--transition-speed) ease;
    overflow-y: auto;
}

.brand-section {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    text-align: center;
}

.brand-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #0f172a !important;
    background: none !important;
    -webkit-text-fill-color: initial !important;
}

.brand-title span {
    color: var(--primary-color) !important;
    -webkit-text-fill-color: var(--primary-color) !important;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 10px 18px;
    color: #475569 !important;
    font-weight: 600;
    font-size: 0.93rem;
    border-radius: 8px;
    margin: 3px 12px;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.sidebar .nav-link i {
    width: 24px;
    margin-right: 12px;
    font-size: 1.05rem;
    color: #64748b;
    transition: transform 0.2s;
}

.sidebar .nav-link:hover {
    color: #0f172a !important;
    background: #f1f5f9 !important;
}

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

.sidebar .nav-link.active {
    color: #1d4ed8 !important;
    background: #eff6ff !important;
    border-left-color: #2563eb !important;
    font-weight: 700;
}

.sidebar .nav-link.active i {
    color: #2563eb !important;
    transform: scale(1.1);
}

/* Sidebar Collapsed State (Desktop) */
@media (min-width: 769px) {
    .sidebar.collapsed {
        width: var(--sidebar-collapsed-width);
    }
    .sidebar.collapsed .brand-title span, 
    .sidebar.collapsed .brand-title {
        display: none;
    }
    .sidebar.collapsed .brand-section {
        padding: 0 10px 12px;
    }
    .sidebar.collapsed .brand-title::before {
        content: "\f2dc";
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        font-size: 24px;
        color: var(--primary-color);
        display: block;
    }
    .sidebar.collapsed .text-muted.small.letter-spacing-2 {
        display: none !important;
    }
    .sidebar.collapsed .nav-link {
        padding: 12px;
        justify-content: center;
        border-radius: 8px;
        margin: 4px 10px;
        border-left: none;
    }
    .sidebar.collapsed .nav-link span {
        display: none;
    }
    .sidebar.collapsed .nav-link i {
        margin-right: 0;
        font-size: 1.3rem;
    }
    .sidebar.collapsed .nav-item span.text-uppercase {
        display: none;
    }
    
    .main-content.collapsed {
        margin-left: var(--sidebar-collapsed-width);
    }
}

.main-content {
    margin-left: var(--sidebar-width);
    padding: 2rem;
    transition: margin-left var(--transition-speed);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.4);
        backdrop-filter: blur(2px);
        z-index: 99;
        display: none;
    }
    .overlay.active {
        display: block;
    }
}

/* ==========================================================================
   === STOREFRONT (Modern Crisp Clean Theme) ===
   ========================================================================== */

/* Storefront Navbar */
.store-navbar-glass {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}

.store-navbar-glass .nav-link {
    color: #334155 !important;
    font-weight: 600;
}
.store-navbar-glass .nav-link:hover {
    color: var(--primary-color) !important;
}

/* Storefront Search Bar */
.store-search-bar {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 50px;
    overflow: hidden;
    transition: all 0.2s ease;
}
.store-search-bar:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    background: #ffffff;
}
.store-search-bar input {
    background: transparent !important;
    border: none !important;
    color: #0f172a !important;
}
.store-search-bar input::placeholder {
    color: #94a3b8 !important;
}

/* Modern Product Card */
.product-card-modern {
    background: #ffffff !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-sm);
}
.product-card-modern:hover {
    transform: translateY(-4px);
    border-color: #93c5fd !important;
    box-shadow: var(--shadow-lg);
}

/* Product Image Box */
.product-image-box {
    background: #f8fafc;
    border-radius: 10px;
    height: 190px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 1rem;
    overflow: hidden;
    border: 1px solid #f1f5f9;
}
.product-image-box img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    transition: transform 0.25s ease;
}
.product-card-modern:hover .product-image-box img {
    transform: scale(1.05);
}

/* Badges System */
.badge {
    padding: 0.45em 0.75em;
    font-weight: 600;
    border-radius: 6px;
}

.badge-stock-in {
    background: #ecfdf5 !important;
    color: #047857 !important;
    border: 1px solid #a7f3d0 !important;
    font-weight: 700;
}
.badge-stock-out {
    background: #fef2f2 !important;
    color: #b91c1c !important;
    border: 1px solid #fecaca !important;
    font-weight: 700;
}
.badge-wholesaler {
    background: #fffbeb !important;
    color: #b45309 !important;
    border: 1px solid #fde68a !important;
    font-weight: 700;
}

/* Breadcrumb */
.breadcrumb-glass {
    background: #ffffff !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 50px;
    padding: 0.6rem 1.4rem;
    box-shadow: var(--shadow-sm);
}

/* Storefront Footer (Clean Rich Slate Footer) */
.store-footer-glass {
    background: #0f172a !important;
    border-top: 1px solid #1e293b;
    color: #cbd5e1;
    position: relative;
}
.store-footer-glass h6, 
.store-footer-glass strong {
    color: #ffffff !important;
}
.store-footer-glass a {
    color: #94a3b8;
}
.store-footer-glass a:hover {
    color: #ffffff;
}

/* Typeahead / Suggestions Box */
.suggestions-box { 
    position: absolute; top: 100%; left: 0; width: 100%; min-width: 450px; 
    background: #ffffff; border: 1px solid var(--border-color); 
    border-radius: 10px; z-index: 1000; max-height: 350px; overflow-y: auto; display: none; 
    box-shadow: var(--shadow-lg); padding: 6px;
}
.suggestion-item { 
    padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #f1f5f9; color: #1e293b; 
    display: flex; justify-content: space-between; align-items: center; border-radius: 6px; transition: all 0.2s; 
}
.suggestion-item:hover, .suggestion-item.active { 
    background-color: #eff6ff; color: #1d4ed8; 
}
.suggestion-item strong { 
    display: block; font-size: 1.05em; color: var(--primary-color); 
}

/* Dropdown Menus */
.dropdown-menu {
    background-color: #ffffff !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-lg) !important;
    border-radius: 10px;
}
.dropdown-item {
    color: #334155 !important;
    font-weight: 500;
}
.dropdown-item:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}
.dropdown-divider {
    border-color: var(--border-color) !important;
}

/* Compact Mode */
.compact-mode .grid-table td, 
.compact-mode .grid-table th {
    padding: 0.3rem !important;
}
.compact-mode .cell-input {
    height: 32px !important;
    font-size: 0.9rem !important;
}
.compact-mode .form-check-label {
    font-size: 0.85rem !important;
}
.compact-mode .btn {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.875rem !important;
}
.compact-mode .suggestion-item {
    padding: 6px 12px;
}