@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,300&display=swap');

/* ---- CSS Variables (overridden per customer via JS) ---- */
:root {
  --primary: #0f0f1a;
  --primary-light: #1a1a2e;
  --surface: #16213e;
  --surface2: #1e2a45;
  --accent: #c9a84c;
  --accent-dim: rgba(201,168,76,0.15);
  --accent-glow: rgba(201,168,76,0.3);
  --text: #f0efe8;
  --text-muted: #8a8fa8;
  --text-dim: #4a5068;
  --border: rgba(255,255,255,0.07);
  --border-accent: rgba(201,168,76,0.3);
  --danger: #e05c5c;
  --success: #4caf82;
  --warning: #e0a84c;
  --info: #4c8fe0;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-accent: 0 4px 24px rgba(201,168,76,0.2);
  --font-display: 'DM Sans', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --nav-height: 64px;
  --header-height: 60px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--primary);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- Login Screen ---- */
#login-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100vh;
  background: var(--primary);
  padding: 2rem;
  position: relative;
  overflow: hidden;
}
#login-screen::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 0%, var(--accent-dim), transparent 70%);
  pointer-events: none;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .app-icon {
  width: 64px; height: 64px;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 1rem;
}
.login-logo h1 {
  font-family: var(--font-display);
  font-size: 1.8rem; font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}
.login-logo p {
  font-size: 0.85rem; color: var(--text-muted);
  margin-top: 0.25rem;
}
.login-company {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.login-company h2 {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 600;
  color: var(--accent);
}
.login-error {
  background: rgba(224,92,92,0.1);
  border: 1px solid rgba(224,92,92,0.3);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.login-error.show { display: block; }

/* ---- App Shell ---- */
#app { display: none; min-height: 100vh; flex-direction: column; }
#app.visible { display: flex; }

/* ---- Header ---- */
.app-header {
  height: var(--header-height);
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem;
  position: sticky; top: 0; z-index: 100;
}
.header-title {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 700;
  color: var(--text);
}
.header-back {
  display: none;
  background: none; border: none;
  color: var(--accent); cursor: pointer;
  font-size: 1.1rem; padding: 0.5rem;
  align-items: center; gap: 0.4rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
}
.header-back.show { display: flex; }
.header-action {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 0.5rem; font-size: 1.2rem;
  transition: color 0.2s;
}
.header-action:hover { color: var(--accent); }

/* ---- Bottom Nav ---- */
.bottom-nav {
  height: var(--nav-height);
  background: var(--primary-light);
  border-top: 1px solid var(--border);
  display: flex;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0.25rem; cursor: pointer;
  color: var(--text-dim);
  transition: color 0.2s;
  position: relative;
  background: none; border: none;
  font-family: var(--font-body);
}
.nav-item .nav-icon { font-size: 1.3rem; display:flex; align-items:center; justify-content:center; }
.nav-item .nav-icon svg { width: 22px; height: 22px; stroke: currentColor; }
.nav-item .nav-label { font-size: 0.65rem; letter-spacing: 0.3px; }
.nav-item.active { color: var(--accent); }
.nav-item.active::before {
  content: '';
  position: absolute; top: 0; left: 20%; right: 20%;
  height: 2px; background: var(--accent);
  border-radius: 0 0 4px 4px;
}

/* ---- Page Content ---- */
.page-content {
  flex: 1;
  padding: 1rem;
  padding-bottom: calc(var(--nav-height) + 1rem);
  overflow-y: auto;
}

/* ---- Pages ---- */
.page { display: none; }
.page.active { display: block; }

/* ---- Dashboard ---- */
.dashboard-greeting {
  margin-bottom: 1.5rem;
}
.dashboard-greeting h2 {
  font-family: var(--font-display);
  font-size: 1.5rem; font-weight: 700;
}
.dashboard-greeting p { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.2rem; }

.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.75rem; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: attr(data-icon);
  position: absolute; right: 0.75rem; bottom: 0.5rem;
  font-size: 2rem; opacity: 0.1;
}
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 1.8rem; font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.stat-card .stat-label {
  font-size: 0.75rem; color: var(--text-muted);
  margin-top: 0.4rem; text-transform: uppercase; letter-spacing: 0.5px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1rem; font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  position: relative;
}
.card:active { transform: scale(0.98); }
.card:hover { border-color: var(--border-accent); }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.card-title { font-weight: 600; font-size: 0.95rem; }
.card-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }
.card-meta { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.6rem; flex-wrap: wrap; }
.card-thumb {
  width: 48px; height: 48px; border-radius: 8px;
  object-fit: cover; background: var(--surface2);
  flex-shrink: 0;
}

/* ---- Badges / Stage Pills ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 20px; font-size: 0.7rem;
  font-weight: 500; letter-spacing: 0.3px;
  text-transform: uppercase;
}
.badge-inquiry  { background: rgba(76,143,224,0.15); color: var(--info); }
.badge-offer    { background: rgba(201,168,76,0.15); color: var(--accent); }
.badge-negotiation { background: rgba(224,168,76,0.15); color: var(--warning); }
.badge-order    { background: rgba(76,175,130,0.15); color: var(--success); }

/* ---- FAB ---- */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 1rem);
  right: 1rem;
  width: 52px; height: 52px;
  background: var(--accent);
  color: var(--primary);
  border: none; border-radius: 50%;
  font-size: 1.5rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-accent);
  z-index: 90;
  transition: transform 0.2s, box-shadow 0.2s;
}
.fab:active { transform: scale(0.92); }
.fab.hidden { display: none; }

/* ---- Forms ---- */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block; font-size: 0.8rem;
  color: var(--text-muted); margin-bottom: 0.4rem;
  text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 500;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a8fa8' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; padding-right: 2.5rem; }
.form-select option { background: var(--surface); }

/* ---- Image Upload ---- */
.image-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  position: relative;
  overflow: hidden;
}
.image-upload-area:hover { border-color: var(--accent); }
.image-upload-area.has-image { border-style: solid; border-color: var(--border-accent); }
.image-upload-area img { max-height: 120px; border-radius: 8px; margin-bottom: 0.5rem; }
.image-upload-area p { font-size: 0.85rem; color: var(--text-muted); }
.image-upload-area input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-progress {
  height: 3px; background: var(--border);
  border-radius: 2px; margin-top: 0.5rem; overflow: hidden;
}
.upload-progress-bar {
  height: 100%; background: var(--accent);
  width: 0%; transition: width 0.3s; border-radius: 2px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem; padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm); border: none;
  font-family: var(--font-body); font-size: 0.9rem;
  font-weight: 500; cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  width: 100%; margin-bottom: 0.5rem;
  text-align: center;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--primary); font-weight: 600; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: rgba(224,92,92,0.15); color: var(--danger); border: 1px solid rgba(224,92,92,0.3); }
.btn-whatsapp { background: #25d366; color: #fff; }
.btn-email { background: var(--info); color: #fff; }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.8rem; width: auto; margin-bottom: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Product Selector (for packages/offers) ---- */
.product-selector {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.product-selector-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.product-selector-item:last-child { border-bottom: none; }
.product-selector-item:hover { background: var(--surface2); }
.product-selector-item.selected { background: var(--accent-dim); }
.product-selector-item img {
  width: 40px; height: 40px; border-radius: 6px;
  object-fit: cover; background: var(--surface2);
}
.product-selector-item .item-info { flex: 1; }
.product-selector-item .item-name { font-size: 0.9rem; font-weight: 500; }
.product-selector-item .item-price { font-size: 0.8rem; color: var(--text-muted); }
.product-selector-item .item-check { color: var(--accent); font-size: 1.1rem; }
.qty-control {
  display: flex; align-items: center; gap: 0.5rem;
}
.qty-btn {
  width: 28px; height: 28px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text);
  cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}
.qty-input {
  width: 40px; text-align: center;
  background: none; border: none;
  color: var(--text); font-size: 0.9rem;
}

/* ---- Offer Items Table ---- */
.offer-items-table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; }
.offer-items-table th {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); padding: 0.5rem; text-align: left;
  border-bottom: 1px solid var(--border);
}
.offer-items-table td { padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); font-size: 0.85rem; vertical-align: middle; }
.offer-items-table tr:last-child td { border-bottom: none; }
.price-input {
  width: 80px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); padding: 0.3rem 0.4rem;
  font-size: 0.85rem; text-align: right;
}

/* ---- Stage Selector ---- */
.stage-steps {
  display: flex; gap: 0; margin: 1rem 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.stage-step {
  flex: 1; padding: 0.6rem 0.2rem;
  text-align: center; font-size: 0.7rem;
  cursor: pointer; transition: all 0.2s;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  background: none;
  font-family: var(--font-body);
}
.stage-step:last-child { border-right: none; }
.stage-step.active-inquiry  { background: rgba(76,143,224,0.2); color: var(--info); }
.stage-step.active-offer    { background: rgba(201,168,76,0.2); color: var(--accent); }
.stage-step.active-negotiation { background: rgba(224,168,76,0.2); color: var(--warning); }
.stage-step.active-order    { background: rgba(76,175,130,0.2); color: var(--success); }

/* ---- Detail View ---- */
.detail-section { margin-bottom: 1.5rem; }
.detail-section-title {
  font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted);
  margin-bottom: 0.75rem; font-weight: 600;
}
.detail-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; align-items: flex-start; }
.detail-label { font-size: 0.8rem; color: var(--text-muted); min-width: 80px; flex-shrink: 0; }
.detail-value { font-size: 0.9rem; color: var(--text); }
.product-image-large {
  width: 100%; max-height: 200px;
  object-fit: cover; border-radius: var(--radius);
  margin-bottom: 1rem;
}

/* ---- Total Row ---- */
.total-row {
  display: flex; justify-content: space-between;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}
.total-row.grand {
  border-top: 2px solid var(--accent);
  margin-top: 0.25rem;
}
.total-row .label { color: var(--text-muted); font-size: 0.9rem; }
.total-row .value { font-weight: 600; color: var(--text); }
.total-row.grand .value { color: var(--accent); font-size: 1.1rem; font-family: var(--font-display); }

/* ---- Empty State ---- */
.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3 { font-family: var(--font-display); font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--text); }
.empty-state p { font-size: 0.85rem; }

/* ---- Toast ---- */
#toast {
  position: fixed; bottom: calc(var(--nav-height) + 1rem);
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 0.75rem 1.5rem;
  border-radius: 100px; font-size: 0.85rem;
  opacity: 0; transition: all 0.3s;
  z-index: 999; white-space: nowrap;
  box-shadow: var(--shadow);
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success { border-color: var(--success); color: var(--success); }
#toast.error { border-color: var(--danger); color: var(--danger); }

/* ---- Loading ---- */
.loading-spinner {
  display: flex; align-items: center; justify-content: center;
  padding: 3rem; color: var(--text-muted);
  flex-direction: column; gap: 1rem;
}
.spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Overlay / Modal ---- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200; display: none;
  align-items: flex-end;
}
.overlay.show { display: flex; }
.sheet-modal {
  background: var(--primary-light);
  border-radius: 24px 24px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  width: 100%; max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sheet-modal-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 1.5rem;
}
.sheet-modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 700;
  margin-bottom: 1.25rem;
}

/* ---- Search Bar ---- */
.search-bar {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
}
.search-bar input {
  flex: 1; background: none; border: none;
  color: var(--text); font-family: var(--font-body);
  font-size: 0.9rem;
}
.search-bar input:focus { outline: none; }
.search-bar input::placeholder { color: var(--text-dim); }

/* ---- Offer PDF Action Bar ---- */
.pdf-actions {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin-top: 1rem;
}
.pdf-actions .btn { flex: 1; min-width: 120px; margin-bottom: 0; }

/* ---- Misc ---- */
.divider { height: 1px; background: var(--border); margin: 1rem 0; }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.mt-1 { margin-top: 0.5rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 100px; padding: 0.2rem 0.6rem;
  font-size: 0.75rem; color: var(--text-muted);
}
.img-placeholder {
  width: 40px; height: 40px; border-radius: 6px;
  background: var(--surface2); display: flex;
  align-items: center; justify-content: center;
  font-size: 1.2rem; color: var(--text-dim);
  flex-shrink: 0;
}

/* ---- Light Mode ---- */
body.light-mode {
  --primary: #f4f5f7;
  --primary-light: #ffffff;
  --surface: #ffffff;
  --surface2: #f0f1f5;
  --text: #1a1a2e;
  --text-muted: #6b7080;
  --text-dim: #a0a5b8;
  --border: rgba(0,0,0,0.08);
  --shadow: 0 4px 24px rgba(0,0,0,0.1);
}

/* ---- Header Right Actions ---- */
.header-actions {
  display: flex; align-items: center; gap: 0.25rem;
}
.header-action {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 0.5rem; border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.header-action:hover { color: var(--accent); background: var(--accent-dim); }
.header-action svg { width: 20px; height: 20px; }

/* ---- Customer List Action Buttons ---- */
.customer-actions {
  display: flex; gap: 0.5rem; margin-top: 0.6rem;
}
.action-btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px; border: 1px solid var(--border);
  font-size: 0.75rem; font-weight: 500;
  cursor: pointer; background: var(--surface2);
  color: var(--text-muted); font-family: var(--font-body);
  transition: all 0.2s;
  text-decoration: none;
}
.action-btn:active { transform: scale(0.95); }
.action-btn.call { border-color: rgba(76,175,130,0.3); color: var(--success); }
.action-btn.call:hover { background: rgba(76,175,130,0.1); }
.action-btn.whatsapp { border-color: rgba(37,211,102,0.3); color: #25d366; }
.action-btn.whatsapp:hover { background: rgba(37,211,102,0.1); }
.action-btn svg { width: 13px; height: 13px; }
