/* ==========================================================================
   CLOSER PWA — LUXO CREAM & WARM EDITORIAL DESIGN SYSTEM (V2.0)
   Alê & Mônica Mesquita Fotografia — New York City
   Padrão Visual Claro em Paridade com o Welcome Guide e Propostas Web
   ========================================================================== */

:root {
  /* Backgrounds: Papel Alabastro / Creme de Luxo / White Surface */
  --bg-base: #F8F6F1;
  --bg-surface: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #FCFBF9;
  --bg-input: #FAF8F5;
  
  /* Gold Accent Tokens (Paleta Oficial Alê & Mônica: #9B7517 / #C5A059) */
  --gold-primary: #9B7517;
  --gold-accent: #C5A059;
  --gold-hover: #7E5F12;
  --gold-light: #FAF3DE;
  --gold-dim: rgba(197, 160, 89, 0.14);
  --gold-border: rgba(197, 160, 89, 0.35);
  --gold-glow: rgba(197, 160, 89, 0.25);
  
  /* Typography & Contrast */
  --text-main: #1A1A1A;
  --text-muted: #555048;
  --text-dim: #8A857D;
  --border-subtle: #E6E2D8;
  --border-card: #EAE6DF;
  
  /* WhatsApp Identity (Light Mode Native) */
  --wa-green: #25D366;
  --wa-green-hover: #1EBE5D;
  --wa-dark: #075E54;
  --wa-bubble: #E7F8E9;
  --wa-bubble-border: #C6E7BE;
  --wa-bubble-text: #111B21;
  --wa-bubble-num: #0F6B56;
  
  /* Status Colors */
  --danger: #DC2626;
  --warning: #D97706;
  --success: #059669;
  --info: #2563EB;
  
  /* Typography Hierarchy */
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Menlo, Consolas, monospace;
  
  /* Geometry & Radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-gold: 0 0 20px rgba(197, 160, 89, 0.2);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.03);
  
  --safe-bottom: env(safe-area-inset-bottom, 20px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  overflow-x: hidden;
  padding-bottom: calc(75px + var(--safe-bottom));
  min-height: 100vh;
}

/* Container */
.app-container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px;
}

/* TOP HEADER */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 16px;
}

.top-header-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #FAF3DE, #F4E8C1);
  border: 1px solid var(--gold-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-primary);
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.brand-text h1 {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-text h1 span {
  color: var(--gold-primary);
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: var(--gold-dim);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gold-border);
}

.brand-text p {
  font-size: 11px;
  color: var(--text-muted);
}

/* Quick Action / Emergency Button */
.btn-emergency {
  background: linear-gradient(135deg, #C5A059, #9B7517);
  border: 1px solid #8A6828;
  color: #FFFFFF;
  padding: 9px 16px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 10px rgba(155, 117, 23, 0.25);
  white-space: nowrap;
}

.btn-emergency:hover, .btn-emergency:active {
  transform: scale(0.97);
  background: linear-gradient(135deg, #D4AF37, #A8811A);
  box-shadow: 0 4px 15px rgba(155, 117, 23, 0.4);
}

/* CONTEXT BAR (Lead Info) */
.context-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin: 16px 0;
  box-shadow: var(--shadow-card);
}

.context-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.context-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.btn-reset-context {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
}

.btn-reset-context:hover {
  color: var(--danger);
}

.context-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 10px;
}

@media (max-width: 640px) {
  .context-grid {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}

.form-input:focus, .form-select:focus {
  border-color: var(--gold-accent);
  box-shadow: 0 0 0 2px var(--gold-dim);
}

.segmented-control {
  display: flex;
  background: var(--bg-input);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.segmented-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.segmented-btn.active {
  background: #FFFFFF;
  color: var(--gold-primary);
  border: 1px solid var(--gold-border);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

/* SEARCH & CATEGORY PILLS */
.search-container {
  margin-bottom: 12px;
  position: relative;
}

.search-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 44px 14px 42px;
  font-size: 15px;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s;
  box-shadow: var(--shadow-card);
}

.search-input:focus {
  border-color: var(--gold-accent);
  box-shadow: var(--shadow-gold);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 16px;
}

.search-clear {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  display: none;
}

.category-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.category-scroll::-webkit-scrollbar {
  display: none;
}

.pill-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-card);
}

.pill-btn:hover {
  border-color: var(--gold-border);
  color: var(--text-main);
}

.pill-btn.active {
  background: var(--gold-light);
  border-color: var(--gold-primary);
  color: var(--gold-hover);
  font-weight: 700;
}

/* MESSAGE CARDS LIST */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

.msg-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: var(--shadow-card);
}

.msg-card:hover {
  border-color: var(--gold-border);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-md);
}

.msg-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.msg-title-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-primary);
  background: var(--gold-light);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--gold-border);
}

.badge-category {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.msg-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
}

.btn-star {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  transition: color 0.2s, transform 0.2s;
  padding: 4px;
}

.btn-star:hover {
  transform: scale(1.15);
}

.btn-star.favorited {
  color: #D97706;
}

/* Microcopy / Context / Subtext */
.msg-context {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 12px;
  line-height: 1.4;
  border-left: 2px solid var(--gold-accent);
  padding-left: 8px;
}

/* Message Mode Tabs (Text vs Audio) */
.msg-mode-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.mode-tab-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.mode-tab-btn.active {
  background: var(--gold-light);
  border-color: var(--gold-primary);
  color: var(--gold-hover);
  font-weight: 700;
}

/* BUBBLES VIEWER (WhatsApp Simulated Paragraphs) */
.bubbles-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.bubble-item {
  background: var(--wa-bubble);
  border: 1px solid var(--wa-bubble-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--wa-bubble-text);
  position: relative;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.bubble-item:hover {
  background: #DCF8C6;
  border-color: var(--wa-green);
}

.bubble-item-num {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--wa-bubble-num);
  margin-bottom: 4px;
  display: block;
}

/* Audio Script Box */
.audio-script-box {
  background: #FFFDF5;
  border: 1px solid #F3E5AB;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  color: #78350F;
  line-height: 1.6;
  white-space: pre-line;
  margin-bottom: 14px;
}

/* ACTIONS BAR */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

/* Sequencer Button */
.btn-sequencer {
  background: linear-gradient(135deg, var(--wa-dark), #128C7E);
  border: 1px solid var(--wa-green);
  color: #FFF;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(7, 94, 84, 0.25);
}

.btn-sequencer:hover, .btn-sequencer:active {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #0A6F62, var(--wa-dark));
  box-shadow: 0 4px 12px rgba(7, 94, 84, 0.35);
}

.btn-sequencer.copied-pulse {
  animation: pulse-green 0.4s ease;
}

@keyframes pulse-green {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.chip-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.chip-bubble:hover {
  border-color: var(--wa-green);
  color: var(--wa-dark);
  background: var(--wa-bubble);
}

.btn-copy-all {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  margin-left: auto;
}

.btn-copy-all:hover {
  border-color: var(--gold-border);
  color: var(--gold-primary);
  background: var(--gold-light);
}

.btn-icon-action {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon-action:hover {
  color: var(--text-main);
  border-color: var(--gold-accent);
}

/* BOTTOM NAVIGATION BAR */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  padding: 8px 16px calc(8px + var(--safe-bottom));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.04);
}

.bottom-nav-inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.nav-tab .nav-icon {
  font-size: 18px;
}

.nav-tab.active {
  color: var(--gold-primary);
  background: var(--gold-dim);
}

.nav-tab.active .nav-icon {
  transform: translateY(-2px);
}

/* DRAWER / BOTTOM SHEET FOR TOOLS */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.sheet-overlay.active {
  display: flex;
}

.sheet-modal {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px 20px calc(24px + var(--safe-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.12);
  animation: slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.sheet-title {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--gold-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-close-sheet {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

/* CALCULATOR STYLING */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 500px) {
  .calc-grid {
    grid-template-columns: 1fr;
  }
}

.rate-badge {
  background: #ECFDF5;
  border: 1px solid #A7F3D0;
  color: #047857;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.calc-result-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
}

.calc-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}

.calc-row.total {
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
  margin-top: 6px;
  font-weight: 700;
  font-size: 16px;
  color: var(--gold-primary);
}

/* GPS PIN CARDS */
.gps-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gps-card {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.gps-info h4 {
  font-size: 15px;
  color: var(--text-main);
  margin-bottom: 2px;
}

.gps-info p {
  font-size: 12px;
  color: var(--text-muted);
}

.gps-actions {
  display: flex;
  gap: 6px;
}

.btn-gps {
  background: var(--gold-light);
  border: 1px solid var(--gold-border);
  color: var(--gold-primary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-gps:hover {
  background: var(--gold-accent);
  color: #FFF;
}

/* PDF PROPOSALS GRID */
.pdf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 540px) {
  .pdf-grid {
    grid-template-columns: 1fr;
  }
}

.pdf-card {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.pdf-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.btn-pdf-share {
  background: var(--wa-green);
  color: #075E54;
  border: 1px solid var(--wa-bubble-border);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-pdf-share:hover {
  background: var(--wa-green-hover);
  color: #FFF;
}

/* TOAST NOTIFICATION */
.toast-box {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(26, 26, 26, 0.95);
  border: 1px solid var(--gold-accent);
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-box.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}