/* =========================================================
   GLOBAL FASHION - STYLESHEET
   Brand colors: teal #28d49c, navy #1a1a2e, background #f5f7f6
   ========================================================= */

:root {
  --teal: #28d49c; --teal-dark: #1fb985; --navy: #1a1a2e;
  --bg: #f5f7f6; --card-bg: #ffffff; --text-main: #1a1a2e; --text-muted: #6b7280;
  --border: #e3e7e5; --danger: #e5484d; --warning: #f5a623; --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, Arial, sans-serif; background: var(--bg); color: var(--text-main); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: var(--teal-dark); text-decoration: none; }

/* ---------- LOGIN SCREEN ---------- */
.login-screen { position: fixed; inset: 0; background: var(--navy); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { background: white; border-radius: var(--radius); padding: 36px 32px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); text-align: center; }
.login-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.login-logo-circle { width: 64px; height: 64px; border-radius: 16px; background: var(--teal); color: var(--navy); font-size: 1.4rem; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.login-title { margin: 0 0 4px; font-size: 1.5rem; color: var(--navy); }
.login-subtitle { color: var(--text-muted); margin: 0 0 20px; font-size: 0.9rem; }
.login-label { display: block; text-align: left; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin: 12px 0 4px; }
.login-input { width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 10px; font-size: 0.96rem; background: var(--bg); }
.login-input:focus { outline: none; border-color: var(--teal); }
.login-btn { width: 100%; margin-top: 20px; padding: 13px; font-size: 1rem; border-radius: 10px; }
.login-error { background: #fde8e8; color: var(--danger); border-radius: 8px; padding: 10px 14px; font-size: 0.88rem; margin-bottom: 8px; text-align: left; }

/* ---------- TOP BAR ---------- */
.topbar { background: var(--navy); color: white; display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; position: sticky; top: 0; z-index: 50; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo-wrap { width: 40px; height: 40px; border-radius: 10px; overflow: hidden; background: var(--teal); display: flex; align-items: center; justify-content: center; flex-shrink:0; }
.logo-wrap img { width: 100%; height: 100%; object-fit: cover; }
.logo-placeholder { font-weight: 700; color: var(--navy); }
.brand-name { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.5px; color: white; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn, a.icon-btn { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.25); color: white; padding: 8px 14px; border-radius: 8px; font-size: 0.9rem; }
.icon-btn:hover { background: rgba(255,255,255,0.2); }
.user-badge { background: rgba(40,212,156,0.15); color: var(--teal); border: 1px solid rgba(40,212,156,0.35); border-radius: 8px; padding: 6px 12px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }

/* ---------- LAYOUT ---------- */
.app-shell { display: flex; min-height: calc(100vh - 60px); }
.sidebar { width: 220px; background: var(--card-bg); border-right: 1px solid var(--border); padding: 18px 10px; display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.nav-item { display: flex; align-items: center; gap: 10px; background: transparent; border: none; padding: 12px 14px; border-radius: 10px; text-align: left; font-size: 0.98rem; color: var(--text-main); }
.nav-item:hover { background: #eef9f4; }
.nav-item.active { background: var(--teal); color: white; font-weight: 600; }
.nav-icon { font-size: 1.1rem; }
.content { flex: 1; padding: 24px 30px 60px; overflow-x: hidden; }
h1 { margin: 0 0 6px; font-size: 1.7rem; color: var(--navy); }
.subtitle { color: var(--text-muted); margin: 0 0 20px; }
.page-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }

/* ---------- BUTTONS ---------- */
.btn { border: none; border-radius: 10px; padding: 10px 18px; font-size: 0.92rem; font-weight: 600; transition: 0.15s; display:inline-block; }
.btn-primary { background: var(--teal); color: white; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-secondary { background: #eef0ef; color: var(--text-main); }
.btn-secondary:hover { background: #dfe3e1; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c93337; }
.btn-small { padding: 6px 10px; font-size: 0.82rem; border-radius: 8px; }

/* ---------- DASHBOARD ---------- */
.big-search-wrap { margin: 10px 0 20px; }
.big-search { width: 100%; padding: 18px 22px; font-size: 1.15rem; border-radius: var(--radius); border: 2px solid var(--border); outline: none; }
.big-search:focus { border-color: var(--teal); }
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 30px; }
.result-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.result-card .rname { font-weight: 700; margin-bottom: 6px; }
.result-card .rmeta { font-size: 0.85rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.badge { display: inline-block; background: #eef9f4; color: var(--teal-dark); border-radius: 6px; padding: 2px 8px; font-size: 0.78rem; font-weight: 600; }
.badge.rack { background: #fff4e0; color: #a06a00; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-top: 10px; margin-bottom: 20px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; text-align: center; }
.stat-number { font-size: 1.6rem; font-weight: 800; color: var(--teal-dark); }
.stat-label { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }
.dash-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- TOOLBAR / FILTERS ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }
.search-input, .select-input, .text-input { padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 0.92rem; background: white; }
.search-input { flex: 1; min-width: 220px; }
.text-input { width: 100%; margin-bottom: 12px; display: block; }
.result-count { color: var(--text-muted); font-size: 0.85rem; margin-left: auto; }

/* ---------- TABLES ---------- */
.table-wrap { overflow-x: auto; background: var(--card-bg); border-radius: var(--radius); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; min-width: 700px; }
.data-table th { text-align: left; background: #fafcfb; padding: 12px 14px; font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 0.92rem; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: #fbfdfc; }
.stock-pill { padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; white-space:nowrap; }
.stock-pill.in_stock { background: #e6f9ef; color: #1a9e5c; }
.stock-pill.low_stock { background: #fff3da; color: #b07a00; }
.stock-pill.out_of_stock { background: #fde8e8; color: #c0282c; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- CARDS / SETTINGS ---------- */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom:16px; }
.card h3 { margin-top: 0; color: var(--navy); }
.card label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 4px; margin-top: 10px; font-weight: 600; }
.warning-text, .warn-box { color: #b07a00; background:#fff4e0; border-radius:8px; padding:10px 14px; font-size: 0.85rem; margin: 10px 0; }
.ok-text { color: #1a9e5c; }
.field-hint { color: var(--text-muted); font-size: 0.8rem; margin: 4px 0 12px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 180px; }

/* ---------- MODAL ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(26,26,46,0.55); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal-overlay.hidden { display: none; }
.modal-box { background: white; border-radius: var(--radius); padding: 26px; max-width: 640px; width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.25); }
.modal-box h2 { margin-top: 0; color: var(--navy); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- INVOICE BUILDER ---------- */
.invoice-line-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.invoice-line-table th { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); text-align: left; padding: 6px; border-bottom: 1px solid var(--border); }
.invoice-line-table td { padding: 6px; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.invoice-line-table input, .invoice-line-table select { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }
.invoice-totals { margin-top: 10px; text-align: right; }
.invoice-totals div { margin: 4px 0; }
.invoice-totals .grand { font-size: 1.2rem; font-weight: 800; color: var(--teal-dark); }
.search-dropdown { position: relative; margin-bottom:10px; }
.search-dropdown-list { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid var(--border); border-radius: 10px; max-height: 220px; overflow-y: auto; z-index: 10; box-shadow: 0 6px 18px rgba(0,0,0,0.12); }
.search-dropdown-item { padding: 8px 12px; cursor: pointer; font-size: 0.88rem; border-bottom: 1px solid var(--border); }
.search-dropdown-item:hover { background: #eef9f4; }

/* ---------- TOASTS / FLASH ---------- */
.toast-inline { padding: 12px 18px; border-radius: 10px; margin-bottom: 16px; font-size: 0.92rem; font-weight:600; }
.toast-inline.success { background: #e6f9ef; color: #1a9e5c; }
.toast-inline.error { background: #fde8e8; color: var(--danger); }
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--navy); color: white; padding: 12px 18px; border-radius: 10px; font-size: 0.9rem; box-shadow: 0 4px 14px rgba(0,0,0,0.2); }
.toast.success { background: var(--teal-dark); } .toast.error { background: var(--danger); }

/* ---------- RTL SUPPORT ---------- */
html[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid var(--border); }
html[dir="rtl"] .nav-item { text-align: right; }
html[dir="rtl"] .data-table th, html[dir="rtl"] .data-table td { text-align: right; }
html[dir="rtl"] .result-count { margin-left: 0; margin-right: auto; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) { .dash-columns { grid-template-columns: 1fr; } }
@media (max-width: 800px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .nav-item { flex-direction: column; font-size: 0.75rem; padding: 8px 10px; white-space: nowrap; }
  .content { padding: 16px; }
}

/* ---------- PRICE TIER SELECTOR (barcode.php cart, invoices.php new invoice) ---------- */
.tier-selector { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tier-selector .tier-label { font-size: 0.85rem; font-weight: 700; color: var(--text-muted); margin-right: 2px; }
.tier-btn { padding: 8px 18px; border-radius: 10px; border: 1.5px solid var(--border); background: white; font-weight: 700; font-size: 0.9rem; cursor: pointer; color: var(--text-muted); }
.tier-btn:hover:not(.active) { background: #eef9f4; }
.tier-btn.active { background: var(--teal); color: white; border-color: var(--teal); }

/* ---------- QUICK ACTIONS (dashboard.php) ---------- */
.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.quick-action-btn { display: flex; align-items: center; gap: 8px; background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 12px; padding: 12px 20px; font-weight: 700; font-size: 0.92rem; color: var(--navy); transition: 0.15s; }
.quick-action-btn:hover { border-color: var(--teal); background: #eef9f4; }
.quick-action-btn .qa-icon { font-size: 1.1rem; }

/* ---------- REPORT PRINT HEADER (reports.php) ---------- */
.report-print-header { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 2px solid var(--border); }
.report-print-header .report-logo { max-height: 56px; max-width: 150px; object-fit: contain; }
.report-print-header .report-company-name { font-size: 1.15rem; font-weight: 800; color: var(--navy); }
.report-print-header .report-print-meta { font-size: 0.82rem; color: var(--text-muted); }

/* ---------- PRINT MODE ---------- */
@media print {
  .topbar, .sidebar, .toolbar, .page-header-row a, .no-print { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; }
  body { background: white; }
}

/* =========================================================
   V3 PROFESSIONAL ADDITIONS
   ========================================================= */

/* Sidebar group labels */
.nav-group-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text-muted); padding: 14px 18px 4px; }

/* Stat card variants */
.stat-card.stat-warn .stat-number { color: #b07a00; }
.stat-card.stat-danger .stat-number { color: var(--danger); }

/* Vertical bar chart (dashboard sales trend) */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding: 10px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 0; }
.bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, var(--teal), var(--teal-dark));
  border-radius: 6px 6px 2px 2px; transition: height 0.3s; }
.bar-col:hover .bar { filter: brightness(1.1); }
.bar-label { font-size: 0.68rem; color: var(--text-muted); margin-top: 4px; }
.bar-value { font-size: 0.62rem; color: var(--text-muted); margin-bottom: 3px; white-space: nowrap; overflow: hidden; max-width: 100%; }

/* Horizontal bars (category breakdown, expenses) */
.hbar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.hbar-name { width: 160px; font-size: 0.84rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-name small { color: var(--text-muted); font-weight: 400; }
.hbar-track { flex: 1; background: var(--bg); border-radius: 6px; height: 16px; overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, var(--teal), var(--teal-dark)); border-radius: 6px; }
.hbar-num { width: 90px; text-align: right; font-size: 0.84rem; font-weight: 700; }

/* Form grid used by v3 pages */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.form-grid .select-input { width: 100%; }

/* POS layout */
.pos-layout { display: grid; grid-template-columns: 1fr 460px; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .pos-layout { grid-template-columns: 1fr; } }
.pos-results { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.pos-hit { background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 14px;
  cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.pos-hit:hover { border-color: var(--teal); background: #f2fdf9; }
.pos-hit-top { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(40,212,156,0.2); }
.pos-totals { border-top: 2px solid var(--border); margin-top: 12px; padding-top: 10px; }
.pos-line { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 0.94rem; }
.pos-grand { font-size: 1.3rem; font-weight: 800; color: var(--navy); border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 10px; }
.pos-empty td { color: var(--text-muted); text-align: center; padding: 24px 10px !important; }

/* ---------- PRODUCT THUMBNAILS (v3.1) ---------- */
.thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; display: inline-flex;
  align-items: center; justify-content: center; background: var(--bg); border: 1px solid var(--border);
  vertical-align: middle; cursor: pointer; flex-shrink: 0; }
.thumb-lg { width: 56px; height: 56px; border-radius: 10px; }
.thumb-empty { font-size: 1.1rem; color: #bbb; cursor: default; }
.result-card-flex { display: flex; gap: 12px; align-items: flex-start; }

/* click-to-enlarge lightbox */
.img-lightbox { position: fixed; inset: 0; background: rgba(10,10,20,0.8); display: flex;
  align-items: center; justify-content: center; z-index: 999; cursor: zoom-out; }
.img-lightbox img { max-width: 90vw; max-height: 88vh; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }

/* ---------- BARCODE LABEL SHEETS ---------- */
.label-sheet { display: none; }
@media print {
  body * { visibility: hidden; }
  .label-sheet, .label-sheet * { visibility: visible; }
  .label-sheet { display: flex !important; flex-wrap: wrap; gap: 2mm; position: absolute; left: 0; top: 0; width: 100%; background: white; }
  .no-print { display: none !important; }
}
.label { border: 0.2mm dashed #ccc; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; overflow: hidden; page-break-inside: avoid; padding: 1mm; background: white; }
.size-small .label { width: 38mm; height: 21mm; }
.size-med   .label { width: 48mm; height: 25mm; }
.size-large .label { width: 60mm; height: 35mm; }
.lbl-shop  { font-size: 6.5pt; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: #000; }
.lbl-name  { font-size: 6.5pt; color: #000; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.size-large .lbl-name { font-size: 8pt; }
.lbl-price { font-size: 8pt; font-weight: 800; color: #000; }
.lbl-code  { max-width: 96%; }

/* ---------- INLINE EDITING (Seller-Central style) ---------- */
.edcell { cursor: pointer; }
.edcell:hover { background: #f2fdf9; box-shadow: inset 0 0 0 1.5px var(--teal); border-radius: 6px; }
.bulk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; padding: 12px 16px; }
.bulk-in { width: 110px; padding: 6px 10px; }

/* ---------- SELLER-CENTRAL STYLE ROWS ---------- */
.row-date { font-size: 0.68rem; color: var(--text-muted); margin-top: 4px; white-space: nowrap; }
.prod-block { max-width: 420px; }
.prod-name { font-weight: 600; line-height: 1.35; }
.prod-meta { font-size: 0.76rem; color: var(--text-muted); margin-top: 2px; }
.prod-meta b { color: var(--text-main); font-weight: 600; }
.sc-box { display: inline-flex; align-items: center; border: 1.5px solid var(--border); border-radius: 8px;
  overflow: hidden; background: #fff; transition: box-shadow .15s, border-color .15s; }
.sc-box:focus-within { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(40,212,156,.25); }
.sc-cur { padding: 0 6px 0 9px; font-size: 0.72rem; color: var(--text-muted); background: var(--bg);
  align-self: stretch; display: flex; align-items: center; border-right: 1px solid var(--border); }
.sc-in { border: none; outline: none; width: 84px; padding: 6px 8px; font-size: 0.86rem; font-family: inherit; }
.sc-in::-webkit-outer-spin-button, .sc-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sc-saved { border-color: #1a9e5c !important; box-shadow: 0 0 0 2px rgba(26,158,92,.3) !important; }
.price-panel .pr-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 3px 0; }
.pr-lbl { font-size: 0.74rem; color: var(--text-muted); min-width: 62px; }
.pr-diff { font-size: 0.7rem; font-weight: 700; margin-top: 4px; text-align: right; }
