/* ==========================================================================
   1. SYSTEM VARIABLES & DESIGN SYSTEM TOKENS
   ========================================================================== */
:root {
    --bg-main: #0b0c10fa;
    --bg-surface: #12141c;
    --bg-surface-elevated: #1a1d29;
    --accent: #ff3f4b;
    --accent-hover: #e0323d;
    --success: #00d27a;
    --text-main: #ffffff;
    --text-muted: #8a8f9f;
    --border: rgba(255, 255, 255, 0.06);
    --sidebar-width: 260px;
    --radius-lg: 12px;
    --radius-md: 8px;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Base resets explicitly preventing vertical and horizontal structural overflows */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: system-ui, -apple-system, sans-serif; 
    -webkit-tap-highlight-color: transparent; 
}

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden; /* Hard blocks layout elements from bursting out sideways */
    min-height: 100vh;
}

body { 
       background: linear-gradient(var(--bg-main)), url(sangilogo.jpg);
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;

    color: var(--text-main); 
    display: flex; 
    flex-direction: column;
    justify-content: center;
}

/* Main framework frame container layout rules */
.app-container { 
    display: flex; 
    flex-direction: column; /* Stacked block flow layout by default for mobile phone screens */
    width: 100%; 
    max-width: 100vw;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==========================================================================
   2. MOBILE STICKY NAVIGATION HEADER BAR (DEFAULT FIXED VIEWPORT SETUPS)
   ========================================================================== */
.mobile-header { 
    display: flex; 
    background: var(--bg-surface); 
    border-bottom: 1px solid var(--border); 
    padding: 0 16px; 
    height: 60px;
    align-items: center; 
    justify-content: space-between; /* Brand text far left, hamburger trigger far right */
    position: fixed; 
    top: 0; 
    left: 0; 
    right: 0; 
    z-index: 95; 
}

/* Tactile mobile hamburger toggle button alignment rules */
.menu-toggle-btn { 
    background: none; 
    border: none; 
    color: var(--text-main); 
    font-size: 1.8rem; 
    cursor: pointer; 
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px; 
    width: 44px;
    padding: 0;
    margin-right: -4px; /* Pulls target box flush with screen margin bounding lines */
}

/* Off-canvas layout structural drawer sidebar definitions */
.sidebar { 
    width: var(--sidebar-width); 
    background: var(--bg-surface); 
    border-right: 1px solid var(--border); 
    padding: 24px; 
    display: flex; 
    flex-direction: column; 
    gap: 30px; 
    position: fixed; 
    top: 0;
    bottom: 0;
    left: 0;
    height: 100vh; 
    z-index: 100; 
    transform: translateX(-100%); /* Keeps hidden off-screen entirely on smartphones */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    box-shadow: 5px 0 25px rgba(0,0,0,0.5);
}

.sidebar.open { 
    transform: translateX(0); /* Slides open smoothly */
}

.sidebar-brand { 
    font-size: 1.25rem; 
    font-weight: 800; 
}
.sidebar-brand span { 
    color: var(--accent); 
}
.sidebar-brand img {
    width: 20%;

    border-radius: 50%;
}

.sidebar-menu { 
    display: flex; 
    flex-direction: column; 
    gap: 6px; 
    list-style: none; 
}

.sidebar-link { 
    display: flex; 
    align-items: center; 
    padding: 12px 16px; 
    color: var(--text-muted); 
    text-decoration: none; 
    border-radius: var(--radius-md); 
    font-weight: 500; 
}
.sidebar-link:hover, .sidebar-link.active { 
    background: rgba(255, 63, 75, 0.1); 
    color: var(--accent); 
}

/* Fluid primary display panel area workspace */
.main-viewport { 
    flex: 1; 
    width: 100%;
    max-width: 100vw;
    padding: 85px 12px 30px 12px; /* Top padding accommodates fixed mobile navbar */
    box-sizing: border-box;
}

/* ==========================================================================
   3. MANAGEMENT INSIGHT PANELS & INPUT GRID ENTITIES
   ========================================================================== */
.stats-grid { 
    display: grid; 
    grid-template-columns: 1fr; 
    gap: 16px; 
    margin-bottom: 24px; 
}

.card { 
    background: var(--bg-surface); 
    border: 1px solid var(--border); 
    padding: 20px; 
    border-radius: var(--radius-lg); 
    box-shadow: var(--shadow); 
}
.card h3 { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; }
.card p { font-size: 1.75rem; font-weight: 700; margin-top: 6px; }

.two-column-grid {
    display: flex;
    flex-direction: column; 
    gap: 24px;
    width: 60vw;
    box-sizing: border-box;
}

.form-card { 
    background: var(--bg-surface); 
    border: 1px solid var(--border); 
    padding: 20px 14px; 
    border-radius: var(--radius-lg); 
    box-shadow: var(--shadow); 
    width: 95vw; 
    box-sizing: border-box; 
}

.form-group { 
    margin-bottom: 16px; 
}
label { display: block; margin-bottom: 6px; color: var(--text-muted); font-size: 0.85rem; }

input, select, button { 
    width: 100%; 
    max-width: 100%; /* Rigidly locks horizontal dimensions beneath parent edges */
    padding: 12px; 
    background: var(--bg-surface-elevated); 
    border: 1px solid var(--border); 
    color: var(--text-main); 
    border-radius: var(--radius-md); 
    font-size: 0.95rem; 
    box-sizing: border-box; /* Forces embedded padding limits into structural computations */
}
button { 
    background: var(--accent); 
    color: white; 
    font-weight: 600; 
    cursor: pointer; 
    border: none;
    transition: background 0.2s;
}
button:hover { background: var(--accent-hover); }

/* ==========================================================================
   4. LIQUID TABLE DATA ELEMENT CONTAINER BREAKPOINT ENGINES
   ========================================================================== */
.table-wrapper { 
    background: var(--bg-surface); 
    border: 1px solid var(--border); 
    border-radius: var(--radius-lg); 
    margin-bottom: 24px; 
    
    /* THE HORIZONTAL FIXES */
    width: 95vw; 
    max-width: 100%; 
    display: block;
    overflow-x: scroll; /* Forces a localized scrollbar inside this card wrapper only */
    box-sizing: border-box; 
    -webkit-overflow-scrolling: touch; /* Keeps swipe motions fluid on iOS and Android */
}

table { 
    width: 100%; 
    border-collapse: collapse; 
    /* Ensures data columns have enough room to read cleanly without breaking layout bounds */
    min-width: 500px; 
    table-layout: auto; 
}

th, td { 
    padding: 12px 14px; 
    border-bottom: 1px solid var(--border); 
    font-size: 0.9rem; 
    white-space: nowrap; /* Prevents long names or badges from wrapping into tall, messy rows */
}
.badge { display: inline-flex; padding: 4px 8px; font-size: 0.75rem; font-weight: 600; border-radius: 4px; background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* Specific scaling limits for the embedded inline stock counters */
.table-wrapper form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.table-wrapper form input[type="number"] {
    width: 60px !important;
    min-width: 60px !important;
    padding: 6px !important;
    font-size: 0.85rem;
    margin: 0;
}

.table-wrapper form button {
    padding: 6px 12px !important;
    width: auto !important;
    font-size: 0.8rem;
    margin: 0;
    white-space: nowrap;
}

/* ==========================================================================
   5. INTERACTIVE TERMINAL POS WORKSPACE MODULES
   ========================================================================== */
.pos-container { 
    display: flex;
    flex-direction: column;
    gap: 20px; 
    width: 70vw;
    max-width: 100%;
    box-sizing: border-box;
}

.pos-catalog { 
    display: flex; 
    flex-direction: column; 
    gap: 16px; 
    width: 95vw;
}

.pos-filter-bar { 
    display: flex; 
    gap: 8px; 
    overflow-x: scroll; 
    padding-bottom: 8px; 
    scrollbar-width: none; 
}
.pos-filter-bar::-webkit-scrollbar { display: none; }
.pos-filter-bar button { 
    width: auto; 
    padding: 8px 16px; 
    background: var(--bg-surface); 
    border: 1px solid var(--border); 
    color: var(--text-muted); 
    border-radius: 30px; 
    white-space: nowrap; 
    font-size: 0.85rem;
}
.pos-filter-bar button.active { background: var(--accent); color: white; border-color: var(--accent); }

.search-container { position: relative; width: 100%; }
.search-input { width: 100%; padding: 12px 12px 12px 38px; background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-main); border-radius: var(--radius-md); }
.search-icon-marker { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

/* Touch matrix items grid mapping settings */
.products-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); 
    gap: 10px; 
    width: 100%;
}

.product-item { 
    background: var(--bg-surface); 
    border: 1px solid var(--border); 
    padding: 12px; 
    border-radius: var(--radius-lg); 
    cursor: pointer; 
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
    min-height: 120px; 
    box-sizing: border-box;
}
.product-item h4 { font-size: 0.85rem; font-weight: 600; line-height: 1.3; }
.product-item .price { color: var(--accent); font-weight: 700; font-size: 1rem; margin-top: 4px; }
.product-item .stock-tag { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* Active receipt tracking panel module window layout */
.cart-panel { 
    background: var(--bg-surface); 
    border: 1px solid var(--border); 
    border-radius: var(--radius-lg); 
    display: flex; 
    flex-direction: column; 
    height: auto; 
    max-height: 460px; /* Constrains growth limits to guarantee structural viewport fitment */
    width: 90vw;
    max-width: 100%;
    box-sizing: border-box;
}
.cart-header { padding: 14px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.95rem; }
.cart-items-box { padding: 14px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex-grow: 1; }
.cart-footer { padding: 14px; border-top: 1px solid var(--border); }

/* Sticky mobile terminal shortcut anchor */
.mobile-jump-cart-btn { 
    display: inline-flex; 
    position: fixed; 
    bottom: 16px; 
    right: 16px; 
    background: var(--accent); 
    color: white; 
    padding: 12px 18px; 
    border-radius: 50px; 
    font-weight: 700; 
    box-shadow: var(--shadow); 
    z-index: 85; 
    border: none; 
    width: auto; 
    font-size: 0.9rem;
    align-items: center;
    gap: 8px;
}
.mobile-jump-cart-btn span {
    background: rgba(0, 0, 0, 0.15);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
}

.item-breakdown-list { margin-top: 4px; padding: 6px; background: rgba(0, 0, 0, 0.2); border-radius: var(--radius-md); font-size: 0.75rem; color: var(--text-muted); }

/* ==========================================================================
   6. LARGE SCREEN WORKSTATION BREAKPOINTS INJECTIONS (MinWidth: 769px)
   ========================================================================== */
@media (min-width: 769px) {
    .app-container { 
        flex-direction: row; /* Transforms framework to classic layout row look */
    }

    .mobile-header { 
        display: none; 
    }

    .sidebar { 
        transform: translateX(0); /* Returns navigation system directly into view */
        box-shadow: none;
    }

    .main-viewport { 
        margin-left: var(--sidebar-width); 
        padding: 40px; 
        width: calc(100% - var(--sidebar-width)); 
        max-width: calc(100vw - var(--sidebar-width));
    }

    .stats-grid { 
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); 
        gap: 24px; 
    }

    .two-column-grid { 
        display: grid;
        grid-template-columns: 1fr 2fr; 
        gap: 32px; 
    }

    .pos-container { 
        display: grid;
        grid-template-columns: 1fr 360px; /* Snaps active billing cart right next to products matrix */
        gap: 32px; 
    }
    .pos-filter-bar{
        width: 60vw;
    }
    .search-input {
        width: 60vw;
    }

    .products-grid { 
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); 
        gap: 16px; 
        width: 60vw;
    }

    .product-item { 
        padding: 16px; 
        min-height: 130px; 
    }
    .product-item h4 { font-size: 0.95rem; }

        .form-card { 
        padding: 16px 12px; 
        width: 60vw;
        max-width: 100%;
        box-sizing: border-box;
    }

    .table-wrapper{
        width: 65vw;
    }


    .cart-panel {
        width: 95vw;
        max-height: 600px;
    }

    .pos-catalog{
        width: 95vw;
    }

    th { padding: 16px 20px; font-size: 0.85rem; }
    td { padding: 16px 20px; font-size: 0.95rem; }

    .mobile-jump-cart-btn { 
        display: none; 
    }
}

/* ==========================================================================
   7. ULTRA EXTRA SMALL MOBILE CONSTRAINTS ENGINE (MaxWidth: 500px and below)
   ========================================================================== */
@media (max-width: 500px) {
    html, body {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
.table-wrapper{
    width: 95vw;
    overflow: scroll;
}
    .app-container {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .main-viewport { 
        padding-left: 10px; /* Slimmer workspace side padding prevents bounds layout pushes */
        padding-right: 10px; 
        padding-top: 76px; 
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
    }

    .two-column-grid, .pos-container {
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .cart-panel { 
        width: 95vw;
        box-sizing: border-box;
    }

    .form-card { 
        padding: 16px 12px; 
        width: 90vw;
        max-width: 100%;
        box-sizing: border-box;
    }
    input, select, button { 
        padding: 10px; 
        font-size: 0.9rem; 
    }
    .products-grid { 
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); /* Clean 2-column distribution balance */
        gap: 8px; 
        width: 100%;
    }
    .product-item {
        min-height: 110px;
        padding: 10px;
        box-sizing: border-box;
    }
    th, td { 
        padding: 10px 6px; 
        font-size: 0.8rem; 
    }
    .cart-items-box {
        max-height: 180px; /* Stops heavy cart payload counts from stretching mobile display screens */
    }
}