/* =============================================================
   Offer Generator — Premium Admin CSS
   Built on Bootstrap 5.3
   ============================================================= */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --sidebar-width: 260px;
  --sidebar-bg:    #0f172a;
  --sidebar-text:  #94a3b8;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-active-bg: rgba(99,102,241,0.15);
  --sidebar-active-text: #a5b4fc;
  --sidebar-active-border: #6366f1;

  --topbar-height: 60px;
  --topbar-bg:     #ffffff;
  --topbar-border: #e2e8f0;

  --page-bg:       #f1f5f9;
  --card-bg:       #ffffff;
  --card-radius:   12px;
  --card-shadow:   0 1px 3px rgba(0,0,0,.07), 0 4px 12px rgba(0,0,0,.04);

  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #0ea5e9;

  --text-primary:  #1e293b;
  --text-muted:    #64748b;
  --text-light:    #94a3b8;
  --border:        #e2e8f0;

  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--page-bg);
  height: 100%;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ── Layout ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform .25s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s ease;
}

/* ── Sidebar Brand ──────────────────────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  min-height: var(--topbar-height);
  flex-shrink: 0;
}

.sidebar-brand-icon { font-size: 22px; color: var(--sidebar-active-border); }
.sidebar-brand-text {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logo {
  width: 32px; height: 32px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}

/* ── Sidebar Nav ────────────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s ease;
  cursor: pointer;
}

.sidebar-link i {
  font-size: 17px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  opacity: .8;
}

.sidebar-link:hover {
  color: #fff;
  background: var(--sidebar-hover);
  text-decoration: none;
}

.sidebar-link.active {
  color: var(--sidebar-active-text);
  background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-active-border);
}

.sidebar-link.active i { opacity: 1; }

.sidebar-link-logout {
  margin-top: 4px;
}
.sidebar-link-logout:hover {
  color: #fca5a5;
  background: rgba(239,68,68,0.1);
}

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 8px 16px;
}

/* ── Sidebar Footer ─────────────────────────────────────────── */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-avatar {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-user-name  { font-size: 13px; font-weight: 600; color: #e2e8f0; line-height: 1.2; }
.sidebar-user-role  { font-size: 11px; color: var(--sidebar-text); }

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  flex-shrink: 0;
  box-shadow: 0 1px 0 var(--topbar-border);
}

.topbar-toggle {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: none;
  line-height: 1;
  transition: color .15s;
}
.topbar-toggle:hover { color: var(--text-primary); background: var(--border); }

.topbar-breadcrumb { flex: 1; }

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.topbar-new-btn {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Content Area ───────────────────────────────────────────── */
.content-area {
  flex: 1;
  padding: 24px;
}

/* ── Sidebar Overlay (mobile) ───────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}

/* ── Flash Banner ───────────────────────────────────────────── */
.flash-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  font-size: 13.5px;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  position: relative;
}
.flash-banner i { font-size: 16px; flex-shrink: 0; }
.flash-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  opacity: .6;
  padding: 0 4px;
  line-height: 1;
}
.flash-close:hover { opacity: 1; }

.flash-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.flash-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.flash-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  border-radius: var(--card-radius) var(--card-radius) 0 0;
}

.card-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-body { padding: 20px; }

/* ── Stat Cards ─────────────────────────────────────────────── */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow .2s, transform .2s;
}
.stat-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

.stat-icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon-primary   { background: rgba(99,102,241,.12); color: var(--primary); }
.stat-icon-success   { background: rgba(16,185,129,.12); color: var(--success); }
.stat-icon-warning   { background: rgba(245,158,11,.12); color: var(--warning); }
.stat-icon-danger    { background: rgba(239,68,68,.12);  color: var(--danger);  }
.stat-icon-info      { background: rgba(14,165,233,.12); color: var(--info);    }
.stat-icon-dark      { background: rgba(30,41,59,.1);    color: #334155;        }

.stat-body {}
.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-responsive { border-radius: 0 0 var(--card-radius) var(--card-radius); overflow: hidden; }

.table {
  margin: 0;
  font-size: 13.5px;
}

.table thead th {
  background: #f8fafc;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-primary);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover td { background: #f8fafc; }

.table-actions { display: flex; gap: 4px; align-items: center; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 8px;
  padding: 7px 16px;
  transition: all .15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-sm { font-size: 12.5px; padding: 5px 12px; border-radius: 6px; gap: 5px; }
.btn-lg { font-size: 15px; padding: 10px 22px; border-radius: 10px; gap: 8px; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn-success { background: var(--success); border-color: var(--success); }
.btn-danger  { background: var(--danger);  border-color: var(--danger);  }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-info    { background: var(--info);    border-color: var(--info); color: #fff; }

.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

.btn-outline-secondary { color: var(--text-muted); border-color: var(--border); }
.btn-outline-secondary:hover { background: var(--border); color: var(--text-primary); }

.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }
.btn-icon.btn-sm { width: 28px; height: 28px; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-control, .form-select {
  font-size: 13.5px;
  border-color: var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  background-color: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
  outline: none;
}
.form-control-sm, .form-select-sm { font-size: 12.5px; padding: 5px 10px; border-radius: 6px; }

.form-control::placeholder { color: #b0bec5; }

textarea.form-control { resize: vertical; min-height: 80px; }

.input-group .form-control { border-radius: 8px !important; }
.input-group .btn { border-radius: 8px !important; }
.input-group { gap: 4px; }
.input-group .form-control { flex: 1; }

/* ── Status Badges ───────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-status-draft    { background: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; }
.badge-status-sent     { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-status-pending  { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.badge-status-accepted { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.badge-status-rejected { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.badge-status-done     { background: #f3f4f6; color: #1e293b; border: 1px solid #d1d5db; background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-header-left {}
.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Filters Bar ─────────────────────────────────────────────── */
.filter-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.filter-bar .form-group { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.filter-bar .form-label { margin-bottom: 0; }

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 52px; opacity: .3; margin-bottom: 16px; display: block; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.empty-state-text  { font-size: 13.5px; margin-top: 6px; }

/* ── Modals ──────────────────────────────────────────────────── */
.modal-content { border: none; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header  { border-bottom: 1px solid var(--border); padding: 18px 22px; }
.modal-footer  { border-top: 1px solid var(--border); }
.modal-title   { font-size: 15px; font-weight: 600; }

/* ── Offer Builder ───────────────────────────────────────────── */
.offer-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  margin-bottom: 18px;
  box-shadow: var(--card-shadow);
}
.offer-section-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 600;
}
.offer-section-header i { color: var(--primary); font-size: 16px; }
.offer-section-body { padding: 20px; }

.offer-items-table thead th { font-size: 11px; }
.offer-items-table td { padding: 8px 10px; }

.item-product-name { font-weight: 500; font-size: 13.5px; }
.item-product-sku  { font-size: 11.5px; color: var(--text-muted); }

.offer-totals {
  background: #f8fafc;
  border-radius: 0 0 var(--card-radius) var(--card-radius);
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.offer-total-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13.5px; }
.offer-total-row.grand-total { font-size: 16px; font-weight: 700; border-top: 1px solid var(--border); margin-top: 8px; padding-top: 10px; }

.offer-global-controls {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.offer-global-controls-title { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }

/* ── Product picker modal ────────────────────────────────────── */
.product-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
.product-picker-item:last-child { border-bottom: none; }
.product-picker-item:hover { background: #f8fafc; }
.product-picker-sku { font-size: 11.5px; color: var(--text-muted); }
.product-picker-name { font-size: 13.5px; font-weight: 500; }
.product-picker-prices { font-size: 12px; color: var(--text-muted); text-align: right; white-space: nowrap; }

/* ── Offer view ──────────────────────────────────────────────── */
.offer-view-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border-radius: var(--card-radius) var(--card-radius) 0 0;
  padding: 28px 32px;
  color: #fff;
}
.offer-number { font-size: 28px; font-weight: 700; }
.offer-meta   { font-size: 13px; color: #94a3b8; margin-top: 4px; }

/* ── Settings page ───────────────────────────────────────────── */
.settings-section { margin-bottom: 28px; }
.settings-section-title { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }

/* ── Import page ─────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(99,102,241,.04);
}
.upload-zone-icon { font-size: 40px; color: var(--text-light); margin-bottom: 12px; }
.upload-zone-text { font-size: 14px; color: var(--text-muted); }
.upload-zone input[type=file] { display: none; }

.import-result-card {
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: 16px;
}

/* ── Print styles ────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .flash-banner, .topbar-new-btn,
  .btn, .no-print, .page-actions { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .content-area { padding: 0 !important; }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }
  .sidebar-overlay.open { display: block; }

  .main-wrapper { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .content-area { padding: 16px; }

  .filter-bar { flex-direction: column; }
  .filter-bar .form-group { min-width: 100%; }
}

@media (max-width: 575.98px) {
  .content-area { padding: 12px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }
  .card-body { padding: 14px; }
  .topbar { padding: 0 14px; }
}

/* ── Utilities ───────────────────────────────────────────────── */
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.text-xs { font-size: 11.5px; }
.text-sm { font-size: 12.5px; }

.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }

.rounded-xl { border-radius: 12px !important; }

.border-0 { border: 0 !important; }
.shadow-sm { box-shadow: var(--card-shadow) !important; }

/* Loading spinner */
.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.7);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Scroll table on mobile */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Inline editable cells */
.editable-cell { cursor: pointer; }
.editable-cell:hover { background: rgba(99,102,241,.06); border-radius: 4px; }

/* ── Login Page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 18px;
  padding: 40px 36px;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo-icon {
  width: 60px; height: 60px;
  background: var(--primary);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  margin-bottom: 14px;
}
.login-title { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.login-subtitle { font-size: 13.5px; color: var(--text-muted); margin-top: 4px; }

/* Custom scrollbar (WebKit) */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Product thumbnails ──────────────────────────────────── */
.product-thumb-sm {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.product-img-preview {
  max-width: 180px;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
}

/* ── Product picker — image in list ─────────────────────── */
.product-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background .12s;
  border-bottom: 1px solid #f1f5f9;
}
.product-picker-item:hover { background: #f8fafc; }
.product-picker-item:last-child { border-bottom: none; }

/* ── Client search dropdown ──────────────────────────────── */
.client-selector-wrapper .input-group-text {
  background: var(--card-bg);
}
#clientSearchDropdown .client-search-item:last-child {
  border-bottom: none !important;
}

/* ── Sidebar logout color ────────────────────────────────── */
.sidebar-link-logout {
  color: #f87171 !important;
}
.sidebar-link-logout:hover {
  background: rgba(239,68,68,.1) !important;
  color: #ef4444 !important;
}

/* ── btn-ghost (topbar logout on mobile) ─────────────────── */
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: .25rem .5rem;
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--sidebar-hover);
}
