/* ============================================================
   KILO WHOLESALE - Design System
   Premium dark theme with glassmorphism
   ============================================================ */

/* ---------- Google Font ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---------- CSS Custom Properties ---------- */
:root {
    /* Primary palette */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.3);

    /* Accent colors */
    --accent-green: #10b981;
    --accent-green-light: #34d399;
    --accent-red: #f43f5e;
    --accent-red-light: #fb7185;
    --accent-amber: #f59e0b;
    --accent-amber-light: #fbbf24;
    --accent-blue: #3b82f6;

    /* Background layers */
    --bg-body: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.8);
    --bg-card-solid: #1e293b;
    --bg-input: rgba(15, 23, 42, 0.6);
    --bg-hover: rgba(99, 102, 241, 0.08);
    --bg-surface: #334155;

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;

    /* Borders */
    --border-color: rgba(148, 163, 184, 0.12);
    --border-light: rgba(148, 163, 184, 0.06);

    /* Glassmorphism */
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(148, 163, 184, 0.15);
    --glass-blur: blur(20px);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);

    /* Spacing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --header-height: 64px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

body.has-sidebar {
    display: flex;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--primary); }

img { max-width: 100%; height: auto; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
}
h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform var(--transition-slow);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    min-height: var(--header-height);
}

.sidebar-brand .brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}

.sidebar-nav .nav-section {
    margin-bottom: 24px;
}

.sidebar-nav .nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    position: relative;
    cursor: pointer;
}

.sidebar-nav a.nav-item {
    text-decoration: none;
}

.sidebar-logout-form {
    margin-top: 12px;
}

.sidebar-logout-button {
    width: 100%;
    border: 0;
    background: transparent;
    font-family: inherit;
    text-align: inherit;
}

.sidebar-logout-button.nav-item {
    color: var(--accent-red-light);
}

.sidebar-nav .nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-nav .nav-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(99, 102, 241, 0.05));
    color: var(--primary-light);
}

.sidebar-nav .nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: var(--radius-full);
}

.sidebar-nav .nav-item .nav-icon {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav .nav-submenu {
    margin: 2px 0;
}

.sidebar-nav .nav-submenu summary {
    list-style: none;
}

.sidebar-nav .nav-submenu summary::-webkit-details-marker {
    display: none;
}

.sidebar-nav .nav-submenu-toggle {
    width: 100%;
}

.sidebar-nav .nav-submenu-toggle .nav-chevron {
    width: 16px;
    height: 16px;
    margin-left: auto;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.sidebar-nav .nav-submenu[open] .nav-chevron {
    transform: rotate(180deg);
}

.sidebar-nav .nav-submenu-items {
    display: grid;
    gap: 2px;
    margin: 4px 0 6px;
    padding-inline-start: 36px;
}

.sidebar-nav .nav-subitem {
    display: block;
    padding: 7px 10px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.35;
    text-decoration: none;
}

.sidebar-nav .nav-subitem:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-nav .nav-subitem.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
}

[dir="rtl"] .sidebar-nav .nav-submenu-toggle .nav-chevron {
    margin-right: auto;
    margin-left: 0;
}

.sidebar-nav .nav-badge {
    margin-left: auto;
    background: var(--accent-red);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    min-width: 22px;
    text-align: center;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-md);
}

.sidebar-user .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--accent-green));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: white;
    flex-shrink: 0;
}

.sidebar-user .user-info {
    overflow: hidden;
}

.sidebar-user .user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-role {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ---------- Main Content Area ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

/* ---------- Top Header ---------- */
.top-header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 900;
}

.top-header .header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-header .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-header .page-title {
    font-size: 1.15rem;
    font-weight: 600;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.menu-toggle:hover { background: var(--bg-hover); }

/* ---------- Header Buttons ---------- */
.header-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.header-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.header-btn .badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: var(--accent-red);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lang-switch {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-surface);
    border-radius: var(--radius-full);
    padding: 3px;
}

.lang-switch a {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}
.lang-switch a:hover { color: var(--text-primary); }
.lang-switch a.active {
    background: var(--primary);
    color: white;
}

/* ---------- Page Content ---------- */
.page-content {
    padding: 24px;
}

/* ---------- Notification Dropdown ---------- */
.notification-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1100;
    display: none;
    overflow: hidden;
}
.notification-dropdown.show { display: block; }

.notification-dropdown .notif-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-dropdown .notif-header h4 {
    font-size: 0.9rem;
    font-weight: 600;
}

.notification-dropdown .notif-header a {
    font-size: 0.75rem;
    color: var(--primary-light);
}

.notification-dropdown .notif-list {
    max-height: 320px;
    overflow-y: auto;
}

.notification-dropdown .notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.notification-dropdown .notif-item:hover { background: var(--bg-hover); }
.notification-dropdown .notif-item.unread { border-left: 3px solid var(--primary); }

.notification-dropdown .notif-item .notif-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.notification-dropdown .notif-item .notif-message {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.notification-dropdown .notif-item .notif-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.notification-dropdown .notif-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ---------- Overlay for mobile sidebar ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(4px);
}
.sidebar-overlay.show { display: block; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .menu-toggle {
        display: flex;
    }
}

@media (max-width: 768px) {
    .page-content { padding: 16px; }
    .top-header { padding: 0 16px; }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    .notification-dropdown { width: calc(100vw - 32px); right: -60px; }
}

@media (max-width: 480px) {
    .page-content { padding: 12px; }
    .top-header { padding: 0 12px; }
}

/* ---------- Auth Layout & Login Page ---------- */
.auth-page {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(17, 24, 39, 0.9)),
        linear-gradient(90deg, rgba(16, 185, 129, 0.08), rgba(99, 102, 241, 0.1));
}

.auth-layout {
    min-height: 100vh;
    padding: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-shell {
    width: min(100%, 980px);
    min-height: 620px;
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.82fr);
    background: rgba(15, 23, 42, 0.58);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: authCardIn 0.42s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-brand-panel,
.auth-card {
    min-width: 0;
}

.auth-brand-panel {
    position: relative;
    padding: 36px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 28px;
    background:
        linear-gradient(180deg, rgba(30, 41, 59, 0.68), rgba(15, 23, 42, 0.86)),
        linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(99, 102, 241, 0.1));
    border-inline-end: 1px solid var(--border-color);
}

.auth-brand-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-logo,
.auth-form-icon,
.auth-input-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.auth-logo {
    width: 48px;
    height: 48px;
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--accent-green));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    box-shadow: 0 10px 26px rgba(16, 185, 129, 0.18);
}

.auth-brand-name {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 800;
}

.auth-brand-copy {
    max-width: 430px;
}

.auth-kicker {
    display: block;
    margin-bottom: 10px;
    color: var(--accent-green-light);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.auth-brand-copy h1 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.22;
}

.auth-brand-copy p {
    max-width: 340px;
    margin: 12px 0 0;
    color: var(--text-secondary);
    font-size: 0.96rem;
    line-height: 1.65;
}

.auth-operations-visual {
    display: grid;
    gap: 12px;
}

.auth-route-line {
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.auth-route-line::before {
    content: '';
    position: absolute;
    inset-inline: 16px;
    top: 50%;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-light), var(--accent-green-light), var(--accent-amber-light));
    opacity: 0.42;
    transform: translateY(-50%);
}

.auth-route-line span {
    width: 18px;
    height: 18px;
    position: relative;
    z-index: 1;
    background: var(--bg-card-solid);
    border: 3px solid var(--primary-light);
    border-radius: 50%;
}

.auth-route-line span:nth-child(2) {
    border-color: var(--accent-green-light);
}

.auth-route-line span:nth-child(3) {
    border-color: var(--accent-amber-light);
}

.auth-visual-panel {
    min-height: 58px;
    padding: 13px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    background: rgba(15, 23, 42, 0.52);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.auth-visual-panel svg {
    color: var(--primary-light);
}

.auth-visual-panel.green svg {
    color: var(--accent-green-light);
}

.auth-visual-panel.amber svg {
    color: var(--accent-amber-light);
}

.auth-visual-bars {
    min-width: 0;
    flex: 1;
    display: grid;
    gap: 8px;
}

.auth-visual-bars span {
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
}

.auth-visual-bars span:first-child {
    width: 76%;
}

.auth-visual-bars span:last-child {
    width: 48%;
}

.auth-card {
    padding: 44px;
    background: rgba(30, 41, 59, 0.72);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-header {
    margin-bottom: 26px;
}

.auth-form-icon {
    width: 44px;
    height: 44px;
    margin-bottom: 14px;
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(129, 140, 248, 0.22);
    border-radius: 8px;
}

.auth-title {
    margin: 0 0 6px;
    color: var(--text-primary);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0;
}

.auth-subtitle {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.auth-form {
    display: grid;
    gap: 18px;
}

.auth-field {
    margin-bottom: 0;
}

.auth-field .form-label {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 700;
}

.auth-input-wrap {
    position: relative;
}

.auth-input-icon {
    width: 42px;
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    color: var(--text-muted);
    pointer-events: none;
}

.auth-input-wrap .form-control {
    min-height: 52px;
    padding-inline-start: 42px;
    padding-inline-end: 14px;
    border-radius: 8px;
    font-size: 0.96rem;
}

.auth-input-wrap:focus-within .auth-input-icon {
    color: var(--primary-light);
}

.auth-submit {
    min-height: 52px;
    margin-top: 4px;
    border-radius: 8px;
    font-size: 0.98rem;
}

[dir="rtl"] .auth-submit-icon {
    transform: scaleX(-1);
}

.auth-language-link {
    width: fit-content;
    margin: 22px auto 0;
    padding: 8px 12px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.86rem;
    font-weight: 700;
}

.auth-language-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: rgba(129, 140, 248, 0.38);
}

@media (max-width: 860px) {
    .auth-layout {
        padding: 16px;
    }

    .auth-shell {
        min-height: auto;
        grid-template-columns: 1fr;
    }

    .auth-brand-panel {
        padding: 24px;
        border-inline-end: 0;
        border-bottom: 1px solid var(--border-color);
    }

    .auth-brand-copy h1 {
        font-size: 1.55rem;
    }

    .auth-operations-visual {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .auth-route-line {
        display: none;
    }

    .auth-card {
        padding: 28px 24px;
    }
}

@media (max-width: 560px) {
    .auth-layout {
        align-items: stretch;
        padding: 0;
    }

    .auth-shell {
        width: 100%;
        min-height: 100vh;
        border-radius: 0;
        border-inline: 0;
        border-top: 0;
        border-bottom: 0;
    }

    .auth-brand-panel {
        padding: 20px;
        gap: 18px;
    }

    .auth-brand-copy p {
        font-size: 0.9rem;
    }

    .auth-operations-visual {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 24px 20px 28px;
    }
}

/* ---------- Grid & Utility Classes for Bootstrap Compatibility ---------- */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -12px;
    margin-left: -12px;
}
[class*="col-"] {
    position: relative;
    width: 100%;
    padding-right: 12px;
    padding-left: 12px;
}
.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
}
.col-6 {
    flex: 0 0 50%;
    max-width: 50%;
}
@media (min-width: 768px) {
    .col-md-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    .col-md-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

.d-flex { display: flex !important; }
.justify-content-between { justify-content: space-between !important; }
.align-items-center { align-items: center !important; }
.text-right { text-align: right !important; }
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.font-weight-600 { font-weight: 600 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mr-2 { margin-right: 0.5rem !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.d-none { display: none !important; }

/* Colors */
.text-danger { color: var(--accent-red) !important; }
.text-success { color: var(--accent-green) !important; }
.text-warning { color: var(--accent-amber) !important; }
.text-primary { color: var(--primary-light) !important; }
.text-muted { color: var(--text-muted) !important; }
