/* iOS Safari Fixes */
html {
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
}

body {
  height: calc(var(--real-vh, 1vh) * 100);
}

#chat-container {
  height: calc((var(--real-vh, 1vh) * 100) - var(--header-height));
}

#chat-form {
  padding-bottom: env(safe-area-inset-bottom);
}

/* Moved from chat.html */
/* ========================
   CSS Variables
   ======================== */
:root {
  --header-height: 4rem;
  /* adjust if your header is taller or shorter */
}

/* Layout */

/* Fixed site header */
#site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 100;
  background: white;
  border-bottom: 1px solid #eee;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  margin: 0;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* --- Chat container block (overridden as per instruction) --- */
/* --- Chat container block (overridden as per instruction) --- */
/* --- Chat container block (overridden as per instruction) --- */
#chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 800px;
  margin: 0 auto;
  background-color: white;
  padding-bottom: 0;
  /* remove any bottom padding that pushes content below fold */
  height: calc(100vh - var(--header-height));
}

.hidden {
  display: none !important;
}

.centered-chat {
  justify-content: center;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

#messages::after {
  content: "";
  display: block;
  height: 4rem;
  /* ensures bottom content isn't obscured by sticky chat input */
}

#chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid #eee;
  background: white;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

/* =========================
   Buttons & Links
   ========================= */
.btn-pill {
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.5rem;
  padding: 0.2rem 0.5rem;
}

.search-input {
  width: 100%;
  font-size: 1rem;
  line-height: 1.5;
  border-radius: 999px;
  padding: 0.6rem 1rem;
  box-sizing: border-box;
}

.plain-link {
  text-decoration: none;
  color: #000;
  font-weight: 600;
  font-size: 0.5rem;
}

.plain-link:hover {
  text-decoration: underline;
}

button.plain-link {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

button.plain-link:hover {
  text-decoration: underline;
}

/* =========================
     Dialog & Modal Styling
     ========================= */
dialog,
.custom-modal-overlay {
  backdrop-filter: blur(8px) saturate(1.8);
  -webkit-backdrop-filter: blur(8px) saturate(1.8);
  background: rgba(0, 0, 0, 0.45) !important;
  border: none;
  padding: 0;
  margin: 0;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  position: fixed;
  inset: 0;
  z-index: 10000;
}

dialog[open],
.custom-modal-overlay.show {
  display: flex !important;
  opacity: 1;
}

dialog article,
.custom-modal {
  background: white !important;
  padding: 2.5rem !important;
  border-radius: 20px !important;
  max-width: 550px;
  width: 90%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
  margin: 0 !important;
}

/* Standardize headers and footers in modals */
dialog header,
.custom-modal header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  margin-bottom: 1.5rem !important;
  padding-bottom: 1rem !important;
  border-bottom: 1px solid #f0f0f0 !important;
  background: transparent !important;
}

dialog footer {
  margin-top: 1.5rem !important;
  padding-top: 1rem !important;
  border-top: 1px solid #f0f0f0 !important;
  display: flex !important;
  justify-content: flex-end !important;
  gap: 1rem !important;
}

/* =========================
     Sign-in Box Styling
     ========================= */
.signin-container {
  display: grid;
  place-items: center;
  height: 100vh;
  padding: 1rem;
}

.signin-box {
  background: var(--surface-1);
  padding: 2rem;
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-3);
  max-width: 24rem;
  width: 100%;
  display: grid;
  gap: 1rem;
  text-align: center;
}

.signin-box button {
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
}

/* =========================
     Subscribe Modal Content
     ========================= */
.subscribe-container {
  position: relative;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 400px;
  margin: 0 auto;
  background: white;
  display: grid;
  gap: 1rem;
}

/* Close button */
.subscribe-container button.close-button {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: #333;
}

/* Modal heading */
.subscribe-container h2 {
  margin: 0;
  font-size: 1.75rem;
}

/* Price */
.price {
  font-size: 1.5rem;
  font-weight: bold;
  margin: 0.25rem 0;
}

.per-month {
  font-size: 1rem;
  font-weight: normal;
}

/* Teaser text */
.teaser {
  margin-bottom: 1rem;
  font-style: italic;
}

/* Features checklist: stacked & left-aligned */
.features {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.features li {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
}

.checkmark {
  color: green;
  margin-right: 0.5rem;
  font-weight: bold;
}

/* Email input: dark border & fit container */
.subscribe-container input[type="email"] {
  width: 100%;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  border: 1px solid #666;
  border-radius: 4px;
  box-sizing: border-box;
}

/* Agreement text */
.agreement {
  font-size: 0.875rem;
  color: #666;
  margin-bottom: 1rem;
}

/* Center the subscribe button container */
.subscribe-container .dialog-menu {
  width: 100%;
  text-align: center;
  padding: 0;
  margin: 0;
}

/* Subscribe button: full width up to max */
.subscribe-container button#modal-submit {
  display: inline-block;
  width: 80%;
  max-width: 320px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  box-sizing: border-box;
}

/* Center <dialog> and add soft shadow */
dialog.modal {
  border: none;
  border-radius: var(--pico-border-radius);
  box-shadow: var(--pico-shadow-3);
  padding: 0;
}

dialog::backdrop {
  background: hsl(0 0% 0% / .55);
}

dialog>article {
  padding: var(--pico-spacing);
}

/* ── dialog header alignment ───────────────────────────── */
dialog.modal header {
  display: flex;
  /* title + X in one row */
  align-items: center;
  /* vertical centring */
  justify-content: space-between;
  margin-bottom: var(--pico-spacing, 1rem);
}

dialog.modal header h3 {
  margin: 0;
  /* kill default <h3> top/bottom margin */
}

dialog.modal header .close {
  font-size: 1.25rem;
  /* tweak as you like */
  line-height: 1;
  /* keep the X vertically centred */
}

/* search bar layout */
.search-bar-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--pico-spacing);
  align-items: stretch;
  /* let the button stretch to input height */
}

/* compact filter button */
.filter-btn {
  height: 77%;
  /* same overall height as the input */
  padding-inline: 0.75rem;
  /* narrower */
  padding-block: 0rem;
  /* match input’s vertical padding */
  white-space: nowrap;
}

/* ── dark button variant ─────────────────────────── */
.btn-black {
  background-color: #000;
  /* solid black */
  color: #fff;
  /* white text   */
  border-color: #000;
  /* keep border invisible */
}

.btn-black:is(:hover, :focus) {
  background-color: #111;
  /* a hair lighter on hover/focus */
  border-color: #111;
}

/* =========================
   Chat UI Styling
   ========================= */


.message {
  padding: 0.5rem 1rem;
  border-radius: 1rem;
  max-width: 75%;
  word-wrap: break-word;
}

.user-message {
  background-color: #4a5568;
  color: white;
  align-self: flex-end;
  border-radius: 1rem;
  padding: 0.5rem 1rem;
  max-width: fit-content;
}

.bot-message {
  background-color: transparent;
  color: #1a202c;
  align-self: flex-start;
  white-space: pre-line;
}

#chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  padding: 1rem;
  border-top: none;
  background: white;
  margin-top: 0.5rem;
  /* subtle leading above the input */
  flex-shrink: 0;
  /* prevents collapsing */
  position: sticky;
  bottom: 0;
  z-index: 10;
}

form#chat-form input#chat-input {
  border: 1px solid #ccc !important;
  border-radius: 1rem !important;
  padding: 0.75rem 1.25rem !important;
  font-size: 1.125rem !important;
  height: 3rem !important;
  width: 100% !important;
}

form#chat-form button#chat-submit {
  background-color: #f1f5f9 !important;
  color: #4a5568 !important;
  border: 1px solid #e2e8f0 !important;
  padding: 0 1rem !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  border-radius: 1rem !important;
  height: 3rem !important;
  min-width: 3rem !important;
  cursor: pointer !important;
}

form#chat-form button#chat-submit:hover {
  background-color: #e2e8f0 !important;
}

.options-container {
  align-self: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 1rem 0 1rem;
}

.option-button {
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 0.3rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.option-button:hover {
  background-color: #e2e8f0;
}

.option-button:disabled {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
}

/* =========================
   Local Form Styling
   ========================= */

.local-form-section {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 2rem 2rem 8rem 2rem;
}

.local-form-section h1 {
  margin-bottom: 0.5rem;
  font-size: 2rem;
  font-weight: 700;
}

.local-form-section .subtitle {
  color: #64748b;
  margin-bottom: 2rem;
  font-size: 1rem;
}

.dynamic-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  opacity: 1;
  transition: opacity 0.3s ease, max-height 0.3s ease;
}

.form-field.hidden {
  display: none;
}

.form-field label {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1e293b;
}

.form-field input[type="text"],
.form-field input[type="number"],
.form-field select {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-field input[type="text"]:focus,
.form-field input[type="number"]:focus,
.form-field select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Character counter */
.char-counter {
  font-size: 0.85rem;
  color: #64748b;
  text-align: right;
}

/* Price input styling */
.price-input-wrapper {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.price-input-wrapper:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.currency-symbol {
  font-weight: 600;
  color: #475569;
  font-size: 1rem;
  line-height: 1.5;
}

.price-input-wrapper input[type="number"] {
  border: none;
  padding: 0;
  font-size: 1rem;
  line-height: 1.5;
  width: 100%;
}

.price-input-wrapper input[type="number"]:focus {
  outline: none;
  box-shadow: none;
}

.currency-label {
  font-size: 1rem;
  color: #64748b;
  font-weight: 500;
  line-height: 1.5;
}

/* Scenario selection */
.scenario-selection {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.scenario-selection select {
  width: 100%;
}

/* File upload styling */
.file-upload-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background-color: #f1f5f9;
  border: 2px dashed #cbd5e1;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  width: fit-content;
}

.file-upload-label:hover {
  background-color: #e2e8f0;
  border-color: #94a3b8;
}

.upload-icon {
  font-size: 1.25rem;
}

.upload-text {
  font-weight: 500;
  color: #475569;
}

.file-input {
  display: none;
}

.file-name {
  font-size: 0.9rem;
  color: #64748b;
  font-style: italic;
}

.file-name.file-selected {
  color: #0f172a;
  font-weight: 500;
  font-style: normal;
}

/* Run Scenario Button */
.btn-run-scenario {
  background-color: #22c55e;
  color: white;
  border: none;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(34, 197, 94, 0.2);
}

.btn-run-scenario:hover {
  background-color: #16a34a;
  box-shadow: 0 4px 8px rgba(34, 197, 94, 0.3);
  transform: translateY(-1px);
}

.btn-run-scenario:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(34, 197, 94, 0.2);
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .local-form-section {
    padding: 1rem;
  }

  .local-form-section h1 {
    font-size: 1.5rem;
  }
}

/* =========================
   Harmonized Upload Zone
   ========================= */
.common-upload-zone {
  border: 2px dashed #ccc;
  padding: 3rem;
  text-align: center;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: #f9f9f9;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  min-height: 250px;
  width: 100%;
  box-sizing: border-box;
}

.common-upload-zone:hover,
.common-upload-zone.drag-over {
  border-color: #000;
  background-color: #f0f0f0;
}

.common-upload-zone .icon {
  font-size: 2.5rem;
}

.common-upload-zone h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #333;
}

.common-upload-zone p {
  margin: 0;
  color: #666;
}

/* ========================
   Toast Notifications
   ======================== */
.toast-container {
  position: fixed;
  top: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  padding: 1rem 1.5rem;
  background: white;
  color: #1a1a1a;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-weight: 500;
  min-width: 250px;
  max-width: 400px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-left: 4px solid #1a1a1a;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-left-color: #00c853;
  /* Success green */
}

.toast-error {
  border-left-color: #d50000;
  /* Error red */
}

.toast-info {
  border-left-color: #2962ff;
  /* Info blue */
}

.toast-close {
  margin-left: 1rem;
  cursor: pointer;
  opacity: 0.5;
  font-size: 1.25rem;
  line-height: 1;
}

.toast-close:hover {
  opacity: 1;
}

/* ========================
   Custom Modal
   ======================== */
.custom-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.custom-modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.custom-modal {
  background: white;
  padding: 2.5rem;
  border-radius: 16px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.custom-modal-overlay.show .custom-modal {
  transform: scale(1);
}

.modal-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #1a1a1a;
}

.modal-message {
  color: #666;
  margin-bottom: 2rem;
  line-height: 1.5;
}

.modal-button-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-btn-download {
  background: #1a1a1a;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.modal-btn-download:hover {
  background: #333;
}

.modal-btn-close {
  background: none;
  border: none;
  color: #999;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
}

.modal-btn-close:hover {
  color: #666;
}

/* ========================
   Recent Runs Module
   ======================== */
.runs-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1rem;
}

.run-history-item {
  background: white !important;
  border: 1px solid #edf2f7 !important;
  border-radius: 12px !important;
  padding: 1.25rem !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 1.5rem !important;
  text-align: left !important;
}

.run-history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
  border-color: #e2e8f0 !important;
}

.run-history-item .status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  width: fit-content;
  margin-bottom: 0.25rem;
}

.status-running {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
}

.status-completed {
  background: #f0fdf4 !important;
  color: #15803d !important;
}

.status-failed {
  background: #fef2f2 !important;
  color: #b91c1c !important;
}

.run-description {
  font-weight: 600;
  font-size: 1rem;
  color: #1e293b;
  margin: 0;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.run-meta {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: auto;
}

.run-skeleton {
  padding: 3rem;
  text-align: center;
  color: #94a3b8;
  background: #f8fafc;
  border-radius: 16px;
  border: 2px dashed #e2e8f0;
  grid-column: 1 / -1;
  font-style: italic;
}