/* ============================================================================
   Auto Parts Accounting & Inventory System - Design System
   Modern Glassmorphism Theme (Thai Culture Ready)
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root, [data-theme="glassmorphism"] {
    --bg-primary: #0f172a;
    --bg-surface: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.85);
    --bg-card-hover: #334155;
    --border-color: rgba(255, 255, 255, 0.1);
    
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-cyan: #06b6d4;
    --accent-purple: #8b5cf6;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --font-family: 'Prompt', 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="light-modern"] {
    --bg-primary: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --border-color: #cbd5e1;
    
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --accent-emerald: #059669;
    --accent-amber: #d97706;
    --accent-rose: #e11d48;
    --accent-cyan: #0891b2;
    --accent-purple: #7c3aed;
    
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #94a3b8;
    
    --shadow-glass: 0 4px 20px rgba(0, 0, 0, 0.08);
}

[data-theme="cyberpunk"] {
    --bg-primary: #0d0714;
    --bg-surface: #170d28;
    --bg-card: rgba(26, 15, 46, 0.85);
    --bg-card-hover: #2d1852;
    --border-color: rgba(192, 132, 252, 0.25);
    
    --primary-color: #c084fc;
    --primary-hover: #a855f7;
    --accent-emerald: #22d3ee;
    --accent-amber: #f472b6;
    --accent-rose: #f43f5e;
    --accent-cyan: #38bdf8;
    --accent-purple: #e879f9;
    
    --text-main: #fcf6ff;
    --text-muted: #c084fc;
    --text-dim: #8b5cf6;
    
    --shadow-glass: 0 8px 32px rgba(192, 132, 252, 0.2);
}

[data-theme="sunset-warm"] {
    --bg-primary: #18181b;
    --bg-surface: #27272a;
    --bg-card: rgba(39, 39, 42, 0.85);
    --bg-card-hover: #3f3f46;
    --border-color: rgba(245, 158, 11, 0.25);
    
    --primary-color: #f59e0b;
    --primary-hover: #d97706;
    --accent-emerald: #10b981;
    --accent-amber: #fbbf24;
    --accent-rose: #f43f5e;
    --accent-cyan: #06b6d4;
    --accent-purple: #a855f7;
    
    --text-main: #fafafa;
    --text-muted: #d4d4d8;
    --text-dim: #71717a;
    
    --shadow-glass: 0 8px 32px rgba(245, 158, 11, 0.15);
}

[data-theme="emerald-forest"] {
    --bg-primary: #062016;
    --bg-surface: #0a3324;
    --bg-card: rgba(10, 51, 36, 0.85);
    --bg-card-hover: #124d37;
    --border-color: rgba(16, 185, 129, 0.25);
    
    --primary-color: #10b981;
    --primary-hover: #059669;
    --accent-emerald: #34d399;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-cyan: #06b6d4;
    --accent-purple: #8b5cf6;
    
    --text-main: #ecfdf5;
    --text-muted: #a7f3d0;
    --text-dim: #4ade80;
    
    --shadow-glass: 0 8px 32px rgba(16, 185, 129, 0.2);
}

[data-theme="midnight-dark"] {
    --bg-primary: #030712;
    --bg-surface: #111827;
    --bg-card: rgba(17, 24, 39, 0.9);
    --bg-card-hover: #1f2937;
    --border-color: rgba(255, 255, 255, 0.12);
    
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #ef4444;
    --accent-cyan: #06b6d4;
    --accent-purple: #a855f7;
    
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.12) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-family);
    line-height: 1.5;
    min-height: 100vh;
}

/* App Header & Navigation */
.app-navbar {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-emerald));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.brand-title {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

.brand-sub {
    font-size: 0.75rem;
    color: var(--accent-emerald);
    font-weight: 500;
}

.nav-tabs-container {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-card);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.nav-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.nav-tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-tab-btn.active {
    background: var(--primary-color) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
    font-weight: 600;
}

.nav-tab-btn.active i {
    color: #ffffff !important;
}

.sub-navbar-container {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.6rem 1.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-glass);
    animation: fadeInDown 0.2s ease-out;
}

.sub-navbar-inner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.btn-sub-tab {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.5rem 1.15rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    opacity: 0.85;
}

.btn-sub-tab:hover {
    background: var(--bg-card-hover);
    color: var(--text-main);
    border-color: var(--primary-color);
    opacity: 1;
}

.btn-sub-tab.active {
    background: var(--primary-color);
    color: #ffffff !important;
    border-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
    opacity: 1;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.branch-badge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* User Profile Menu & Dropdown Popover */
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.user-menu-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.25);
}

.user-avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-emerald));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.user-info-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    text-align: left;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 270px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
    padding: 0.75rem;
    display: none;
    flex-direction: column;
    z-index: 3000;
    backdrop-filter: blur(20px);
    animation: fadeInDropdown 0.15s ease-out;
}

.user-dropdown-menu.active {
    display: flex;
}

@keyframes fadeInDropdown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-dropdown-header {
    padding: 0.4rem 0.5rem;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.88rem;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    box-sizing: border-box;
}

.user-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--primary-color);
}

.user-dropdown-item.danger {
    color: #f43f5e;
}

.user-dropdown-item.danger:hover {
    background: rgba(244, 63, 94, 0.15);
    color: #fb7185;
}

.user-dropdown-item-theme {
    padding: 0.5rem 0.6rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin: 0.35rem 0;
}

/* Layout Main Container */
.main-container {
    max-width: 1440px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

.btn-sub-tab {
    background: rgba(125, 125, 125, 0.08);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-sub-tab:hover {
    background: rgba(125, 125, 125, 0.15);
    color: var(--text-main);
}

.btn-sub-tab.active {
    background: #2563eb !important;
    border-color: #2563eb !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
    font-weight: 600;
}

.btn-sub-tab.active i,
.btn-sub-tab.active span,
.btn-sub-tab.active * {
    color: #ffffff !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Glassmorphism Cards */
.card-glass {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-glass);
    margin-bottom: 1.5rem;
}

.card-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Grid & Dashboard Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.metric-card.blue::before { background: var(--primary-color); }
.metric-card.emerald::before { background: var(--accent-emerald); }
.metric-card.amber::before { background: var(--accent-amber); }
.metric-card.rose::before { background: var(--accent-rose); }

.metric-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
}

.metric-icon {
    position: absolute;
    right: 1.25rem;
    bottom: 1rem;
    font-size: 2.2rem;
    opacity: 0.15;
}

/* POS Layout */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 1.35fr;
    gap: 1.5rem;
}

@media (max-width: 992px) {
    .pos-container {
        grid-template-columns: 1fr;
    }
}

.pos-search-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.input-glass {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    width: 100%;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.input-glass:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.btn-glass {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-glass:not(.btn-primary):not(.btn-emerald):not(.btn-rose):not(.btn-amber):hover {
    background: var(--bg-card-hover);
    color: var(--text-main);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover,
.btn-glass.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-color)) !important;
    color: #ffffff !important;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5);
    transform: translateY(-1px);
}

.btn-emerald {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-emerald:hover,
.btn-glass.btn-emerald:hover {
    background: linear-gradient(135deg, #059669, #047857) !important;
    color: #ffffff !important;
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.5);
    transform: translateY(-1px);
}

.btn-amber {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    border: none;
}

.btn-amber:hover,
.btn-glass.btn-amber:hover {
    background: linear-gradient(135deg, #d97706, #b45309) !important;
    color: #ffffff !important;
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.5);
    transform: translateY(-1px);
}

.btn-rose {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    color: #ffffff;
    border: none;
}

.btn-rose:hover,
.btn-glass.btn-rose:hover {
    background: linear-gradient(135deg, #e11d48, #be123c) !important;
    color: #ffffff !important;
    box-shadow: 0 6px 16px rgba(244, 63, 94, 0.5);
    transform: translateY(-1px);
}

/* POS Products Catalog Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    max-height: 600px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.product-item-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.product-item-card:hover {
    border-color: var(--primary-color);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}

.part-badge {
    display: inline-block;
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: monospace;
    margin-bottom: 0.4rem;
}

.product-name-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.3rem;
    line-height: 1.3;
}

.car-compat {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

.price-stock-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.part-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-emerald);
}

.part-stock {
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* POS Cart Table */
.cart-table-wrapper {
    max-height: 440px;
    overflow-y: auto;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.table-custom {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table-custom th {
    background: var(--bg-surface);
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--border-color);
}

.table-custom td {
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

.table-custom tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.cart-summary-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.summary-row.total {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-emerald);
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

/* Modal Popup */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-overlay.active {
    display: flex;
}

.modal-body-glass {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 650px;
    padding: 1.5rem;
    box-shadow: var(--shadow-glass);
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalShakePrompt {
    0%, 100% { transform: scale(1); }
    20%, 60% { transform: scale(1.015) translateX(-4px); }
    40%, 80% { transform: scale(1.015) translateX(4px); }
}
.modal-shake-prompt {
    animation: modalShakePrompt 0.35s ease-in-out;
}

/* Form Controls */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* Status Badges */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.badge-success { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.badge-danger { background: rgba(244, 63, 94, 0.2); color: #fda4af; }
.badge-info { background: rgba(6, 182, 212, 0.2); color: #67e8f9; }

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* ============================================================================
   Theme & Template Customizer Styles
   ============================================================================ */
.theme-selector-dropdown {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.theme-selector-dropdown:hover {
    border-color: var(--primary-color);
}

.theme-selector-dropdown option {
    background: var(--bg-surface);
    color: var(--text-main);
}

.theme-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1rem 0 1.5rem 0;
}

.theme-card {
    background: var(--bg-surface);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
    overflow: hidden;
}

.theme-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

.theme-card.active {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.15);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.theme-card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    background: var(--primary-color);
    color: #fff;
    font-weight: 700;
    display: none;
}

.theme-card.active .theme-card-badge {
    display: inline-block;
}

.theme-preview-dots {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.theme-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.2);
}

/* Invoice Template Live Preview Card */
.invoice-preview-card {
    background: #ffffff;
    color: #1e293b;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    font-family: 'Sarabun', sans-serif;
    font-size: 11px;
    margin-top: 1rem;
    border: 1px solid #cbd5e1;
    transition: all 0.3s ease;
}

.invoice-preview-card.theme-blue { border-top: 4px solid #2563eb; }
.invoice-preview-card.theme-emerald { border-top: 4px solid #10b981; }
.invoice-preview-card.theme-purple { border-top: 4px solid #8b5cf6; }
.invoice-preview-card.theme-dark { border-top: 4px solid #1e293b; }
.invoice-preview-card.theme-crimson { border-top: 4px solid #dc2626; }

.invoice-preview-card.style-thermal80 {
    max-width: 280px;
    margin: 1rem auto;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    padding: 10px;
    border: 1px dashed #94a3b8;
}

.template-option-btn {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.template-option-btn:hover {
    border-color: var(--primary-color);
    color: var(--text-main);
}

.template-option-btn.active {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* POS Product Image & Hover Tooltip */
.pos-prod-thumb-box {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.pos-prod-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

.pos-prod-thumb-box:hover .pos-prod-thumb {
    transform: scale(1.1);
}

.cart-item-thumb {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
    background: #ffffff;
    border: 1px solid var(--border-color);
    vertical-align: middle;
    margin-right: 6px;
}

/* Floating Mouse Hover Tooltip Preview */
.pos-img-hover-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 10px;
    padding: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    max-width: 220px;
    animation: fadeInTooltip 0.15s ease-out;
}

@keyframes fadeInTooltip {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.pos-img-hover-tooltip img {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
    background: #ffffff;
}

.pos-img-hover-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: #ffffff;
    margin-top: 6px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================================
   RESPONSIVE DESIGN SYSTEM (MOBILE, TABLET, DESKTOP)
   ============================================================================ */

/* 1. Header & Navigation Bar Responsiveness */
@media (max-width: 992px) {
    .app-navbar {
        flex-wrap: wrap;
        padding: 0.6rem 1rem;
        gap: 0.75rem;
    }

    .brand-container {
        flex: 1;
    }

    .brand-logo {
        width: 36px;
        height: 36px;
        font-size: 1.25rem;
    }

    .brand-title {
        font-size: 1.05rem;
    }

    .brand-sub {
        font-size: 0.7rem;
    }

    .nav-tabs-container {
        order: 3;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        padding: 0.35rem 0.25rem;
        border-radius: var(--radius-md);
        scrollbar-width: none; /* Firefox */
        margin-top: 0.25rem;
    }

    .nav-tabs-container::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

    .nav-tab-btn {
        flex-shrink: 0;
        padding: 0.5rem 0.9rem;
        font-size: 0.85rem;
    }

    .header-status {
        gap: 0.5rem;
    }

    .branch-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.6rem;
    }
}

@media (max-width: 576px) {
    .main-container {
        padding: 0 0.6rem;
        margin: 0.85rem auto;
    }

    .card-glass {
        padding: 0.9rem;
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    .card-title-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .card-title {
        font-size: 1rem;
    }

    .user-info-text {
        display: none; /* Compact avatar for small phones */
    }

    .user-menu-btn {
        padding: 0.35rem;
    }

    .user-dropdown-menu {
        width: 260px;
        right: -10px;
    }
}

/* 2. POS Page Responsive Layout */
@media (max-width: 992px) {
    .pos-container {
        grid-template-columns: 1fr !important;
        gap: 1.25rem;
    }

    .pos-search-bar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .pos-category-pills {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        padding-bottom: 6px;
        scrollbar-width: none;
    }

    .pos-category-pills::-webkit-scrollbar {
        display: none;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
        gap: 0.75rem;
    }

    .product-item-card {
        padding: 0.75rem;
    }

    .product-name-title {
        font-size: 0.88rem;
    }
}

/* 3. Form Rows & Grid Layouts */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr !important;
        flex-direction: column;
        gap: 0.75rem;
    }

    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 0.75rem;
    }

    .metric-card {
        padding: 0.9rem;
    }

    .metric-value {
        font-size: 1.35rem;
    }

    .metric-icon {
        font-size: 1.7rem;
        right: 0.65rem;
        bottom: 0.65rem;
    }
}

/* 4. Modals Responsiveness */
@media (max-width: 768px) {
    .modal-body-glass {
        width: 94% !important;
        max-width: 94% !important;
        margin: 1rem auto;
        padding: 1.15rem !important;
        max-height: 90vh;
        overflow-y: auto;
        border-radius: 14px;
    }
}

/* 5. Tables & Touch Responsiveness */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .table-custom th,
    .table-custom td {
        padding: 0.55rem 0.7rem;
        font-size: 0.82rem;
        white-space: nowrap;
    }

    /* Primary buttons & inputs min-height for touch targets */
    .btn-glass, .btn-primary, .btn-emerald, .btn-rose, .btn-amber {
        min-height: 40px;
        touch-action: manipulation;
    }

    .input-glass {
        min-height: 42px;
        font-size: 0.9rem;
    }
}

/* 6. Sub-tabs Responsiveness */
@media (max-width: 768px) {
    .ref-sub-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        padding-bottom: 0.5rem;
        scrollbar-width: none;
    }

    .ref-sub-tabs::-webkit-scrollbar {
        display: none;
    }

    .btn-sub-tab {
        flex-shrink: 0;
        padding: 0.45rem 0.85rem;
        font-size: 0.82rem;
    }
}

/* 7. Print A4 Portrait Styles */
@media print {
    @page {
        size: A4 portrait;
        margin: 0 !important;
    }
    html, body {
        height: auto !important;
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
    }
    body * {
        visibility: hidden !important;
    }
    #modal-print-po, #modal-print-po * {
        visibility: visible !important;
    }
    #modal-print-po {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        max-height: 295mm !important;
        background: #ffffff !important;
        display: block !important;
        overflow: hidden !important;
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    #modal-print-po .modal-body-glass {
        box-shadow: none !important;
        border: none !important;
        background: #ffffff !important;
        padding: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    .no-print {
        display: none !important;
    }
    .a4-print-document {
        padding: 4mm 8mm !important;
        margin: 0 auto !important;
        background: #ffffff !important;
        color: #000000 !important;
        font-family: 'Inter', 'Prompt', sans-serif !important;
        box-shadow: none !important;
        border: none !important;
        box-sizing: border-box !important;
        page-break-after: avoid !important;
        page-break-before: avoid !important;
        page-break-inside: avoid !important;
    }
    .po-print-table {
        page-break-inside: auto !important;
    }
    .po-print-table tr {
        page-break-inside: avoid !important;
        page-break-after: auto !important;
    }
    .po-print-table th, .po-print-table td {
        border: 1px solid #000000 !important;
        color: #000000 !important;
        padding: 3px 5px !important;
    }
}

.search-dropdown-item:hover {
    background: rgba(56, 189, 248, 0.2) !important;
}

/* Sub-modals & Secondary Search Overlay Priority */
#modal-po-product-search,
#modal-search-customer,
#modal-void-reason,
#modal-db-error {
    z-index: 3000 !important;
}




/* Modal Container Styling */
.modal-container {
    background: #ffffff !important;
    color: #0f172a !important;
    border-radius: 16px !important;
    padding: 1.5rem !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
    border: 1px solid #cbd5e1 !important;
    max-height: 90vh;
    overflow-y: auto;
    width: 90%;
    position: relative;
    z-index: 2001;
}

.modal-container .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-container .modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
}

.modal-container .modal-close {
    background: #f1f5f9;
    border: none;
    font-size: 1.5rem;
    color: #64748b;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-container .modal-close:hover {
    background: #ef4444;
    color: #ffffff;
}

.modal-container .form-label {
    color: #334155 !important;
    font-weight: 600;
    margin-bottom: 0.35rem;
    display: block;
}

.modal-container .input-glass {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
    border-radius: 8px;
    padding: 0.55rem 0.85rem;
    width: 100%;
}

.modal-container .input-glass:focus {
    background: #ffffff !important;
    border-color: #0284c7 !important;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15) !important;
    outline: none;
}

.modal-container .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid #e2e8f0;
}


/* =========================================================================
   DOCUMENT-FOLDER STYLE TABS DESIGN FOR SYSTEM SETTINGS
   ========================================================================= */
.doc-folder-tabs-header {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #0284c7;
    margin-top: 1rem;
    margin-bottom: 1.25rem;
    padding-left: 4px;
    overflow-x: auto;
}

.doc-folder-tab {
    background: linear-gradient(180deg, #1e293b, #0f172a);
    color: #94a3b8;
    border: 1px solid #334155;
    border-bottom: none;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    padding: 0.6rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s ease;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
    position: relative;
    top: 2px;
}

.doc-folder-tab:hover {
    background: linear-gradient(180deg, #334155, #1e293b);
    color: #f8fafc;
    border-color: #38bdf8;
}

.doc-folder-tab.active {
    background: linear-gradient(180deg, #0284c7, #0369a1);
    color: #ffffff;
    border-color: #38bdf8;
    border-bottom: 2px solid #0284c7;
    box-shadow: 0 -4px 12px rgba(2,132,199,0.3);
    top: 0px;
    z-index: 2;
}


/* =========================================================================
   LIGHT MODERN THEME & HIGH CONTRAST MODAL FIXES
   ========================================================================= */

/* Card boxes inside System Settings Modal */
.sys-card-box {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: all 0.25s ease;
}

[data-theme="light-modern"] .sys-card-box {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

[data-theme="light-modern"] .modal-body-glass {
    background: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15) !important;
}

[data-theme="light-modern"] .card-title {
    color: #0284c7 !important;
    font-weight: 700 !important;
}

[data-theme="light-modern"] .form-label {
    color: #1e293b !important;
    font-weight: 600 !important;
}

[data-theme="light-modern"] small, 
[data-theme="light-modern"] .text-muted {
    color: #64748b !important;
}

[data-theme="light-modern"] .input-glass {
    background: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #94a3b8 !important;
}

[data-theme="light-modern"] .input-glass:focus {
    border-color: #0284c7 !important;
    box-shadow: 0 0 0 3px rgba(2,132,199,0.15) !important;
}

[data-theme="light-modern"] select.input-glass option {
    background: #ffffff !important;
    color: #0f172a !important;
}

/* Document Folder Tabs in Light Modern Theme */
[data-theme="light-modern"] .doc-folder-tabs-header {
    border-bottom: 2px solid #0284c7 !important;
}

[data-theme="light-modern"] .doc-folder-tab {
    background: #e2e8f0 !important;
    color: #334155 !important;
    border: 1px solid #cbd5e1 !important;
    border-bottom: none !important;
}

[data-theme="light-modern"] .doc-folder-tab:hover {
    background: #cbd5e1 !important;
    color: #0f172a !important;
}

[data-theme="light-modern"] .doc-folder-tab.active {
    background: #0284c7 !important;
    color: #ffffff !important;
    border-color: #0284c7 !important;
}

/* Data Tables in Light Modern Theme */
[data-theme="light-modern"] .table-custom th {
    background: #e2e8f0 !important;
    color: #0f172a !important;
    border-bottom: 2px solid #cbd5e1 !important;
    font-weight: 700 !important;
}

[data-theme="light-modern"] .table-custom td {
    background: #ffffff !important;
    color: #1e293b !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

[data-theme="light-modern"] .table-custom tr:hover td {
    background: #f1f5f9 !important;
}

/* Binary Upload Boxes in Light Modern Theme */
[data-theme="light-modern"] .binary-upload-card {
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
}
