:root {
    /* Color Palette - Premium & Trustworthy */
    --primary-color: #3329ec;
    /* Indigo 600 */
    --primary-hover: #3122ce;
    /* Indigo 700 */
    --secondary-color: #10B981;
    /* Emerald 500 */
    --secondary-hover: #059669;
    /* Emerald 600 */
    --danger-color: #EF4444;
    /* Red 500 */
    --danger-hover: #DC2626;
    /* Red 600 */

    /* Neutral Colors */
    --bg-body: #F3F4F6;
    /* Cool Gray 100 */
    --bg-card: #FFFFFF;
    --text-main: #1F2937;
    /* Gray 800 */
    --text-muted: #6B7280;
    /* Gray 500 */
    --border-color: #E5E7EB;
    /* Gray 200 */

    /* Shadows & Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Typography */
    --font-family: 'Poppins', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
}

/* ============================================
   RESPONSIVE — Mobile-first breakpoints
   ============================================ */

/* Large Desktop (1200px+): default layout — no overrides needed */

/* Medium Desktop / Laptop (max 1200px) */
@media (max-width: 1200px) {
    .pos-container {
        grid-template-columns: 1fr 280px;
    }

    .container {
        padding: 0 1rem;
    }
}

/* Dashboard & Layout Utilities */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.responsive-flex-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .responsive-flex-row {
        flex-direction: column;
        align-items: stretch;
    }

    .card {
        padding: 1rem !important;
    }
}

/* Header Styles */
header {
    background: #111827;
    /* Gray 900 */
    color: #fff;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
}

header .logo-text {
    font-weight: 300;
    opacity: 0.9;
}

/* Navigation */
.navbar {
    position: relative;
    overflow: hidden;
    flex: 1;
    margin: 0 1rem;
}

.navbar ul {
    display: flex;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 4px 2px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
    white-space: nowrap;
    flex-wrap: nowrap;
}

.navbar ul::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.navbar ul li {
    flex-shrink: 0;
}

.navbar a {
    display: inline-block;
    color: #9CA3AF;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.2s;
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.navbar a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.navbar a.active {
    color: #fff;
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* Slider arrow buttons */
.navbar-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    z-index: 10;
    transition: background 0.2s;
    flex-shrink: 0;
}

.navbar-arrow:hover {
    background: var(--primary-color);
}

.navbar-arrow.left {
    left: 0;
}

.navbar-arrow.right {
    right: 0;
}

/* Main Container Layout */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* POS Wrapper — fills viewport height below header */
.pos-wrapper {
    margin-top: 1rem;
    margin-bottom: 1rem;
    padding: 0 1rem;
    max-width: 100%;
}

/* POS Specific Layout — 3 columns: Products | Cart | Checkout */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 300px 280px;
    gap: 1rem;
    height: calc(100vh - 130px);
    min-height: 500px;
}

#posAddProductBtn {
    margin-top: 10px;
    margin-bottom: 10px;
    background-color: var(--border-color);
    box-shadow: #111827 0px 1px 10px -5px;
    color: var(--primary-color);
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.products-panel {
    overflow: hidden;


}

.products-category {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    z-index: 99999;
}

.panel-header {
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.products-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    overflow-y: auto;
    padding: 0.25rem;
    /* prevent shadow clip */
    height: 100%;
}

.product-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.product-card .title {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.product-card .price {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.1rem;
}

.product-card .desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    flex-grow: 1;
}

.product-img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-md);
}

/* Cart Styles */
.cart-panel {
    border-right: 1px solid var(--border-color);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

#cartItems {
    flex: 1;
    overflow-y: auto;
    margin: 1rem 0;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px dashed var(--border-color);
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.cart-summary {
    background: var(--bg-body);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-top: auto;
}

.cart-summary div {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.cart-summary .total {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}

/* Checkout Panel */
.checkout-panel {
    display: flex;
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
}

/* Form Elements */
.input-field {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.button:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.button:disabled {
    background-color: #9CA3AF;
    cursor: not-allowed;
    opacity: 0.7;
}

.button.secondary {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    text-decoration: none;

}

.button.secondary:hover {
    background-color: var(--bg-card);
}

/* Category Filter Buttons */
.button.category-filter {
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
}

.button.category-filter.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.button.category-filter.active:hover {
    background-color: var(--primary-hover);
}


.button-group {
    display: flex;
    max-width: 600px;
    flex-direction: row;
}

.button.secondary2 {
    max-width: 85px;
    background-color: #F3F4F6;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    opacity: 0.7;

}

.daily.balance {
    max-width: 110px;
    background-color: #F3F4F6;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-md);
    cursor: pointer;
    opacity: 1;
}

.daily.balance:hover {
    background-color: #E5E7EB;
    transform: translateY(-1px);
    transition-duration: 0.3s;
}

#dailybalanceinput {
    display: none;
    max-width: 250px;
    height: 30px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: baseline;
    padding: 1rem;
    align-content: center;
}

#dailybalanceinput.show {
    display: block;
}

.img-container {
    max-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px auto;
}

.img-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.button.delete {
    background-color: #FEE2E2;
    color: var(--danger-color);
}

.button.delete:hover {
    background-color: #FECACA;
}

.button.full-width {
    width: 100%;
}

/* checkout actions grid */
.checkout-actions {
    display: grid;
    gap: 0.5rem;
}

#completeSale {
    background-color: var(--secondary-color);
    font-size: 1.1rem;
    padding: 1rem;
}

#completeSale:hover {
    background-color: var(--secondary-hover);
}

/* Modal */
.password-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    place-items: center;
    z-index: 1000;
}

.password-modal[aria-hidden="false"] {
    display: grid;
}

.password-modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease-out;
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Utility */
.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.text-center {
    text-align: center;
}

/* ============================================
   TABLET (max 1024px)
   ============================================ */
@media (max-width: 1024px) {
    header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    header h1 {
        font-size: 1.2rem;
    }

    .navbar {
        margin: 0 0.5rem;
    }

    /* POS: 2 columns — products+cart stacked | checkout */
    .pos-container {
        grid-template-columns: 1fr 260px;
        grid-template-rows: 1fr auto;
        height: auto;
        gap: 0.75rem;
    }

    /* Checkout spans full width below */
    .checkout-panel {
        grid-column: 1 / -1;
        flex-direction: row;
        gap: 1rem;
    }

    .checkout-panel .card {
        flex: 1;
    }

    .products-list {
        height: 50vh;
        min-height: 300px;
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }

    .cart-panel {
        max-height: 60vh;
    }

    .container,
    .pos-wrapper {
        margin: 0.75rem auto;
        padding: 0 0.75rem;
    }

    .card {
        padding: 1rem;
    }
}

/* ============================================
   MOBILE (max 768px)
   ============================================ */
@media (max-width: 768px) {

    /* Header */
    header {
        padding: 0.6rem 0.75rem;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    header h1 {
        font-size: 1rem;
    }

    header h1 img {
        height: 24px !important;
    }

    .logo-text {
        display: none;
        /* hide text next to logo on very small screens */
    }

    .user-controls button {
        font-size: 0.75rem;
        padding: 0.4rem 0.75rem;
    }

    /* Navbar slider — reduce arrow size */
    .navbar-arrow {
        width: 22px;
        height: 22px;
        font-size: 0.7rem;
    }

    /* Container */
    .container,
    .pos-wrapper {
        margin: 0.5rem auto;
        padding: 0 0.5rem;
    }

    /* POS Layout — single column, scrollable */
    .pos-container {
        grid-template-columns: 1fr;
        height: auto;
        gap: 0.75rem;
    }

    .checkout-panel {
        grid-column: 1 / -1;
        flex-direction: column;
    }

    .products-panel {
        max-height: none;
    }

    .products-list {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        height: 45vh;
        min-height: 250px;
        gap: 0.5rem;
    }

    .product-card {
        padding: 0.5rem;
    }

    .product-card img {
        height: 100px !important;
        width: 100% !important;
        object-fit: contain !important;
    }

    /* Cart */
    .cart-panel {
        max-height: 300px;
    }

    #cartItems {
        margin: 0.5rem 0;
    }

    .cart-item {
        padding: 0.5rem 0;
        font-size: 0.85rem;
    }

    .cart-summary {
        padding: 0.75rem;
    }

    /* Checkout Panel */
    .checkout-panel {
        padding: 0.5rem;
    }

    /* Cards */
    .card {
        padding: 0.75rem;
        border-radius: var(--radius-md);
    }

    /* Buttons */
    .button {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    .button.secondary2 {
        max-width: 72px;
        font-size: 0.75rem;
        padding: 0.4rem 0.5rem;
    }

    /* Order type buttons */
    .button-group {
        flex-wrap: wrap;
        max-width: 100%;
        gap: 4px;
    }

    /* Tables — horizontal scroll on mobile */
    .table-container,
    .overflow-x-auto,
    div[style*="overflow-x:auto"],
    div[style*="overflow-x: auto"] {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1.5rem;
        width: 100%;
        background: white;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
    }

    table {
        min-width: 700px;
        /* forces scroll when screen is narrow */
        width: 100%;
        border-collapse: collapse;
    }

    th,
    td {
        padding: 0.85rem 0.6rem !important;
        font-size: 0.85rem;
    }

    /* Modals — full width on mobile */
    .password-modal .card,
    .password-modal>div {
        width: 95vw !important;
        max-width: 95vw !important;
        padding: 1.25rem !important;
        margin: 0 auto;
        max-height: 90vh;
        overflow-y: auto;
        box-sizing: border-box;
    }

    /* Override inline multi-column grids to 1-col on mobile */
    .password-modal-content [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Panel header */
    .panel-header h2 {
        font-size: 1rem;
    }

    /* Input fields */
    .input-field {
        padding: 0.6rem;
        font-size: 0.875rem;
    }

    /* Daily Balance section */
    #dailybalanceinput {
        max-width: 140px;
        height: 28px;
        font-size: 0.85rem;
    }
}

/* ============================================
   VERY SMALL MOBILE (max 480px)
   ============================================ */
@media (max-width: 480px) {
    .products-list {
        grid-template-columns: repeat(2, 1fr);
        height: 40vh;
    }

    header h1 {
        font-size: 0.9rem;
    }

    .button {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .pos-container {
        gap: 0.5rem;
    }
}

/* Table Styles (Added for Warehouse/Inventory) */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: white;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

thead {
    background-color: var(--text-main);
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--bg-body);
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:last-child td {
    border-bottom: none;
}


tr:hover td {
    background-color: #F9FAFB;
}


.edit-btn,
.delete-btn {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    margin-right: 4px;
}

.edit-btn {
    background: var(--bg-body);
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

.delete-btn {
    background: #fee2e2;
    color: var(--danger-color);
}

/* Login Page Specific Styles */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111827;
    /* Gray 900 */
    min-height: 100vh;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    background: #1F2937;
    /* Gray 800 */
    border: 1px solid #374151;
    /* Gray 700 */
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    height: 48px;
    margin-bottom: 1rem;
}

.login-title {
    color: #F9FAFB;
    /* Gray 50 */
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: #9CA3AF;
    /* Gray 400 */
}

/* Premium Button Styles */
.btn-premium {
    position: relative;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    font-weight: 600;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2), 0 2px 4px -1px rgba(79, 70, 229, 0.1);
    letter-spacing: 0.025em;
    width: 100%;
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3), 0 4px 6px -2px rgba(79, 70, 229, 0.15);
    filter: brightness(1.1);
}

.btn-premium:active {
    transform: translateY(0);
}

.btn-premium:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-right: 0.5rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.login-footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.8rem;
    color: #6B7280;
}


#transactionsList {
    overflow-y: auto;
    max-height: 400px;
    max-width: 100%;
    padding: 0.5rem;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-delete {
    background-color: #FEE2E2;
    color: var(--danger-color);
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s;
}

@media print {
    .no-print { display: none !important; }
    
    body * {
        visibility: hidden;
    }

    #content,
    #content * {
        visibility: visible;
    }

    #content {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
}

#search-bar {
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    width: 100%;
    max-width: 400px;
}