/* ============================
   InventoryPOS Web — style.css
   ============================ */

:root {
    --bg:          #1A1A2E;
    --bg-dark:     #16213E;
    --surface:     #1E1E3A;
    --surface2:    #252550;
    --secondary:   #0F3460;
    --accent:      #E94560;
    --accent-h:    #c73450;
    --success:     #4CAF50;
    --warning:     #FF9800;
    --danger:      #F44336;
    --info:        #2196F3;
    --text:        #FFFFFF;
    --text-muted:  #9090B8;
    --border:      #333366;
    --card-radius: 12px;
    --sidebar-w:   240px;
    --transition:  0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

/* ── Layout ─────────────────────────── */
.app-wrapper   { display: flex; height: 100vh; overflow: hidden; }
.main-content  { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.content-area  { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Sidebar ────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    transition: width var(--transition);
    flex-shrink: 0;
    overflow: hidden;
    border-right: 1px solid var(--border);
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-info span { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 14px; }
.sidebar.collapsed .nav-item i { margin: 0; }
.sidebar.collapsed .sidebar-footer { flex-direction: column; gap: 8px; }

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
}
.logo-icon { font-size: 26px; }
.logo-text  { font-size: 18px; font-weight: 700; color: var(--text); white-space: nowrap; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-muted);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
    border-left: 3px solid transparent;
}
.nav-item i { width: 20px; text-align: center; font-size: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
    background: var(--surface2);
    color: var(--accent);
    border-left-color: var(--accent);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    gap: 10px;
}
.user-info {
    display: flex; align-items: center; gap: 8px;
    color: var(--text-muted); font-size: 13px;
    overflow: hidden;
}
.user-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout {
    color: var(--text-muted);
    text-decoration: none;
    padding: 6px;
    border-radius: 6px;
    transition: color var(--transition), background var(--transition);
    flex-shrink: 0;
}
.btn-logout:hover { color: var(--danger); background: rgba(244,67,54,.1); }

/* ── Topbar ─────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 24px;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-toggle {
    background: none; border: none; color: var(--text-muted);
    font-size: 18px; cursor: pointer; padding: 4px 8px;
    border-radius: 6px; transition: color var(--transition);
}
.sidebar-toggle:hover { color: var(--text); }
.page-title { font-size: 20px; font-weight: 600; flex: 1; }
.topbar-right { margin-left: auto; }
.badge-date { color: var(--text-muted); font-size: 13px; }

/* ── Cards ──────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--card-radius);
    border: 1px solid var(--border);
    padding: 20px;
}
.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 16px;
}

/* ── Stat cards ─────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
}
.stat-icon {
    width: 52px; height: 52px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(33,150,243,.15); color: #2196F3; }
.stat-icon.green  { background: rgba(76,175,80,.15);  color: #4CAF50; }
.stat-icon.orange { background: rgba(255,152,0,.15);  color: #FF9800; }
.stat-icon.red    { background: rgba(233,69,96,.15);  color: #E94560; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Grid helpers ───────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }

/* ── Tables ─────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    background: var(--surface2);
    color: var(--text-muted);
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em;
    padding: 12px 14px; text-align: left;
    white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:hover { background: rgba(255,255,255,.03); }
tbody td { padding: 12px 14px; vertical-align: middle; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ── Badges ─────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-success { background: rgba(76,175,80,.15);  color: var(--success); }
.badge-warning { background: rgba(255,152,0,.15);  color: var(--warning); }
.badge-danger  { background: rgba(244,67,54,.15);  color: var(--danger);  }
.badge-info    { background: rgba(33,150,243,.15); color: var(--info);    }

/* ── Buttons ────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 18px; border-radius: 8px; border: none;
    font-size: 14px; font-weight: 600; cursor: pointer;
    text-decoration: none; transition: opacity var(--transition), transform var(--transition);
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: none; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-sm       { padding: 5px 12px; font-size: 13px; }
.btn-icon     { padding: 7px; border-radius: 6px; }

/* ── Forms ──────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label       { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
input[type=text], input[type=number], input[type=email],
input[type=password], input[type=url], select, textarea {
    width: 100%; padding: 10px 14px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-size: 14px;
    transition: border-color var(--transition);
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--surface2); }

/* ── Search bar ─────────────────────── */
.search-bar {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 14px;
}
.search-bar i { color: var(--text-muted); }
.search-bar input {
    background: none; border: none; color: var(--text);
    font-size: 14px; flex: 1; padding: 0; width: auto;
}

/* ── Toolbar row ────────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .search-bar { flex: 1; min-width: 200px; }

/* ── Modal ──────────────────────────── */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.6); z-index: 1000;
    align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 28px; width: 100%; max-width: 520px;
    max-height: 90vh; overflow-y: auto;
    animation: modal-in .15s ease;
}
@keyframes modal-in { from { opacity:0; transform:scale(.95); } to { opacity:1; transform:none; } }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 20px; cursor: pointer; padding: 4px;
}
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Alerts ─────────────────────────── */
.alert {
    padding: 12px 16px; border-radius: 8px;
    margin-bottom: 16px; font-size: 14px;
    display: flex; align-items: center; gap: 10px;
}
.alert-success { background: rgba(76,175,80,.15); color: var(--success); border: 1px solid rgba(76,175,80,.3); }
.alert-danger  { background: rgba(244,67,54,.15);  color: var(--danger);  border: 1px solid rgba(244,67,54,.3); }
.alert-warning { background: rgba(255,152,0,.15);  color: var(--warning); border: 1px solid rgba(255,152,0,.3); }

/* ── POS Layout ─────────────────────── */
.pos-wrapper { display: grid; grid-template-columns: 1fr 380px; gap: 20px; height: calc(100vh - 120px); }
.pos-products { overflow-y: auto; }
.pos-cart {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--card-radius); display: flex; flex-direction: column;
}
.pos-cart-header { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; }
.pos-cart-items { flex: 1; overflow-y: auto; padding: 12px; }
.pos-cart-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.cart-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 8px; border-bottom: 1px solid var(--border);
}
.cart-item-name { flex: 1; font-size: 14px; }
.cart-item-price { font-size: 12px; color: var(--text-muted); }
.cart-qty { display: flex; align-items: center; gap: 8px; }
.cart-qty button {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); cursor: pointer; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
}
.cart-qty button:hover { border-color: var(--accent); color: var(--accent); }
.cart-qty span { min-width: 24px; text-align: center; font-weight: 600; }
.cart-subtotal { min-width: 70px; text-align: right; font-weight: 600; color: var(--accent); }
.cart-remove { color: var(--text-muted); background: none; border: none; cursor: pointer; font-size: 16px; }
.cart-remove:hover { color: var(--danger); }
.pos-total-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.pos-total-label { color: var(--text-muted); font-size: 14px; }
.pos-total-value { font-size: 24px; font-weight: 700; color: var(--success); }

/* Product grid for POS */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.product-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--card-radius); overflow: hidden;
    cursor: pointer; transition: border-color var(--transition), transform var(--transition);
}
.product-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.product-card img { width: 100%; height: 110px; object-fit: cover; }
.product-card-body { padding: 10px; }
.product-card-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.product-card-price { color: var(--accent); font-weight: 700; font-size: 14px; }
.product-card-stock { font-size: 11px; color: var(--text-muted); }

/* ── Gallery grid ───────────────────── */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.gallery-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--card-radius); overflow: hidden; }
.gallery-item img { width: 100%; height: 160px; object-fit: cover; }
.gallery-item-body { padding: 12px; }

/* ── Auth pages ─────────────────────── */
.auth-page {
    min-height: 100vh; background: var(--bg);
    display: flex; align-items: center; justify-content: center;
}
.auth-box {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 40px; width: 100%; max-width: 420px;
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo .icon { font-size: 52px; display: block; margin-bottom: 10px; }
.auth-logo h1 { font-size: 26px; font-weight: 700; }
.auth-logo p  { color: var(--text-muted); font-size: 14px; }

/* ── Misc ───────────────────────────── */
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-3 { gap: 12px; }
.w-full { width: 100%; }
.font-bold { font-weight: 700; }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.product-img-sm { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }

@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
    .pos-wrapper { grid-template-columns: 1fr; grid-template-rows: 1fr 400px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
    .form-row   { grid-template-columns: 1fr; }
}
