:root {
    --primary: #ff6b00;
    --primary-hover: #e66000;
    --secondary: #1e293b;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --dark: #050a18;
    --sidebar-bg: #0a122a;
    --card-bg: #0a122a;
    --white: #ffffff;
    --text: #ffffff;
    --text-muted: #cbd5e1;
    --sidebar-width: 220px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --border: rgba(255, 255, 255, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

html, body {
    overflow-x: hidden;
}

body {
    background: var(--dark);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--white);
    position: fixed;
    top: 0;
    left: 0;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 2000;
    border-right: 1px solid var(--border);
    transition: transform 0.3s ease;
}

.sidebar-logo {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--white);
    overflow: hidden;
}

.sidebar-logo::before { display: none !important; }

.sidebar-logo img {
    width: 35px;
    height: 35px;
    min-width: 35px;
    object-fit: contain;
    flex-shrink: 0;
}

.nav-links {
    list-style: none;
    flex-grow: 1;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.3s;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255, 107, 0, 0.1);
    color: var(--primary);
}

.nav-link i {
    margin-right: 0.75rem;
    color: var(--primary);
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 1.5rem;
    width: calc(100% - var(--sidebar-width));
    min-width: 0;
    overflow-x: hidden;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.responsive-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
}

.responsive-grid.inv { grid-template-columns: 1fr 2.5fr; }
.responsive-grid.mkt { grid-template-columns: 1fr 1.8fr; }

@media (max-width: 1200px) {
    :root { --sidebar-width: 60px; }
    .sidebar { padding: 1rem 0.5rem; width: 60px; }
    
    /* Hide text nodes with font-size trick, img is unaffected */
    .sidebar-logo { 
        font-size: 0 !important; 
        overflow: hidden;
        justify-content: center;
        margin-bottom: 1.5rem;
    }
    .sidebar-logo img { width: 32px; height: 32px; min-width: 32px; }
    
    /* Hide nav link text */
    .nav-link span { display: none; }
    .nav-link { justify-content: center; padding: 0.75rem; }
    .nav-link i { margin-right: 0; font-size: 1.15rem; }
    
    /* Add tooltips via title on hover (native browser) */
    .nav-link { position: relative; }
}

@media (max-width: 1024px) {
    .responsive-grid, .responsive-grid.inv, .responsive-grid.mkt {
        grid-template-columns: 1fr !important;
    }
}

.card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.3s;
}

.card:hover { transform: translateY(-5px); }

.card-title {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--white);
}

.table-container {
    background: var(--card-bg);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: rgba(255, 255, 255, 0.02);
    text-align: left;
    padding: 0.65rem 0.75rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

td {
    padding: 0.65rem 0.75rem;
    border-top: 1px solid var(--border);
    color: var(--text);
    font-size: 0.875rem;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: rgba(34, 197, 94, 0.1); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.2); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.2); }

.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

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

input, select, textarea, option {
    background: #0f172a;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    color: var(--white);
    outline: none;
    transition: border-color 0.3s;
}

input:focus, select:focus, textarea:focus { border-color: var(--primary); }

label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    .btn-group {
        flex-direction: column;
    }
    .btn-group button, .btn-group a {
        width: 100%;
    }
    td {
        word-break: break-word;
        max-width: 150px;
    }
}

/* Mobile Header */
.mobile-header {
    display: none;
    background: #0a122a;
    padding: 0.75rem 1.25rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3000;
    border-bottom: 1px solid var(--border);
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.mobile-header .sidebar-logo {
    margin-bottom: 0;
    font-size: 1.25rem;
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--primary); /* Use orange for toggle for better visibility */
    font-size: 1.75rem;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* RESPONSIVE MEDIA QUERIES */
@media (max-width: 1024px) {
    body { display: block; }
    :root { --sidebar-width: 0px; }
    
    .sidebar {
        width: 260px;
        transform: translateX(-100%);
        padding: 1.5rem;
    }
    .sidebar-logo span, .nav-link span { display: block; }
    .nav-link { justify-content: flex-start; padding: 0.75rem 1rem; }
    .nav-link i { margin-right: 0.75rem; }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1rem;
        padding-top: 5rem;
    }
    
    .mobile-header {
        display: flex;
    }
    
    .card-grid {
        grid-template-columns: 1fr;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .pos-container {
        grid-template-columns: 1fr !important;
    }
    
    .cart-section {
        position: static !important;
        width: 100% !important;
        margin-top: 1.5rem;
    }
}

@media (max-width: 768px) {
    .table-container {
        overflow-x: auto;
    }
    
    table {
        min-width: 500px;
    }
    
    .page-title {
        font-size: 1.25rem;
    }
    
    .card {
        padding: 1rem;
    }
}

/* Always allow tables to scroll horizontally */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* POS Quantity Control */
.qty-control {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
}
.qty-control button {
    background: none;
    border: none;
    color: var(--white);
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-weight: 800;
    transition: 0.2s;
}
.qty-control button:hover { background: var(--primary); }
.qty-control input {
    width: 40px;
    background: transparent;
    border: none;
    color: white;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    padding: 0;
    margin: 0;
    -moz-appearance: textfield;
    appearance: textfield;
    box-shadow: none;
    outline: none;
}

.qty-control input::-webkit-outer-spin-button,
.qty-control input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    appearance: none !important;
    margin: 0;
}

.delete-btn {
    background: none;
    border: none;
    color: #f87171;
    cursor: pointer;
    padding: 0.5rem;
    transition: 0.2s;
    font-size: 1.1rem;
}
.delete-btn:hover { color: #ef4444; transform: scale(1.15); }
