/* StoreManager OMS - Main Stylesheet */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a3c6e;
  --primary-light: #2563eb;
  --primary-hover: #1d4ed8;
  --sidebar-bg: #0f2349;
  --sidebar-text: #94b4d8;
  --sidebar-active: #2563eb;
  --bg: #f0f4f8;
  --white: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info-bg: #eff6ff;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
}

body { font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

a { text-decoration: none; color: inherit; }
button { cursor: pointer; }
input, select, textarea { font-family: inherit; }

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

/* ---- SIDEBAR ---- */
.sidebar { width: 200px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transition: width 0.2s; }
.sidebar-logo { padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.logo-title { font-size: 16px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 8px; }
.logo-icon { width: 28px; height: 28px; background: var(--primary-light); border-radius: 6px; display: flex; align-items: center; justify-content: center; }
.logo-sub { font-size: 10px; color: var(--sidebar-text); margin-top: 2px; letter-spacing: 0.5px; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-group { margin-bottom: 4px; }
.nav-label { font-size: 10px; font-weight: 600; color: rgba(148,180,216,0.5); padding: 8px 16px 4px; letter-spacing: 1px; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 16px; font-size: 13px; color: var(--sidebar-text); border-radius: 0; transition: background 0.15s, color 0.15s; position: relative; cursor: pointer; border-left: 3px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: rgba(37,99,235,0.2); color: #fff; border-left-color: var(--primary-light); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-sub { padding-left: 8px; display: none; }
.nav-sub.open { display: block; }
.nav-sub .nav-item { padding-left: 40px; font-size: 12px; }
.nav-expand { margin-left: auto; transition: transform 0.2s; }
.nav-item.has-sub.open .nav-expand { transform: rotate(90deg); }
.sidebar-version { padding: 12px 16px; font-size: 11px; color: rgba(148,180,216,0.4); border-top: 1px solid rgba(255,255,255,0.06); }

/* ---- MAIN CONTENT ---- */
.main-content { margin-left: 200px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }
.topbar { background: var(--white); border-bottom: 1px solid var(--border); padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow); }
.topbar-left { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.topbar-left span { color: var(--text); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.page-content { padding: 24px; flex: 1; min-width: 0; }


/* ---- BREADCRUMB ---- */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-bottom: 20px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary-light); }
.breadcrumb-sep { color: #cbd5e1; }

/* ---- PAGE HEADER ---- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.page-title-sub { font-size: 13px; color: var(--text-muted); font-weight: 400; }
.page-actions { display: flex; align-items: center; gap: 8px; }

/* ---- CARDS ---- */
.card { background: var(--white); border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow); }
.card-body { padding: 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 18px 20px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon.blue { background: #eff6ff; color: var(--primary-light); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.yellow { background: var(--warning-bg); color: var(--warning); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-icon.purple { background: #f5f3ff; color: #7c3aed; }
.stat-num { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---- BUTTONS ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 500; border: 1px solid transparent; transition: background 0.15s, border-color 0.15s, opacity 0.15s; white-space: nowrap; }
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--primary-light); color: #fff; border-color: var(--primary-light); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-secondary { background: var(--white); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--white); color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon svg { width: 15px; height: 15px; }
.btn[disabled], .btn.loading { opacity: 0.7; pointer-events: none; }

/* ---- TABLE ---- */
.table-card { background: var(--white); border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.table-toolbar { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-group { display: flex; align-items: center; gap: 0; }
.search-select { border: 1px solid var(--border); border-right: none; padding: 7px 10px; border-radius: var(--radius) 0 0 var(--radius); font-size: 12px; background: var(--bg); color: var(--text); height: 34px; }
.search-input { border: 1px solid var(--border); padding: 7px 10px; border-radius: 0; font-size: 13px; height: 34px; width: 200px; color: var(--text); }
.search-input:focus { outline: none; border-color: var(--primary-light); }
.search-btn { background: var(--primary); border: 1px solid var(--primary); color: #fff; padding: 7px 12px; border-radius: 0 var(--radius) var(--radius) 0; height: 34px; display: flex; align-items: center; }
.search-btn svg { width: 14px; height: 14px; }
.table-actions-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.page-size-select { border: 1px solid var(--border); padding: 6px 8px; border-radius: var(--radius); font-size: 12px; color: var(--text); background: var(--white); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
thead th { background: #f8fafc; padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--text); }
thead th .sort-icon { display: inline; color: var(--primary-light); margin-left: 4px; }
tbody tr { border-bottom: 1px solid #f1f5f9; transition: background 0.1s; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 10px 14px; font-size: 13px; color: var(--text); vertical-align: middle; }
tbody tr.row-highlight-yellow { background: #fffbeb; }
tbody tr.row-highlight-blue { background: #eff6ff; }
tbody tr.row-highlight-pink { background: #fff0f0; }
.table-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.table-count { font-size: 12px; color: var(--text-muted); }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 4px; }
.page-btn { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); border: 1px solid var(--border); background: var(--white); font-size: 12px; color: var(--text-muted); cursor: pointer; }
.page-btn:hover { background: var(--bg); }
.page-btn.active { background: var(--primary-light); color: #fff; border-color: var(--primary-light); }
.page-btn[disabled] { opacity: 0.4; pointer-events: none; }

/* ---- STATUS DROPDOWNS in TABLE ---- */
.status-dropdown { position: relative; display: inline-block; }
.status-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius); font-size: 12px; font-weight: 500; border: none; cursor: pointer; white-space: nowrap; }
.status-btn svg { width: 10px; height: 10px; }
.status-btn.open-status { background: #dcfce7; color: #16a34a; }
.status-btn.pending-status { background: #fef3c7; color: #d97706; }
.status-btn.packed-status { background: #dbeafe; color: #2563eb; }
.status-btn.delivered-status { background: #dcfce7; color: #16a34a; }
.status-btn.cancelled-status { background: #fee2e2; color: #dc2626; }
.status-btn.returned-status  { background: #fdf4ff; color: #7e22ce; }
.status-btn.transit-status   { background: #e0f2fe; color: #0284c7; }
.status-btn.sync-not { background: #fef3c7; color: #d97706; }
.status-btn.sync-ok { background: #dcfce7; color: #16a34a; }
.status-btn.sync-fail { background: #fee2e2; color: #dc2626; }
.status-btn.win { background: #dcfce7; color: #16a34a; }
.status-btn.lost { background: #fee2e2; color: #dc2626; }
.status-btn.no-answer { background: #f3f4f6; color: #6b7280; }
.status-btn.on-hold { background: #fef3c7; color: #d97706; }
.status-btn.fake { background: #fee2e2; color: #dc2626; }

.status-menu { position: absolute; top: calc(100% + 4px); left: 0; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 25px rgba(0,0,0,0.12); z-index: 200; min-width: 150px; display: none; }
.status-menu.show { display: block; }
.status-menu-item { display: flex; align-items: center; gap: 8px; padding: 9px 14px; font-size: 13px; cursor: pointer; transition: background 0.1s; }
.status-menu-item:hover { background: var(--bg); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-green { background: #16a34a; }
.dot-yellow { background: #d97706; }
.dot-blue { background: #2563eb; }
.dot-red { background: #dc2626; }
.dot-gray { background: #9ca3af; }
.dot-purple { background: #7c3aed; }

/* ---- FORMS ---- */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.form-row.one { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.3px; }
.form-label.required::after { content: ' *'; color: var(--danger); }
.form-control { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; font-size: 13px; color: var(--text); background: var(--white); width: 100%; transition: border-color 0.15s; }
.form-control:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }
.form-control::placeholder { color: #a0aec0; }
.form-hint { font-size: 11px; color: var(--text-muted); }
.live-preview { font-size: 13px; color: var(--primary-light); font-weight: 500; margin-top: 4px; min-height: 18px; }

/* ---- MODAL ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 500; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal { background: var(--white); border-radius: var(--radius-lg); width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.modal-header { padding: 18px 22px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--white); z-index: 1; }
.modal-title { font-size: 16px; font-weight: 700; color: var(--text); }
.modal-close { background: none; border: none; color: var(--text-muted); width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); cursor: pointer; }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 14px 22px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-lg { max-width: 900px; }

/* ---- ALERTS ---- */
.alert { padding: 12px 16px; border-radius: var(--radius); display: flex; align-items: flex-start; gap: 10px; font-size: 13px; }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-info { background: var(--info-bg); color: var(--primary-light); }
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

/* ---- BADGES ---- */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 100px; font-size: 11px; font-weight: 600; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-yellow { background: var(--warning-bg); color: var(--warning); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-purple { background: #f5f3ff; color: #7c3aed; }

/* ---- TOAST NOTIFICATION ---- */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 10px; font-size: 13px; min-width: 250px; max-width: 360px; pointer-events: all; animation: slideIn 0.25s ease; }
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--primary-light); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast-success svg { color: var(--success); }
.toast-error svg { color: var(--danger); }
.toast-info svg { color: var(--primary-light); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- USER AVATAR ---- */
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.user-menu { position: relative; }
.user-dropdown { position: absolute; right: 0; top: calc(100% + 8px); background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); min-width: 180px; display: none; z-index: 200; }
.user-dropdown.show { display: block; }
.user-dropdown-item { display: flex; align-items: center; gap: 8px; padding: 9px 14px; font-size: 13px; color: var(--text); cursor: pointer; transition: background 0.1s; }
.user-dropdown-item:hover { background: var(--bg); }
.user-dropdown-item svg { width: 14px; height: 14px; color: var(--text-muted); }
.user-dropdown-divider { border-top: 1px solid var(--border); margin: 4px 0; }

/* ---- ORDER DETAIL ---- */
.order-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.detail-section { background: #f8fafc; border-radius: var(--radius); padding: 14px; }
.detail-section h4 { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.detail-row { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; border-bottom: 1px solid #eef1f5; }
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); }
.detail-value { font-weight: 500; color: var(--text); text-align: right; }

/* ---- SYNC PROGRESS ---- */
.sync-progress { height: 8px; background: #e2e8f0; border-radius: 100px; overflow: hidden; }
.sync-progress-bar { height: 100%; background: linear-gradient(90deg, #16a34a, #4ade80); border-radius: 100px; transition: width 0.3s; }

/* ---- SHIPPING STATS ---- */
.shipping-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.ship-stat { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow); }
.ship-stat-num { font-size: 28px; font-weight: 700; color: var(--text); }
.ship-stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ship-stat-icon { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.ship-icon-blue { background: #eff6ff; color: var(--primary-light); }
.ship-icon-spin { background: #eff6ff; color: var(--primary-light); }
.ship-icon-red { background: var(--danger-bg); color: var(--danger); }
.ship-icon-green { background: var(--success-bg); color: var(--success); }

/* ---- LOW STOCK ALERT ---- */
.low-stock-alert { background: var(--danger-bg); border: 1px solid #fca5a5; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--danger); }

/* ---- CHECKBOX ---- */
.checkbox-cell { width: 36px; }
.custom-check { width: 16px; height: 16px; accent-color: var(--primary-light); cursor: pointer; }

/* ---- SOURCE ICONS ---- */
.source-icon { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.source-icon svg { width: 16px; height: 16px; }

/* ---- COPY BUTTON ---- */
.copy-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 2px; border-radius: 4px; }
.copy-btn:hover { color: var(--primary-light); }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- LOADING SPINNER ---- */
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; }
.spinner-dark { border-color: rgba(37,99,235,0.2); border-top-color: var(--primary-light); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- EMPTY STATE ---- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; color: #cbd5e1; margin-bottom: 12px; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state-sub { font-size: 13px; }

/* ---- TABS ---- */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn { padding: 10px 16px; font-size: 13px; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; background: none; border-top: none; border-left: none; border-right: none; transition: color 0.15s, border-color 0.15s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary-light); border-bottom-color: var(--primary-light); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- PRINT ---- */
@media print { .sidebar, .topbar, .no-print { display: none !important; } .main-content { margin-left: 0; } }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .sidebar { width: 0; overflow: hidden; }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .shipping-stats { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .order-detail-grid { grid-template-columns: 1fr; }
}
