/* ==========================================================================
   GarageERP Design System
   A distinctive, workshop-inspired theme layered on top of Bootstrap 5.
   Palette: deep slate sidebar + safety-orange accent (garage/tools identity),
   soft neutral canvas, generous rounding, mobile-first responsive layout.
   ========================================================================== */

:root {
    --ge-ink-900: #0f172a;
    --ge-ink-800: #16213a;
    --ge-ink-700: #1f2c4c;
    --ge-accent: #ff6b35;
    --ge-accent-dark: #e5551f;
    --ge-teal: #0ea5a4;
    --ge-canvas: #f3f5f9;
    --ge-card: #ffffff;
    --ge-border: #e6e9ef;
    --ge-text: #1a2130;
    --ge-text-muted: #6b7688;
    --ge-radius-lg: 18px;
    --ge-radius-md: 12px;
    --ge-radius-sm: 8px;
    --ge-shadow: 0 2px 10px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --ge-shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);
    --sidebar-width: 264px;
    --topbar-height: 68px;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--ge-canvas);
    color: var(--ge-text);
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

/* ---------------- App shell layout ---------------- */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar-toggle-input { display: none; }

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--ge-ink-900) 0%, var(--ge-ink-800) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1040;
    transition: transform 0.28s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 22px 18px;
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}

.brand-mark { color: var(--ge-accent); font-size: 1.5rem; line-height: 1; }
.brand-text b { color: var(--ge-accent); font-weight: 800; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px;
    overflow-y: auto;
}

.nav-section-label {
    margin: 18px 12px 6px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    font-weight: 700;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--ge-radius-sm);
    color: #cbd5e1;
    font-weight: 500;
    font-size: 0.94rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; color: #8b95a8; }

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.sidebar-nav .nav-link:hover i { color: var(--ge-accent); }

.sidebar-nav .nav-link.active {
    background: rgba(255, 107, 53, 0.16);
    color: #fff;
}

.sidebar-nav .nav-link.active i { color: var(--ge-accent); }

.sidebar-nav .nav-link.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.sidebar-close-handle, .sidebar-backdrop { display: none; }

/* ---------------- Main column ---------------- */

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-height);
    background: var(--ge-card);
    border-bottom: 1px solid var(--ge-border);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.hamburger-btn {
    display: none;
    font-size: 1.4rem;
    color: var(--ge-text);
    cursor: pointer;
    padding: 4px 6px;
}

.topbar-spacer { flex: 1; }

.store-switcher-btn, .user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--ge-canvas);
    border: 1px solid var(--ge-border);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ge-text);
}

.store-switcher-btn i.bi-geo-alt-fill { color: var(--ge-accent); }
.small-chevron { font-size: 0.7rem; color: var(--ge-text-muted); margin-left: 2px; }

.store-switcher-menu { max-height: 320px; overflow-y: auto; min-width: 240px; }

.org-badge {
    align-items: center;
    gap: 8px;
    color: var(--ge-text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}
.org-badge i { color: var(--ge-teal); }

.user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--ge-ink-900);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.content-area {
    flex: 1;
    padding: 26px 28px 60px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* ---------------- Cards, stat tiles, tables ---------------- */

.ge-card {
    background: var(--ge-card);
    border: 1px solid var(--ge-border);
    border-radius: var(--ge-radius-lg);
    box-shadow: var(--ge-shadow);
    padding: 22px;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 22px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0;
}

.page-header p.subtitle {
    color: var(--ge-text-muted);
    margin: 2px 0 0;
    font-size: 0.92rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 26px;
}

.stat-tile {
    display: block;
    background: var(--ge-card);
    border: 1px solid var(--ge-border);
    border-radius: var(--ge-radius-md);
    padding: 18px 20px;
    box-shadow: var(--ge-shadow);
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

a.stat-tile:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.08); transform: translateY(-1px); }

.stat-tile .stat-icon {
    width: 40px; height: 40px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
    margin-bottom: 12px;
    color: #fff;
}

.stat-tile .stat-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-tile .stat-label { color: var(--ge-text-muted); font-size: 0.85rem; font-weight: 500; }

.bg-icon-orange { background: var(--ge-accent); }
.bg-icon-teal { background: var(--ge-teal); }
.bg-icon-navy { background: var(--ge-ink-800); }
.bg-icon-rose { background: #e2477a; }

.ge-table-wrap {
    background: var(--ge-card);
    border: 1px solid var(--ge-border);
    border-radius: var(--ge-radius-lg);
    overflow: hidden;
    box-shadow: var(--ge-shadow);
}

.ge-table-wrap table { margin-bottom: 0; }

.ge-table-wrap thead th {
    background: var(--ge-canvas);
    border-bottom: 1px solid var(--ge-border);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ge-text-muted);
    font-weight: 700;
    padding: 12px 16px;
}

.ge-table-wrap tbody td {
    padding: 13px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--ge-border);
    font-size: 0.92rem;
}

.ge-table-wrap tbody tr:last-child td { border-bottom: none; }
.ge-table-wrap tbody tr:hover { background: #fbfbfd; }

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: capitalize;
}

.status-Draft, .status-Booked { background: #eef2ff; color: #4338ca; }
.status-InProgress { background: #fff7ed; color: var(--ge-accent-dark); }
.status-AwaitingParts { background: #fef2f2; color: #b91c1c; }
.status-QualityCheck { background: #f0fdfa; color: #0f766e; }
.status-ReadyForPickup { background: #ecfdf5; color: #047857; }
.status-Invoiced, .status-Paid { background: #eff6ff; color: #1d4ed8; }
.status-Closed { background: #f1f5f9; color: #475569; }
.status-Cancelled, .status-Void { background: #f5f5f5; color: #9ca3af; }
.status-Submitted { background: #fff7ed; color: var(--ge-accent-dark); }
.status-PartiallyReceived { background: #fefce8; color: #a16207; }
.status-Received { background: #ecfdf5; color: #047857; }
.ledger-credit { background: #fef2f2; color: #b91c1c; }
.ledger-debit { background: #ecfdf5; color: #047857; }

/* ---------------- Buttons ---------------- */

.btn-ge-primary {
    background: var(--ge-accent);
    border-color: var(--ge-accent);
    color: #fff;
    font-weight: 600;
    border-radius: var(--ge-radius-sm);
}
.btn-ge-primary:hover { background: var(--ge-accent-dark); border-color: var(--ge-accent-dark); color: #fff; }

.btn-ge-outline {
    border: 1px solid var(--ge-border);
    color: var(--ge-text);
    background: #fff;
    font-weight: 600;
    border-radius: var(--ge-radius-sm);
}
.btn-ge-outline:hover { background: var(--ge-canvas); }

/* ---------------- Forms ---------------- */

.ge-form-card {
    max-width: 720px;
    background: var(--ge-card);
    border: 1px solid var(--ge-border);
    border-radius: var(--ge-radius-lg);
    box-shadow: var(--ge-shadow);
    padding: 28px;
}

.form-label { font-weight: 600; font-size: 0.88rem; color: var(--ge-text); }
.form-control, .form-select {
    border-radius: var(--ge-radius-sm);
    border-color: var(--ge-border);
    padding: 10px 13px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--ge-accent);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15);
}

/* ---------------- Alerts ---------------- */

.alert-floating { border-radius: var(--ge-radius-md); border: none; margin-bottom: 18px; font-weight: 500; }

/* ---------------- Auth (login) screen ---------------- */

.auth-shell { background: var(--ge-ink-900); }

.auth-main {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 20%, rgba(255,107,53,0.18), transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(14,165,164,0.16), transparent 45%),
        var(--ge-ink-900);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--ge-card);
    border-radius: var(--ge-radius-lg);
    box-shadow: var(--ge-shadow-lg);
    padding: 40px 36px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.4rem;
    margin-bottom: 6px;
    color: var(--ge-ink-900);
}
.auth-brand i { color: var(--ge-accent); font-size: 1.7rem; }
.auth-subtitle { color: var(--ge-text-muted); margin-bottom: 26px; font-size: 0.92rem; }

/* ---------------- POS item picker (counter sale) ---------------- */

.pos-picker-body {
    display: flex;
    gap: 18px;
    align-items: flex-start;
}

.pos-category-list {
    flex: 0 0 170px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 480px;
    overflow-y: auto;
}

.pos-category-btn {
    text-align: left;
    background: transparent;
    border: none;
    border-radius: var(--ge-radius-sm);
    padding: 9px 12px;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--ge-ink-700);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}
.pos-category-btn:hover { background: var(--ge-canvas); }
.pos-category-btn.active { background: var(--ge-accent); color: #fff; }

.pos-item-grid {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    max-height: 480px;
    overflow-y: auto;
    align-content: start;
}

.pos-tile-wrap form { height: 100%; }

.pos-tile {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    background: var(--ge-card);
    border: 1px solid var(--ge-border);
    border-radius: var(--ge-radius-md);
    padding: 14px 10px;
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
.pos-tile:hover:not(:disabled) { box-shadow: var(--ge-shadow); transform: translateY(-2px); border-color: var(--ge-accent); }
.pos-tile:disabled { opacity: 0.5; cursor: not-allowed; }

.pos-tile-icon {
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 107, 53, 0.12);
    color: var(--ge-accent);
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.pos-tile-name { font-size: 0.82rem; font-weight: 600; color: var(--ge-ink-900); line-height: 1.25; }
.pos-tile-price { font-size: 0.86rem; font-weight: 700; color: var(--ge-accent-dark); }
.pos-tile-stock { font-size: 0.72rem; color: var(--ge-text-muted); }

.pos-balance-sticky { position: sticky; top: 88px; }

/* ---------------- Responsive breakpoints ---------------- */

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--ge-shadow-lg);
    }
    .sidebar-close-handle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 18px; right: 16px;
        width: 32px; height: 32px;
        border-radius: 50%;
        background: rgba(255,255,255,0.08);
        color: #fff;
        cursor: pointer;
    }
    .app-main { margin-left: 0; }
    .hamburger-btn { display: block; }
    .sidebar-backdrop {
        display: none;
        position: fixed; inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 1030;
    }
    .sidebar-toggle-input:checked ~ .sidebar { transform: translateX(0); }
    .sidebar-toggle-input:checked ~ .sidebar-backdrop { display: block; }
    .content-area { padding: 18px 16px 48px; }
    .org-badge { display: none !important; }
    .pos-balance-sticky { position: static; }
}

@media (max-width: 767.98px) {
    .pos-picker-body { flex-direction: column; align-items: stretch; }
    .pos-category-list {
        flex-direction: row;
        flex: 0 0 auto;
        width: 100%;
        max-width: 100%;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 4px;
    }
    .pos-item-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); max-height: none; width: 100%; }
}

@media (max-width: 575.98px) {
    .topbar { padding: 0 14px; gap: 8px; }
    .store-switcher-label { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .page-header h1 { font-size: 1.25rem; }
    .ge-form-card { padding: 20px; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .pos-item-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
    .pos-tile { padding: 10px 6px; }
    .pos-tile-icon { width: 36px; height: 36px; font-size: 1rem; }
    .pos-tile-name { font-size: 0.72rem; }
}

@media (min-width: 1400px) {
    .content-area { padding: 32px 40px 60px; }
}

@media print {
    .sidebar, .topbar, .alert-floating { display: none !important; }
    .app-main { margin: 0 !important; }
    .content-area { padding: 0 !important; }
}
