/* ==========================================================================
   KVINA ENTERPRISE DESIGN SYSTEM & MASTER TEMPLATE
   Framework: Vanilla CSS 3 + CSS Variables + Glassmorphism + Dark Mode
   ========================================================================== */

:root {
    --primary: #2563eb;
    --primary-rgb: 37, 99, 235;
    --primary-light: #eff6ff;
    --primary-dark: #1d4ed8;
    
    --accent: #10b981;
    --accent-light: #ecfdf5;
    --accent-dark: #047857;
    
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    
    --danger: #ef4444;
    --danger-light: #fef2f2;
    
    --purple: #8b5cf6;
    --purple-light: #f5f3ff;
    
    --cyan: #06b6d4;
    --cyan-light: #ecfeff;
    
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-alt: #f1f5f9;
    --bg-sidebar: #0f172a;
    --bg-header: rgba(255, 255, 255, 0.92);
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --text-inverse: #ffffff;
    
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    
    --sidebar-width: 275px;
    --sidebar-collapsed-width: 76px;
    --header-height: 68px;
    
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    --transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-body: #0b0f19;
    --bg-surface: #111827;
    --bg-card: #111827;
    --bg-alt: #1f2937;
    --bg-sidebar: #070b14;
    --bg-header: rgba(17, 24, 39, 0.92);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-light: #6b7280;
    
    --border-color: #374151;
    --border-hover: #4b5563;
    
    --primary-light: #1e3a8a;
    --accent-light: #064e3b;
    --warning-light: #78350f;
    --danger-light: #7f1d1d;
    --purple-light: #4c1d95;
    --cyan-light: #164e63;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   APP SHELL LAYOUT (SIDEBAR + HEADER + MAIN CONTENT)
   ========================================================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* --- SIDEBAR --- */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: var(--transition);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #ffffff;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
    transition: var(--transition);
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.4);
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

.nav-section-label {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #64748b;
    padding: 0.75rem 0.65rem 0.25rem 0.65rem;
    letter-spacing: 0.08em;
    white-space: nowrap;
    transition: var(--transition);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-md);
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-link span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(3px);
}

.nav-link.active {
    color: #ffffff;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.nav-link .nav-badge {
    margin-left: auto;
    font-size: 0.68rem;
    padding: 0.12rem 0.45rem;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.18);
    color: white;
    font-weight: 700;
    flex-shrink: 0;
    white-space: nowrap;
}

.sidebar-footer {
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    white-space: nowrap;
    transition: var(--transition);
}

/* --- SIDEBAR COLLAPSED MODE --- */
.app-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.app-sidebar.collapsed .sidebar-header {
    padding: 0;
    justify-content: center;
}

.app-sidebar.collapsed .sidebar-brand {
    gap: 0;
    justify-content: center;
}

.app-sidebar.collapsed .sidebar-brand span,
.app-sidebar.collapsed .nav-section-label,
.app-sidebar.collapsed .nav-link span,
.app-sidebar.collapsed .nav-link .nav-badge,
.app-sidebar.collapsed .sidebar-footer {
    display: none !important;
}

.app-sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem 0;
    gap: 0;
}

.app-sidebar.collapsed .nav-link:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.12);
}

.app-sidebar.collapsed .nav-link i {
    font-size: 1.25rem;
    width: auto;
}

/* --- MAIN WRAPPER & HEADER --- */
.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: var(--transition);
}

.app-main.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

.app-header {
    height: var(--header-height);
    background: var(--bg-header);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.header-toggle-btn:hover { color: var(--primary); background: var(--bg-alt); }

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-user-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    text-decoration: none;
    color: var(--text-main);
    font-size: 0.875rem;
    font-weight: 600;
    transition: var(--transition);
}
.header-user-btn:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

/* --- CONTENT CONTAINER --- */
.app-content {
    flex: 1;
    padding: 1.75rem;
}

/* ==========================================================================
   BUTTONS & FORM CONTROLS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    font-family: var(--font-main);
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-accent {
    background-color: var(--accent);
    color: white;
}
.btn-accent:hover {
    background-color: var(--accent-dark);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-outline {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-main);
}
.btn-outline:hover {
    background-color: var(--bg-alt);
    border-color: var(--border-hover);
}

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

.form-group { margin-bottom: 1.25rem; }
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: var(--text-main);
}
.form-control {
    width: 100%;
    padding: 0.55rem 0.95rem;
    font-size: 0.9rem;
    line-height: 1.45;
    font-family: var(--font-main);
    background-color: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    transition: var(--transition);
    box-sizing: border-box;
    min-height: 42px;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* --- CUSTOM SELECT / COMBOBOX STYLING --- */
select.form-control,
.form-control select,
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 16px;
    padding-right: 2.25rem !important;
    min-height: 42px;
    line-height: 1.45;
    font-size: 0.875rem;
    box-sizing: border-box;
    cursor: pointer;
}

[data-theme="dark"] select.form-control,
[data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
}

select option {
    background-color: var(--bg-surface);
    color: var(--text-main);
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
}

/* ==========================================================================
   CARDS & PANELS
   ========================================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.card-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

/* ==========================================================================
   BADGES & PILLS
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.7rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--accent-light); color: var(--accent); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-cyan { background: var(--cyan-light); color: var(--cyan); }

/* ==========================================================================
   GLASSMORPHISM AUTH PAGE & WIZARD
   ========================================================================== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #064e3b 100%);
    padding: 2rem 1.5rem;
    position: relative;
    overflow: hidden;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    top: -20%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.auth-wrapper::after {
    content: '';
    position: absolute;
    bottom: -20%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.25) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.auth-card {
    width: 100%;
    max-width: 460px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    border-radius: var(--radius-xl);
    padding: 2.75rem 2.25rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    z-index: 10;
}

[data-theme="dark"] .auth-card {
    background: rgba(17, 24, 39, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
}

.wizard-card {
    width: 100%;
    max-width: 860px;
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    padding: 2.75rem;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    position: relative;
    z-index: 10;
}

/* ==========================================================================
   TOAST NOTIFICATION CONTAINER
   ========================================================================== */
#toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}
.toast.success { border-left: 4px solid var(--accent); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

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

.pc-slot-row {
    display: grid;
    grid-template-columns: 210px 1fr 90px 130px 36px;
    gap: 0.75rem;
    align-items: center;
    background: var(--bg-alt);
    padding: 0.65rem 0.95rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}
.pc-slot-row:hover {
    border-color: var(--primary);
    background: var(--bg-surface);
}

.pc-part-select {
    min-height: 42px !important;
    height: 42px !important;
    line-height: 1.45 !important;
    padding: 0.5rem 2.25rem 0.5rem 0.85rem !important;
    font-size: 0.875rem !important;
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE, TABLET, LAPTOP, DESKTOP)
   ========================================================================== */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

.header-page-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

/* Tablet & Mobile (<= 992px) */
@media (max-width: 992px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: 280px !important;
        z-index: 1050;
        box-shadow: 0 0 35px rgba(0, 0, 0, 0.45);
    }

    .app-sidebar.mobile-open {
        transform: translateX(0) !important;
    }

    .app-main {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .app-content {
        padding: 1.25rem;
    }

    .header-badge-industry {
        display: none !important;
    }

    .header-page-title {
        max-width: 200px;
        font-size: 0.9rem;
    }

    .header-left {
        gap: 0.5rem;
    }
}

/* Mobile Devices (<= 768px) */
@media (max-width: 768px) {
    .app-header {
        padding: 0 0.85rem;
        height: 56px;
    }

    .header-user-text {
        display: none !important;
    }

    .header-user-btn {
        padding: 0;
        border: none;
        background: transparent;
    }

    .header-user-btn:hover {
        box-shadow: none;
        border-color: transparent;
    }

    .header-page-title {
        max-width: 140px;
        font-size: 0.85rem;
    }

    .app-content {
        padding: 0.85rem;
    }

    .header-right {
        gap: 0.35rem;
    }

    /* PC Builder Layout */
    .pc-build-grid {
        grid-template-columns: 1fr !important;
    }

    .pc-slot-row {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
        padding: 0.85rem !important;
    }

    .pc-slot-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .pc-slot-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.75rem;
    }

    /* POS Screen Stack */
    .pos-main-container {
        grid-template-columns: 1fr !important;
    }

    /* Tables responsiveness */
    div[style*="overflow-x: auto"] table {
        min-width: 550px;
    }

    /* Top Grid metrics */
    div[style*="grid-template-columns: repeat(3, 1fr)"],
    div[style*="grid-template-columns: repeat(4, 1fr)"],
    div[style*="grid-template-columns: repeat(auto-fit"] {
        grid-template-columns: 1fr !important;
    }

    div[style*="grid-template-columns: 2fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* Small Phones (<= 480px) */
@media (max-width: 480px) {
    .app-content {
        padding: 0.65rem;
    }

    .card {
        padding: 1rem;
    }

    .btn {
        padding: 0.5rem 0.9rem;
        font-size: 0.8rem;
    }

    .pos-modal-backdrop > div {
        max-width: 95vw !important;
        margin: 0.5rem !important;
    }
}

