/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

/* ── Builder Wrapper ── */
.builder-wrapper { min-height: 100vh; background: #f0ebe3; }

/* ── Header ── */
.app-header {
  background: linear-gradient(135deg, #6b1212 0%, #b01a1a 100%);
  color: #fff;
  padding: 10px 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.header-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.header-brand-info { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.brand-icon { font-size: 1.5rem; }
.header-brand-info h1 { margin: 0; font-size: 1.05rem; font-weight: 700; line-height: 1.2; }
.header-brand-info small { font-size: 0.7rem; opacity: 0.82; display: block; }

/* ── Header Nav ── */
.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-username {
  font-size: 0.78rem;
  opacity: 0.85;
  color: #fff;
  white-space: nowrap;
}
.nav-btn {
  font-size: 0.82rem;
  background: rgba(255,255,255,0.15);
  color: #fff;
  padding: 5px 11px;
  border-radius: 5px;
  text-decoration: none;
  font-weight: 600;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  line-height: 1.5;
  display: inline-block;
}
.nav-btn:hover { background: rgba(255,255,255,0.28); color: #fff; }

/* ── Hamburger toggle (hidden on desktop) ── */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  padding: 7px 8px;
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all 0.22s;
}
/* Animate to X when open */
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 640px) {
  .nav-toggle { display: flex; }

  .header-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: linear-gradient(160deg, #5c0f0f 0%, #8a1616 100%);
    padding: 10px 16px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
    z-index: 99;
  }
  .header-nav.open { display: flex; }

  .nav-username {
    font-size: 0.85rem;
    padding: 6px 4px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.18);
    margin-bottom: 2px;
    opacity: 0.75;
  }
  .nav-btn {
    font-size: 0.92rem;
    padding: 11px 14px;
    border-radius: 8px;
    text-align: left;
    width: 100%;
    background: rgba(255,255,255,0.12);
  }
  .nav-btn:hover { background: rgba(255,255,255,0.22); }
  /* Sign out form needs full width too */
  .nav-signout-form { width: 100%; }
}

/* ── Legacy .header-brand kept for any leftover refs ── */
.header-brand { display: flex; align-items: center; gap: 9px; max-width: 800px; margin: 0 auto; }

/* ── Shared horizontal alignment (search bar, banners, form) ── */
.builder-outer {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 8px;
}
@media (min-width: 600px) {
  .builder-outer { padding: 0 14px; }
}

/* ── Content ── */
.builder-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 32px;
}

/* ── Cards ── */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.07);
  border: 1px solid #e4d9cc;
}
.card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #7a1515;
  border-bottom: 1.5px solid #f0ebe3;
  padding-bottom: 7px;
  margin-bottom: 10px;
}
.card-icon { font-size: 0.9rem; }

/* ── Customer Card ── */
.customer-card { border-left: 3px solid #b01a1a; padding: 10px 12px; }
.customer-row { display: flex; align-items: center; gap: 10px; }
.customer-icon { font-size: 1.2rem; flex-shrink: 0; }
.phone-input {
  display: flex;
  border: 1.5px solid #ddd;
  border-radius: 7px;
  overflow: hidden;
  background: #fafafa;
}
.phone-prefix {
  padding: 8px 10px;
  background: #f0e8e0;
  color: #666;
  font-size: 16px;
  font-weight: 600;
  border-right: 1.5px solid #ddd;
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.phone-input input { border: none; background: transparent; flex: 1; border-radius: 0; min-width: 0; }
.phone-input:focus-within { border-color: #b01a1a; box-shadow: 0 0 0 2px rgba(176,26,26,0.12); }

/* ── Form Grid ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 359px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-field.col-span-2 { grid-column: span 1; }
}
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field.col-span-2 { grid-column: span 2; }
.form-field label {
  font-size: 0.68rem;
  font-weight: 600;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.required { color: #b01a1a; }
.optional { color: #ccc; font-weight: 400; text-transform: none; letter-spacing: 0; }

/* ── Inputs ── */
input[type='text'],
input[type='number'],
input[type='date'],
input[type='time'],
input[type='tel'],
select {
  padding: 8px 10px;
  border: 1.5px solid #ddd;
  border-radius: 7px;
  font-size: 16px;
  color: #2c2c2c;
  background: #fafafa;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
  min-height: 40px;
}
input:focus, select:focus {
  border-color: #b01a1a;
  box-shadow: 0 0 0 2px rgba(176,26,26,0.12);
  background: #fff;
}
.readonly-input { background: #f0ebe6; color: #888; cursor: default; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* ── Itinerary Day ── */
.itinerary-day {
  background: #fdf8f2;
  border: 1.5px solid #e4d9cc;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}
.day-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.day-badge {
  background: #7a1515;
  color: #fff;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 46px;
  text-align: center;
}
.day-header-right { display: flex; align-items: center; gap: 6px; }
.drop-pill {
  background: #e85d04;
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 600;
}
.btn-remove-day {
  background: none;
  border: 1.5px solid #ccc;
  color: #999;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-remove-day:hover { background: #ffeeee; border-color: #b01a1a; color: #b01a1a; }

/* ── Places ── */
.places-section { margin-top: 8px; }
.places-label { font-size: 0.68rem; font-weight: 600; color: #777; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 5px; }
.places-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 6px; }
.place-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #fff;
  border: 1.5px solid #e0d5c5;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #444;
  transition: all 0.12s;
  min-height: 36px;
}
.place-chip.selected { background: #fff3f3; border-color: #b01a1a; color: #7a1515; }
.place-chip input[type='checkbox'] { width: 16px; height: 16px; min-height: 16px; padding: 0; margin: 0; flex-shrink: 0; accent-color: #7a1515; cursor: pointer; }
.place-name { flex: 1; line-height: 1.2; font-size: 0.78rem; }
.add-place-row { display: flex; gap: 6px; margin-top: 6px; }
.add-place-row input { flex: 1; }
.btn-add-place {
  background: #7a1515;
  color: #fff;
  border: none;
  padding: 0 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  min-height: 40px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.btn-add-place:hover { background: #b01a1a; }

/* ── Day Toggles ── */
.day-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed #e0d5c5; }
.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #444;
  font-weight: 500;
  user-select: none;
  background: #fff;
  border: 1.5px solid #e0d5c5;
  border-radius: 7px;
  padding: 7px 10px;
  min-height: 36px;
  transition: border-color 0.12s, background 0.12s;
}
.toggle-label.checked { border-color: #7a1515; background: #fff3f3; color: #7a1515; }
.toggle-label input[type='checkbox'] { width: 16px; height: 16px; min-height: 16px; padding: 0; margin: 0; cursor: pointer; accent-color: #7a1515; flex-shrink: 0; }

/* ── Add Day Button ── */
.btn-add-day {
  width: 100%;
  padding: 9px;
  border: 2px dashed #b01a1a;
  background: #fff5f5;
  color: #b01a1a;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s;
  min-height: 40px;
  margin-top: 2px;
}
.btn-add-day:hover { background: #ffeeee; }
.plus-icon { font-size: 1.1rem; line-height: 1; }

/* ── Percent Input ── */
.percent-input { display: flex; border: 1.5px solid #ddd; border-radius: 7px; overflow: hidden; background: #fafafa; }
.percent-input input { border: none; background: transparent; flex: 1; border-radius: 0; min-width: 0; }
.percent-input:focus-within { border-color: #b01a1a; box-shadow: 0 0 0 2px rgba(176,26,26,0.12); }
.percent-symbol { padding: 8px 10px; background: #f0e8e0; color: #666; font-size: 16px; font-weight: 600; border-left: 1.5px solid #ddd; white-space: nowrap; display: flex; align-items: center; }

/* ── Pricing Summary ── */
.pricing-summary { margin-top: 10px; border: 1.5px solid #e4d9cc; border-radius: 8px; overflow: hidden; background: #fdf8f2; }
.pricing-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; font-size: 0.85rem; color: #555; border-bottom: 1px solid #f0e8dc; }
.pricing-row:last-child { border-bottom: none; }
.pricing-row.discount-row { color: #2a8a3e; font-weight: 600; }
.pricing-row.grand-total { background: #7a1515; color: #fff; font-weight: 700; font-size: 0.95rem; padding: 10px 12px; }
.pricing-row.meta { font-size: 0.78rem; color: #888; }

/* ── Actions ── */
.form-actions { padding: 4px 0 12px; text-align: center; }
.btn-preview {
  background: linear-gradient(135deg, #7a1515, #b01a1a);
  color: #fff;
  border: none;
  padding: 13px 36px;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(176,26,26,0.38);
  transition: all 0.2s;
  letter-spacing: 0.3px;
  width: 100%;
  max-width: 320px;
  min-height: 48px;
}
.btn-preview:hover:not(:disabled) { box-shadow: 0 5px 16px rgba(176,26,26,0.48); transform: translateY(-1px); }
.btn-preview:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-save {
  background: linear-gradient(135deg, #155a7a, #1a7ab0);
  color: #fff;
  border: none;
  padding: 13px 36px;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(26,122,176,0.38);
  transition: all 0.2s;
  letter-spacing: 0.3px;
  width: 100%;
  max-width: 320px;
  min-height: 48px;
  margin-bottom: 10px;
}
.btn-save:hover:not(:disabled) { box-shadow: 0 5px 16px rgba(26,122,176,0.48); transform: translateY(-1px); }
.btn-save:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }
.hint { margin-top: 8px; font-size: 0.74rem; color: #bbb; }
.input-error { border-color: #c0392b !important; background: #fff5f5 !important; }
.field-error { display: block; margin-top: 3px; font-size: 0.72rem; color: #c0392b; }

/* ── Min KM info ── */
.min-km-info { display: flex; justify-content: space-between; background: #e8f4fd; border: 1px solid #90caf9; border-radius: 6px; padding: 6px 10px; font-size: 12px; color: #1565c0; gap: 8px; }
.min-km-warn { background: #fff3cd; border: 1px solid #ffc107; border-radius: 6px; padding: 7px 10px; font-size: 12px; color: #856404; }

/* ── Preview ── */
.preview-wrapper { min-height: 100vh; background: #dfe7eb; }
.preview-header { background: #075e54; color: #fff; padding: 13px 20px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 6px rgba(0,0,0,0.3); }
.header-title { font-size: 0.95rem; font-weight: 600; }
.btn-back { background: none; border: none; color: #fff; cursor: pointer; font-size: 0.88rem; font-weight: 500; padding: 4px 0; display: flex; align-items: center; gap: 4px; opacity: 0.9; text-decoration: none; }
.btn-back:hover { opacity: 1; }
.preview-content { max-width: 680px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; padding-bottom: 40px; }
.wp-card { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.wp-card-header { background: #075e54; color: #fff; padding: 10px 16px; font-size: 0.82rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.wp-chat-bg { background-color: #e5ddd5; padding: 16px 12px; }
.wp-bubble { background: #dcf8c6; border-radius: 0 10px 10px 10px; padding: 10px 14px 6px; max-width: 95%; box-shadow: 0 1px 2px rgba(0,0,0,0.14); position: relative; display: inline-block; }
.wp-bubble::before { content: ''; position: absolute; top: 0; left: -8px; border: 8px solid transparent; border-right-color: #dcf8c6; border-top: 0; }
.wp-text { font-size: 0.87rem; line-height: 1.55; color: #303030; white-space: pre-wrap; word-break: break-word; }
.wp-text strong { font-weight: 700; color: #111; }
.wp-text em { font-style: italic; color: #555; }
.wp-time { text-align: right; font-size: 0.7rem; color: #888; margin-top: 4px; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-wa, .btn-copy { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px 16px; border: none; border-radius: 12px; font-size: 0.92rem; font-weight: 700; cursor: pointer; transition: all 0.2s; letter-spacing: 0.2px; }
.btn-icon { display: flex; align-items: center; font-size: 1.05rem; }
.btn-wa { background: #25d366; color: #fff; box-shadow: 0 3px 12px rgba(37,211,102,0.4); }
.btn-wa:hover { background: #1dbb5a; transform: translateY(-1px); }
.btn-copy { background: #fff; color: #333; border: 1.5px solid #ddd; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.btn-copy:hover { background: #f5f5f5; }
.btn-copy.copied { background: #f0fff4; border-color: #25d366; color: #15803d; }
.raw-section { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
.raw-section summary { padding: 13px 16px; cursor: pointer; font-size: 0.85rem; color: #666; font-weight: 500; user-select: none; list-style: none; }
.raw-section summary::-webkit-details-marker { display: none; }
.raw-section summary::before { content: '▶ '; font-size: 0.7rem; }
.raw-section[open] summary::before { content: '▼ '; }
.raw-section textarea { display: block; width: 100%; padding: 14px 16px; border: none; border-top: 1px solid #f0f0f0; font-family: 'Courier New', monospace; font-size: 0.78rem; color: #444; resize: vertical; outline: none; box-sizing: border-box; background: #f9f9f9; line-height: 1.55; }

/* ── Responsive ── */
@media (min-width: 600px) {
  .builder-content { padding: 14px; gap: 12px; }
  .card { padding: 16px; }
  .form-grid { gap: 10px; }
  .places-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .btn-preview { width: auto; }
}
@media (max-width: 480px) {
  .action-row { grid-template-columns: 1fr; }
}
