:root {
  --bg-light: #f5f7fa;
  --bg-white: #ffffff;
  --text-dark: #333333;
  --text-muted: #555555;
  --primary: #1e3a8a;
  --primary-dark: #162c6b;
  --border-radius: 10px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  --transition: 0.2s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body, html {
  height: 100%;
  font-family: 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-light);
  color: var(--text-dark);
}

/* ─── Navigation Bar ─── */
.nav {
  width: 100%;
  background: var(--primary);
  color: #fff;
  display: flex;
  justify-content: flex-end;
  padding: 1rem 2rem;
  box-shadow: var(--shadow);
  border-radius: 0 0 12px 12px;
  position: fixed;
  top: 0;
  z-index: 10;
}

.menu-wrapper {
  position: relative;
  display: inline-block;
}

.menu-button {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #fff;
  cursor: pointer;
  padding: 0.5rem 1rem;
  font-weight: 500;
}

.menu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background-color: var(--bg-white);
  box-shadow: var(--shadow);
  border-radius: var(--border-radius);
  padding: 0.5rem 0;
  min-width: 180px;
  z-index: 1000;
}

.menu-dropdown a {
  display: block;
  padding: 12px 20px;
  color: var(--text-dark);
  font-size: 0.95rem;
  text-decoration: none;
  transition: background var(--transition);
}

.menu-dropdown a:hover {
  background-color: #f3f4f6;
}

.menu-wrapper:hover .menu-dropdown {
  display: block;
}

/* ─── Container Layout ─── */
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 6rem; /* space for fixed nav */
}

/* ─── Card Styling ─── */
.card {
  background: var(--bg-white);
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 2rem;
}

.card h1, .card h2, .card h4 {
  color: var(--primary);
  text-align: center;
  margin-bottom: 1rem;
}

/* ─── User Info Block ─── */
.user-info {
  background: #eef2f7;
  padding: 1rem;
  border-radius: var(--border-radius);
  font-size: 0.95rem;
}

.user-info p {
  margin: 0.3rem 0;
  color: var(--text-muted);
}

/* ─── Forms ─── */
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

form label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

form input,
form select {
  padding: 0.75rem;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: var(--border-radius);
  transition: border-color var(--transition);
}

form input:focus,
form select:focus {
  outline: none;
  border-color: var(--primary);
}

form button {
  margin-top: 1rem;
  padding: 0.75rem;
  font-size: 1rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: background var(--transition);
}

form button:hover {
  background: var(--primary-dark);
}

#message {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.95rem;
}

/* ─── Chat History Cards ─── */
#history-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
}

#history-list .card {
  margin: 0;
  transform: none;
}

#history-list .message pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ─── Chat Message Styling ─── */
.message {
  background: var(--bg-white);
  padding: 1rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  line-height: 1.5;
}

.message.user {
  align-self: flex-end;
  border-left: 4px solid var(--primary);
}

.message.ai {
  align-self: flex-start;
}
.dropdown-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #fff;
  cursor: pointer;
  padding: 0.5rem 1rem;
  font-weight: 500;
}
/* Customer Name field — match other inputs */
#customer_name{
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d4d9e2;
  border-radius: 12px;
  background: #fff;
  font: inherit;
  box-sizing: border-box;
}
#customer_name::placeholder{ color:#9aa3b2; }
#customer_name:focus{
  outline: none;
  border-color: #2f6bff;
  box-shadow: 0 0 0 3px rgba(47,107,255,.15);
}


/* =======================================================
   EstimAI Design System v1
   (Safe to append – does not remove existing styles)
   ======================================================= */

:root {
  --est-bg: #f3f4f6;
  --est-bg-card: #ffffff;

  --est-primary: #1e3a8a;  /* deep navy */
  --est-primary-soft: #e0ecff;
  --est-primary-border: #c7d2fe;

  --est-accent: #3b82f6;

  --est-text-main: #111827;
  --est-text-muted: #6b7280;
  --est-border-subtle: #e5e7eb;
  --est-border-strong: #d1d5db;

  --est-success-bg: #dcfce7;
  --est-success-text: #166534;

  --est-radius-lg: 12px;
  --est-radius-pill: 999px;

  --est-shadow-soft: 0 18px 30px rgba(15, 23, 42, 0.08);
}

/* ---------- Global base tweaks ---------- */

body {
  background: var(--est-bg);
  color: var(--est-text-main);
}

/* Container + card polish */

.container {
  max-width: 960px;
  margin: 32px auto;
  padding: 0 16px;
}

.card {
  background: var(--est-bg-card);
  border-radius: var(--est-radius-lg);
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: var(--est-shadow-soft);
  padding: 20px 22px;
}

/* ---------- Titles / text ---------- */

.page-title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--est-text-main);
}

.page-subtitle {
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: var(--est-text-muted);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0.45rem 1.1rem;
  border-radius: var(--est-radius-pill);
  border: 1px solid transparent;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease,
    box-shadow 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--est-primary);
  border-color: var(--est-primary);
  color: #ffffff;
  box-shadow: 0 10px 25px rgba(30, 58, 138, 0.25);
}

.btn-primary:hover {
  background: #111827;
  border-color: #111827;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #ffffff;
  border-color: var(--est-primary-border);
  color: var(--est-primary);
}

.btn-secondary:hover {
  background: var(--est-primary-soft);
  border-color: var(--est-primary);
}

/* For old .btn-back links so they look consistent */
.btn-back {
  @apply btn btn-secondary;
}

/* If your setup doesn't support @apply, comment the line above and use: */
.btn-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0.45rem 1.1rem;
  border-radius: var(--est-radius-pill);
  border: 1px solid var(--est-primary-border);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  background: #ffffff;
  color: var(--est-primary);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease,
    box-shadow 0.15s ease, color 0.15s ease;
}

.btn-back:hover {
  background: var(--est-primary-soft);
  border-color: var(--est-primary);
}

/* ---------- Quote meta (gutter / HVAC details) ---------- */

.quote-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 18px;
}

.quote-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: var(--est-radius-pill);
  font-size: 11px;
  border: 1px solid var(--est-border-subtle);
  background: #f9fafb;
  color: var(--est-text-muted);
}

.quote-pill-label {
  font-weight: 600;
  color: var(--est-text-main);
  font-size: 11px;
}

/* ---------- Quote body typography ---------- */

#quote-content {
  border-radius: 10px;
  border: 1px solid var(--est-border-subtle);
  background: #f9fafb;
  padding: 14px 14px 10px;
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--est-text-main);
}

#quote-content p {
  margin: 0 0 6px;
}

/* Optional: section headings inside quote text if model uses them */
#quote-content p:nth-child(1),
#quote-content p:nth-child(3),
#quote-content p:nth-child(7) {
  font-weight: 600;
}

/* ---------- Nav polishing (optional, works with your existing nav) ---------- */

.nav {
  background: #020617;        /* your dark navy */
  padding: 10px 24px;
  display: flex;
  justify-content: flex-end;  /* 🔹 pushes menu to the right */
  align-items: center;
}

/* ensure the wrapper isn't centering itself */
.menu-wrapper {
  position: relative;
  margin: 0;                  /* remove margin: 0 auto if you had it */
}


.menu-button {
  border-radius: var(--est-radius-pill);
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.5);
  color: #e5e7eb;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.85rem;
}

.menu-button:hover {
  background: rgba(15, 23, 42, 0.95);
}

.menu-dropdown {
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.6);
  background: #020617;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.8);
}

.menu-dropdown a {
  color: #e5e7eb;
  font-size: 0.85rem;
}

.menu-dropdown a:hover {
  background: rgba(15, 23, 42, 0.85);
}



/* ---------- Accounts: Company Branding card ---------- */
.account-stack {
  max-width: 760px;
  margin: 0 auto;
  padding: 6rem 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.account-page-title {
  margin: 0 0 2px;
  color: var(--est-primary);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.account-stack .card {
  margin-top: 0;
}

.account-card,
.branding-card {
  width: 100%;
  max-width: none;
}

.branding-card {
  gap: 14px;
}

.branding-title {
  margin: 0;
  color: var(--est-primary);
  text-align: left;
  font-size: 1.45rem;
}

.branding-subtitle {
  margin: 0;
  color: var(--est-text-muted);
  font-size: 0.93rem;
}

.branding-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.branding-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.branding-field label {
  font-size: 0.9rem;
  color: var(--est-text-muted);
  font-weight: 600;
}

.branding-field input {
  width: 100%;
  padding: 0.72rem 0.8rem;
  border: 1px solid #cfd5df;
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fff;
}

.branding-field input:focus,
.branding-file-input:focus {
  outline: none;
  border-color: var(--est-primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.15);
}

.branding-logo-block {
  border: 1px solid var(--est-border-subtle);
  border-radius: 12px;
  background: #f8fafc;
  padding: 14px;
}

.branding-logo-label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--est-text-muted);
}

.branding-logo-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.branding-logo-preview {
  width: 170px;
  height: 84px;
  border: 1px solid var(--est-border-subtle);
  border-radius: 12px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.branding-logo-image {
  max-width: 100%;
  max-height: 100%;
}

.branding-logo-empty {
  font-size: 12px;
  color: var(--est-text-muted);
}

.branding-logo-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.branding-file-input {
  font-size: 0.9rem;
}

.branding-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.branding-inline-msg {
  font-size: 0.88rem;
  color: var(--est-text-muted);
}

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

  .branding-title {
    font-size: 1.28rem;
  }

  .branding-logo-preview {
    width: 100%;
    max-width: 260px;
  }
}

/* =======================================================
   EstimAI Professional UI Overrides (global)
   Keep at end so legacy rules stay backward-compatible.
   ======================================================= */
:root {
  --pro-bg: #f2f5fb;
  --pro-surface: #ffffff;
  --pro-surface-soft: #f8fbff;
  --pro-text: #0f172a;
  --pro-muted: #5b6b81;
  --pro-border: #d7e1ef;
  --pro-border-strong: #bfd0e7;
  --pro-primary: #1d4ed8;
  --pro-primary-dark: #1e3a8a;
  --pro-shadow: 0 18px 42px rgba(15, 23, 42, 0.12);
  --pro-radius: 14px;
}

html, body {
  background: var(--pro-bg);
  color: var(--pro-text);
}

.nav {
  background: linear-gradient(180deg, #07102a 0%, #091634 100%);
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow: 0 10px 28px rgba(2, 6, 23, 0.45);
  border-radius: 0;
  padding: 11px 18px;
  z-index: 999;
}

.menu-wrapper {
  position: relative;
}

.menu-button,
.dropdown-btn {
  border-radius: 999px;
  border: 1px solid rgba(191, 208, 231, 0.55);
  background: rgba(15, 23, 42, 0.7);
  color: #e5edf8;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 8px 14px;
  line-height: 1;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.menu-button:hover,
.dropdown-btn:hover {
  border-color: rgba(191, 208, 231, 0.9);
  background: rgba(30, 41, 59, 0.88);
  transform: translateY(-1px);
}

.menu-dropdown,
.dropdown-content {
  display: block;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.36);
  background: #07102a;
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.65);
  padding: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px) scale(0.98);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.menu-wrapper:hover .menu-dropdown,
.menu-wrapper:hover .dropdown-content,
.menu-dropdown.show,
.dropdown-content.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.menu-dropdown a,
.dropdown-content a {
  display: block;
  border-radius: 10px;
  color: #dbe7fb;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 10px 12px;
  text-decoration: none;
  transition: background 0.14s ease, color 0.14s ease;
}

.menu-dropdown a:hover,
.dropdown-content a:hover {
  background: rgba(29, 78, 216, 0.24);
  color: #ffffff;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 84px 16px 24px;
}

.card {
  background: var(--pro-surface);
  border: 1px solid var(--pro-border);
  border-radius: var(--pro-radius);
  box-shadow: var(--pro-shadow);
}

input,
select,
textarea {
  border: 1px solid #c8d6e8;
  border-radius: 10px;
  background: #ffffff;
  color: #0f172a;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

button,
.btn,
form button {
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

@media (max-width: 768px) {
  .nav {
    padding: 10px 12px;
  }
  .container {
    padding: 78px 12px 20px;
  }
  .menu-button,
  .dropdown-btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 0.98rem;
  }
  .menu-dropdown,
  .dropdown-content {
    position: fixed;
    top: calc(64px + env(safe-area-inset-top, 0px));
    right: 12px;
    left: 12px;
    min-width: 0;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - (84px + env(safe-area-inset-top, 0px) + env(safe-area-inset-bottom, 0px)));
    overflow: auto;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .menu-dropdown a,
  .dropdown-content a {
    min-height: 44px;
    padding: 12px 14px;
  }
}

@media (max-width: 480px) {
  .nav {
    padding: 9px 10px;
  }
  .container {
    padding: 74px 10px 16px;
  }
  .menu-dropdown,
  .dropdown-content {
    top: calc(60px + env(safe-area-inset-top, 0px));
    right: 8px;
    left: 8px;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - (72px + env(safe-area-inset-top, 0px) + env(safe-area-inset-bottom, 0px)));
  }
}

/* =======================================================
   Global Menu Button Consistency Lock
   Ensures the nav menu trigger matches the unified pill style
   across pages, even when page-level CSS defines .menu-button.
   ======================================================= */
.nav .menu-button,
.nav .dropdown-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  min-height: 40px !important;
  padding: 8px 14px !important;
  border-radius: 12px !important;
  border: 1px solid rgba(15, 23, 42, 0.18) !important;
  background: #ffffff !important;
  color: #1e293b !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.01em !important;
  line-height: 1 !important;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.16) !important;
  text-decoration: none !important;
}

.nav .menu-button:hover,
.nav .dropdown-btn:hover {
  background: #f8fafc !important;
  border-color: rgba(15, 23, 42, 0.28) !important;
  transform: translateY(-1px);
}

.nav .menu-button:focus-visible,
.nav .dropdown-btn:focus-visible {
  outline: 2px solid #2563eb !important;
  outline-offset: 2px !important;
}

/* =======================================================
   Unified Button Tier System
   ======================================================= */
.btn-primary,
.btn-secondary,
.btn-destructive {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 10px 16px !important;
  border-radius: 10px !important;
  border: 1px solid transparent !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  text-decoration: none !important;
  cursor: pointer !important;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease !important;
}

.btn-primary {
  background: #2563eb !important;
  border-color: #2563eb !important;
  color: #ffffff !important;
}

.btn-primary:hover:not(:disabled) {
  background: #1d4ed8 !important;
  border-color: #1d4ed8 !important;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #ffffff !important;
  border-color: #1e2a3a !important;
  color: #1e2a3a !important;
}

.btn-secondary:hover:not(:disabled) {
  background: #f8fafc !important;
}

.btn-destructive {
  background: #ffffff !important;
  border-color: #dc2626 !important;
  color: #dc2626 !important;
}

.btn-destructive:hover:not(:disabled) {
  background: #fef2f2 !important;
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-destructive:disabled {
  opacity: 0.55 !important;
  cursor: not-allowed !important;
  transform: none !important;
}
