:root {
    --primary: #6366f1;
    --primary-rgb: 99, 102, 241;
    --primary-hover: #4f46e5;
    --secondary: #a855f7;
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);

    /* Default Dark Mode (Deep Navy/Slate) */
    --bg-body: #020617;
    --bg-sidebar: #0f172a;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-input: rgba(0, 0, 0, 0.2);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --glass-border: rgba(255, 255, 255, 0.1);
    --sidebar-border: rgba(255, 255, 255, 0.1);
}

body.light-mode {
    --bg-body: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #64748b;
    --glass-border: rgba(0, 0, 0, 0.15);
    --sidebar-border: rgba(0, 0, 0, 0.12);
}

/* Specific light mode border emphasis */
html.light-mode .product-card,
html.light-mode .cart-panel,
html.light-mode .category-pill,
html.light-mode .search-box input,
html.light-mode .glass-card {
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05) !important;
}

html.light-mode .product-card:hover {
    border-color: var(--primary) !important;
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1) !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Splash Screen */
.splash-body {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
}

.splash-container {
    text-align: center;
    animation: fadeIn 1s ease-out;
}

.main-logo-icon {
    width: 100px;
    height: 100px;
    color: var(--primary);
    filter: drop-shadow(0 0 15px rgba(99, 102, 241, 0.5));
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

.splash-title {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(to right, #6366f1, #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
}

.splash-subtitle {
    font-size: 1.2rem;
    color: #94a3b8;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 40px;
}

.loader-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin: 0 auto;
    overflow: hidden;
}

.loader-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    animation: load 2.5s ease-in-out forwards;
}

/* Login Page */
.auth-page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
}

.glass-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: var(--shadow);
}

.form-group {
    margin-bottom: 20px;
    position: relative;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-style {
    width: 100%;
    padding: 14px 18px;
    padding-right: 45px;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-icon-right {
    position: absolute;
    right: 12px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    padding: 6px;
    border-radius: 8px;
    z-index: 5;
}

.input-icon-right:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.clear-input {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.input-style:not(:placeholder-shown)+.clear-input,
.input-style:focus+.clear-input {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.validation-msg {
    font-size: 0.8rem;
    margin-top: 5px;
    display: none;
}

.validation-msg.error {
    color: #ef4444;
    display: block;
}

.validation-msg.success {
    color: #22c55e;
    display: block;
}

.input-style:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes load {
    from {
        width: 0%;
    }

    to {
        width: 100%;
    }
}

/* Dashboard Layout */
.dashboard-body {
    background-color: var(--bg-body);
}

.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--sidebar-border);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    width: 280px;
    z-index: 100;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    overflow-x: hidden;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--primary-rgb, 99, 102, 241), 0.3) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(var(--primary-rgb, 99, 102, 241), 0.2);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.sidebar-nav:hover::-webkit-scrollbar-thumb {
    background: rgba(var(--primary-rgb, 99, 102, 241), 0.5);
    background-clip: content-box;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding: 0 10px;
}

.sidebar-logo {
    color: var(--primary);
    width: 32px;
    height: 32px;
}

.sidebar-title {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 8px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(var(--primary-rgb, 99, 102, 241), 0.1);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

.sidebar-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 20px 0;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: #64748b;
}

.main-content {
    margin-left: 280px;
    padding: 30px;
    width: calc(100% - 280px);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    position: relative;
    padding-bottom: 10px;
}

.clock {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    padding: 8px 16px;
    border-radius: 50px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    padding: 24px;
    border-radius: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.stat-icon {
    padding: 10px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border-radius: 12px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
}

.stat-label {
    color: #94a3b8;
    font-size: 0.9rem;
}

@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        padding: 20px 10px;
    }

    .sidebar-title,
    .user-details,
    .nav-item span {
        display: none;
    }

    .main-content {
        margin-left: 80px;
        width: calc(100% - 80px);
    }
}

@media (max-width: 640px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 15px;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* POS Specific Styles */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    height: calc(100vh - 140px);
    /* Adjusted for header */
    overflow: hidden;
    /* Prevent page scroll */
}

.product-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
    height: 100%;
}

.category-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
    flex-shrink: 0;
    /* Keep category height fixed */
}

.category-scroll::-webkit-scrollbar {
    height: 4px;
}

.category-scroll::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    grid-auto-rows: max-content;
    /* Ensure rows don't stretch weirdly */
    gap: 15px;
    overflow-y: auto;
    padding-right: 10px;
    padding-bottom: 20px;
    /* Space for last items */
    flex: 1;
    /* Take remaining space */
}

.product-card {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.product-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-3px);
    border-color: var(--primary);
}

.product-image {
    width: 100%;
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.product-name {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 0.95rem;
    color: #f1f5f9;
}

.product-price {
    color: var(--primary);
    font-weight: 800;
    font-size: 1.1rem;
}

.cart-panel {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cart-header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.cart-item {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.cart-item-details {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.cart-item-price {
    color: #94a3b8;
    font-size: 0.85rem;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 10px;
    border-radius: 8px;
}

/* Theme Icon Handling */
.theme-icon {
    display: none !important;
}

html:not(.light-mode) .sun-icon {
    display: block !important;
}

html.light-mode .moon-icon {
    display: block !important;
}

/* Top Bar & UI Colors */
#page-title {
    color: var(--text-main);
}

.clock {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(var(--primary-rgb, 99, 102, 241), 0.1);
    padding: 8px 16px;
    border-radius: 50px;
    border: 1px solid rgba(var(--primary-rgb, 99, 102, 241), 0.2);
}

/* POS & Cards */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    height: calc(100vh - 140px);
    overflow: hidden;
}

.cart-panel {
    background: var(--bg-sidebar);
    border: 1px solid var(--sidebar-border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.product-card {
    background: var(--bg-sidebar);
    border: 1px solid var(--sidebar-border);
    border-radius: 16px;
    padding: 15px;
    text-align: center;
    transition: all 0.2s;
}

.product-name {
    color: var(--text-main);
}

.cart-footer {
    padding: 20px;
    background: rgba(0, 0, 0, 0.05);
    border-top: 1px solid var(--sidebar-border);
}

body.light-mode .cart-footer {
    background: #f8fafc;
}

.total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 20px;
    color: var(--text-main);
}

.category-pill {
    padding: 8px 20px;
    background: var(--bg-sidebar);
    border: 1px solid var(--sidebar-border);
    color: var(--text-muted);
    border-radius: 50px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.category-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.category-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-main);
}

th {
    text-align: left;
    padding: 15px;
    color: var(--text-dim);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--sidebar-border);
}

td {
    padding: 15px;
    border-bottom: 1px solid var(--sidebar-border);
}

tr:hover td {
    background: rgba(var(--primary-rgb, 99, 102, 241), 0.03);
}

#productSearch:focus {
    border-color: var(--primary) !important;
    background: rgba(99, 102, 241, 0.05) !important;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

#productSearch:focus+i {
    color: var(--primary) !important;
}

@media (max-width: 1024px) {
    .pos-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .cart-panel {
        height: 500px;
    }
}