/* =====================================================
   Appliance & Home Layby System — shared styles
   Brand: red #ED1C24, grey #777777, white
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
  --brand-red:       #ED1C24;
  --brand-red-dark:  #c81820;
  --brand-grey:      #777777;
  --brand-grey-dark: #444444;
  --brand-bg:        #F5F6F8;
  --brand-card:      #FFFFFF;
  --brand-border:    #E4E6EA;
  --brand-text:      #222222;
  --brand-muted:     #6B7280;
  --status-active:   #2F7D32;
  --status-amber:    #B26A00;
  --status-overdue:  #C0392B;
  --status-pending:  #1F5FB3;
  --status-done:     #2F7D32;
  --status-grey:     #6B7280;
  --shadow-sm:       0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md:       0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -1px rgba(0,0,0,0.04);
  --radius:          8px;
  --radius-sm:       4px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--brand-bg);
  color: var(--brand-text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--brand-red); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 0.5em; font-weight: 600; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; color: var(--brand-grey-dark); }

/* ---------- Top bar ---------- */
.topbar {
  background: white;
  border-bottom: 1px solid var(--brand-border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.topbar .brand { display: flex; align-items: center; gap: 12px; }
.topbar .brand img { height: 44px; width: auto; }
.topbar .brand-text { display: flex; flex-direction: column; line-height: 1; }
.topbar .brand-text .biz { font-weight: 700; font-size: 14px; color: var(--brand-grey-dark); letter-spacing: 0.5px;}
.topbar .brand-text .tagline { font-size: 9px; color: var(--brand-grey); letter-spacing: 1.5px; text-transform: uppercase; margin-top: 2px;}
.topbar nav { display: flex; gap: 4px; flex: 1; margin-left: 24px; flex-wrap: wrap; }
.topbar nav a {
  padding: 8px 14px; border-radius: var(--radius-sm);
  color: var(--brand-grey-dark); font-weight: 500;
  text-decoration: none; font-size: 13px;
}
.topbar nav a:hover { background: var(--brand-bg); }
.topbar nav a.active { background: var(--brand-red); color: white; }
.topbar .user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--brand-grey); }
.topbar .user button { padding: 6px 12px; }

/* ---------- Layout ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card {
  background: var(--brand-card);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px; margin-bottom: 16px;
  border-bottom: 1px solid var(--brand-border);
}
.card-header h2 { margin: 0; }
.card-header .actions { display: flex; gap: 8px; }

/* ---------- Stat cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  border: 1px solid var(--brand-border);
  border-radius: var(--radius);
  padding: 16px;
  border-left: 3px solid var(--brand-red);
}
.stat-card .label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--brand-muted); }
.stat-card .value { font-size: 26px; font-weight: 700; color: var(--brand-text); margin-top: 4px; }
.stat-card .sub { font-size: 12px; color: var(--brand-muted); margin-top: 2px; }
.stat-card.urgent { border-left-color: var(--status-overdue); }
.stat-card.success { border-left-color: var(--status-done); }
.stat-card.pending { border-left-color: var(--status-pending); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--brand-grey-dark);
  cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 500;
  transition: all 0.1s;
}
.btn:hover { border-color: var(--brand-grey); color: var(--brand-text); }
.btn-primary { background: var(--brand-red); color: white; border-color: var(--brand-red); }
.btn-primary:hover { background: var(--brand-red-dark); border-color: var(--brand-red-dark); color: white; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--brand-bg); }
.btn-danger { background: white; border-color: var(--status-overdue); color: var(--status-overdue); }
.btn-danger:hover { background: var(--status-overdue); color: white; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 600px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
.form-group label {
  display: block;
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--brand-muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.form-group .hint { font-size: 12px; color: var(--brand-muted); margin-top: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px;
  background: white;
  color: var(--brand-text);
  transition: border-color 0.1s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(237, 28, 36, 0.08);
}
textarea { min-height: 80px; resize: vertical; }
.checkbox-line { display: flex; align-items: flex-start; gap: 10px; }
.checkbox-line input[type="checkbox"] { width: auto; margin-top: 3px; }
.checkbox-line label { text-transform: none; letter-spacing: normal; font-size: 13px; color: var(--brand-text); }

/* ---------- Tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--brand-border); }
.data-table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--brand-muted); font-weight: 600; background: #FAFBFC;
}
.data-table tbody tr:hover { background: var(--brand-bg); cursor: pointer; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .center { text-align: center; }

/* ---------- Status pills ---------- */
.pill {
  display: inline-block; padding: 2px 8px;
  border-radius: 999px; font-size: 11px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.pill-active   { background: #E6F4EA; color: var(--status-active); }
.pill-overdue  { background: #FBEAE6; color: var(--status-overdue); }
.pill-pending  { background: #E3EDFB; color: var(--status-pending); }
.pill-completed{ background: #E6F4EA; color: var(--status-done); }
.pill-cancelled{ background: #EEEEEE; color: var(--status-grey); }
.pill-defaulted{ background: #FBEAE6; color: var(--status-overdue); }
.pill-owned    { background: #FFF1E6; color: #B26A00; }
.pill-consignment { background: #E6F0FB; color: #1F5FB3; }

/* ---------- Progress bar ---------- */
.progress {
  height: 8px; background: var(--brand-border);
  border-radius: 99px; overflow: hidden;
}
.progress-bar { height: 100%; background: var(--brand-red); transition: width 0.3s; }
.progress-bar.done { background: var(--status-done); }

/* ---------- Empty state ---------- */
.empty {
  padding: 48px 24px; text-align: center;
  color: var(--brand-muted); font-size: 14px;
}
.empty .big { font-size: 20px; color: var(--brand-grey-dark); margin-bottom: 6px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: none; z-index: 1000;
  align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: white; border-radius: var(--radius);
  width: 100%; max-width: 600px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.modal.wide { max-width: 900px; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--brand-border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { margin: 0; }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--brand-border); display: flex; justify-content: flex-end; gap: 8px; background: #FAFBFC; }
.modal-close { background: transparent; border: 0; font-size: 22px; cursor: pointer; color: var(--brand-muted); padding: 4px 8px; }

/* ---------- Toasts ---------- */
.toast-host { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--brand-text); color: white;
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13px; box-shadow: var(--shadow-md);
  min-width: 240px; max-width: 360px;
  animation: slidein 0.2s ease-out;
}
.toast.success { background: var(--status-done); }
.toast.error { background: var(--status-overdue); }
@keyframes slidein { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #FAFBFC 0%, var(--brand-bg) 100%);
  padding: 20px;
}
.auth-card {
  background: white; padding: 40px; border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%; max-width: 400px;
  text-align: center;
}
.auth-card img { height: 64px; margin-bottom: 20px; }
.auth-card h1 { font-size: 18px; margin-bottom: 24px; color: var(--brand-grey-dark); }
.auth-card .form-group { text-align: left; }
.auth-card .error { color: var(--status-overdue); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- Sidebar layout (used in admin layby detail and intake) ---------- */
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

/* ---------- Misc ---------- */
.muted { color: var(--brand-muted); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.right { text-align: right; }
.tag-strip { display: flex; gap: 6px; flex-wrap: wrap; }
hr { border: 0; border-top: 1px solid var(--brand-border); margin: 16px 0; }
.searchbar { display: flex; gap: 8px; align-items: center; }
.searchbar input { flex: 1; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--brand-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; padding-top: 2px; }
.kv dd { margin: 0; font-weight: 500; }

/* ---------- Action dropdown (used in toolbars) ---------- */
.action-dropdown { position: relative; display: inline-block; }
.action-dropdown summary {
  list-style: none; cursor: pointer; user-select: none;
}
.action-dropdown summary::-webkit-details-marker { display: none; }
.action-dropdown[open] > summary { background: var(--brand-bg); border-color: var(--brand-grey); }
.action-dropdown .dropdown-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 50;
  min-width: 220px;
  background: white; border: 1px solid var(--brand-border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 6px 0; overflow: hidden;
}
.action-dropdown .dropdown-menu button,
.action-dropdown .dropdown-menu a {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 14px; text-align: left;
  background: transparent; border: 0; cursor: pointer;
  font-family: inherit; font-size: 13px; color: var(--brand-text);
  text-decoration: none;
}
.action-dropdown .dropdown-menu button:hover,
.action-dropdown .dropdown-menu a:hover { background: var(--brand-bg); }
.action-dropdown .dropdown-menu .danger { color: var(--status-overdue); }
.action-dropdown .dropdown-menu .divider { height: 1px; background: var(--brand-border); margin: 4px 0; }

/* ---------- Dashboard task rows (replaces tables on dashboard) ---------- */
.task-list { display: flex; flex-direction: column; }
.task-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 4px; gap: 12px;
  border-bottom: 1px solid var(--brand-border);
  cursor: pointer; transition: background 0.1s;
}
.task-row:hover { background: var(--brand-bg); }
.task-row:last-child { border-bottom: 0; }
.task-row .task-code { font-weight: 700; color: var(--brand-red); font-size: 13px; }
.task-row .task-customer { font-size: 13px; color: var(--brand-text); margin-top: 2px; }
.task-row .task-meta { text-align: right; flex-shrink: 0; }
.task-row .task-amount { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.task-row .task-detail { font-size: 11px; color: var(--brand-muted); margin-top: 2px; }
.task-row.urgent .task-amount { color: var(--status-overdue); }

/* ---------- Wizard / stepper ---------- */
.wizard-steps {
  display: flex; align-items: center; gap: 4px;
  margin-bottom: 20px; padding: 16px;
  background: white; border: 1px solid var(--brand-border);
  border-radius: var(--radius);
}
.wizard-step {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--brand-muted);
  cursor: default;
}
.wizard-step .step-circle {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand-bg); color: var(--brand-muted);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  border: 2px solid var(--brand-border);
  transition: all 0.15s;
}
.wizard-step.active .step-circle {
  background: var(--brand-red); color: white;
  border-color: var(--brand-red);
}
.wizard-step.done .step-circle {
  background: var(--status-done); color: white;
  border-color: var(--status-done);
}
.wizard-step.active { color: var(--brand-text); font-weight: 600; }
.wizard-step.done { cursor: pointer; }
.wizard-step.done:hover { color: var(--brand-red); }
.wizard-connector {
  flex: 1; height: 2px; background: var(--brand-border);
  min-width: 16px; margin: 0 4px;
}
.wizard-step.done + .wizard-connector,
.wizard-connector.done { background: var(--status-done); }
.wizard-step-label { display: inline; font-size: 12px; }

.wizard-panel { display: none; }
.wizard-panel.active { display: block; }
.wizard-nav {
  display: flex; justify-content: space-between;
  margin-top: 20px; gap: 12px;
}
.wizard-nav .spacer { flex: 1; }

.wizard-summary {
  background: var(--brand-bg);
  border-radius: var(--radius); padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; font-size: 13px;
}
.wizard-summary .total { font-size: 18px; font-weight: 700; color: var(--brand-red); }

/* ---------- Mobile improvements ---------- */
@media (max-width: 600px) {
  .container { padding: 14px; }
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .topbar nav { margin-left: 0; gap: 2px; width: 100%; order: 3; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .topbar nav a { padding: 6px 10px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
  .topbar .brand img { height: 36px; }
  .topbar .user { font-size: 11px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 12px; border-left-width: 3px; }
  .stat-card .value { font-size: 20px; }
  .stat-card .label { font-size: 10px; }
  .stat-card .sub { font-size: 10px; }

  .page-header h1 { font-size: 20px; }
  .page-actions { width: 100%; }
  .page-actions .btn { font-size: 12px; padding: 7px 10px; }

  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 6px; }

  .card { padding: 14px; }
  .card-header { padding-bottom: 8px; margin-bottom: 12px; }
  .card-header h2 { font-size: 15px; }

  .wizard-steps { padding: 10px; gap: 2px; }
  .wizard-step-label { display: none !important; }
  .wizard-connector { min-width: 8px; }

  .modal { max-width: 100%; margin: 0; border-radius: 0; min-height: 100vh; }
  .modal-backdrop { padding: 0; }
}

/* ---------- Image lightbox (product zoom) ---------- */
.lightbox-backdrop {
  position: fixed; inset: 0; z-index: 1500;
  background: rgba(0, 0, 0, 0.88);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; cursor: zoom-out;
  animation: fadein 0.15s ease-out;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.lightbox-content {
  max-width: 95vw; max-height: 90vh;
  display: flex; flex-direction: column; align-items: center;
  cursor: default;
}
.lightbox-content img {
  max-width: 100%; max-height: 80vh; object-fit: contain;
  display: block; border-radius: 4px; background: white;
}
.lightbox-caption {
  color: white; text-align: center; padding: 12px 16px 0;
  font-size: 14px; font-weight: 500;
}
.lightbox-empty {
  color: white; padding: 60px 40px; font-size: 14px;
  background: rgba(255, 255, 255, 0.1); border-radius: 4px;
}
.lightbox-close {
  position: fixed; top: 16px; right: 18px;
  background: rgba(255, 255, 255, 0.15);
  color: white; border: 0; cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 26px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }

/* Zoom button overlay on product thumbnails */
.thumb-wrap { position: relative; }
.zoom-btn {
  position: absolute; top: 6px; right: 6px;
  background: rgba(255, 255, 255, 0.94); border: 0; cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: background 0.1s, transform 0.1s;
}
.zoom-btn:hover { background: white; transform: scale(1.08); }
.thumb-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-bg); color: var(--brand-muted);
  font-size: 28px;
}

/* ---------- Print ---------- */
@media print {
  .topbar, .page-actions, .btn, .modal-backdrop { display: none !important; }
  body { background: white; }
}
