/* ============================================================
   Madhubhan Resort & Spa — AI Booking Concierge
   Premium hospitality visual language: warm cream/stone ground,
   soft sage-green accents, quiet shadows, generous whitespace.
   ============================================================ */

:root {
  --cream: #faf6ef;
  --stone-50: #f5f0e6;
  --stone-100: #ece4d4;
  --stone-200: #ddd2ba;
  --stone-300: #c2b294;
  --ink-900: #2b2620;
  --ink-700: #4a4338;
  --ink-500: #7a7263;
  --ink-400: #9a9284;
  --sage-600: #5f7a5f;
  --sage-500: #74915f;
  --sage-100: #e4ead9;
  --sage-50: #eef2e7;
  --gold: #b08d4f;
  --white: #ffffff;
  --danger: #a8503f;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-soft: 0 1px 2px rgba(43, 38, 32, 0.04), 0 8px 24px rgba(43, 38, 32, 0.06);
  --shadow-lift: 0 4px 12px rgba(43, 38, 32, 0.08), 0 16px 40px rgba(43, 38, 32, 0.10);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===================== HEADER ===================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--white);
  border-bottom: 1px solid var(--stone-100);
  flex: 0 0 auto;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--sage-500), var(--sage-600));
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  line-height: 1.2;
  color: var(--ink-900);
}

.brand-subtitle {
  font-size: 12.5px;
  color: var(--ink-500);
  letter-spacing: 0.02em;
  margin-top: 1px;
}

.header-right { display: flex; align-items: center; gap: 14px; }

.suhana-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--sage-50);
  border: 1px solid var(--sage-100);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--sage-600);
}

.suhana-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-400);
  transition: background 0.25s ease;
}
.suhana-dot.online { background: var(--sage-500); box-shadow: 0 0 0 3px var(--sage-100); }
.suhana-dot.error { background: var(--danger); box-shadow: 0 0 0 3px rgba(168, 80, 63, 0.15); }

.suhana-status { color: var(--ink-500); font-weight: 500; font-size: 12px; }

.powered-by { font-size: 11.5px; color: var(--ink-400); display: none; }
@media (min-width: 720px) { .powered-by { display: inline; } }

.debug-toggle {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--stone-100);
  background: var(--white);
  color: var(--ink-400);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.debug-toggle:hover { background: var(--stone-50); color: var(--ink-700); }

/* ===================== MAIN LAYOUT ===================== */
.app-main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 34% 66%;
  gap: 22px;
  padding: 18px 32px;
  align-items: stretch;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  overflow: hidden;
}

@media (max-width: 980px) {
  html, body { overflow: auto; }
  .app { height: auto; min-height: 100vh; overflow: visible; }
  .app-main {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
    overflow: visible;
    min-height: 0;
  }
  .app-header { padding: 14px 16px; }
  .voice-panel { height: auto; min-height: 480px; }
  .booking-panel { height: auto; overflow: visible; }
  .booking-columns, .booking-columns.has-rooms { grid-template-columns: 1fr; }
  .rooms-card, .cart-card { height: auto; overflow: visible; }
  .rooms-card .rooms-grid, .cart-items { overflow: visible; max-height: none; }
}

.panel { min-width: 0; min-height: 0; }

.card {
  background: var(--white);
  border: 1px solid var(--stone-100);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 14px;
  flex: 0 0 auto;
}

.card-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-500);
  margin-bottom: 14px;
}

/* ===================== VOICE PANEL ===================== */
.voice-panel {
  background: var(--white);
  border: 1px solid var(--stone-100);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  min-height: 0;
}

.voice-stage {
  flex: 0 0 auto;
  padding: 18px 24px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: radial-gradient(ellipse at 50% -10%, var(--sage-50), transparent 60%);
  border-bottom: 1px solid var(--stone-100);
}

.avatar-wrap { position: relative; display: flex; align-items: center; justify-content: center; height: 76px; }

.avatar-ring {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--sage-500), var(--sage-600));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  box-shadow: 0 0 0 6px var(--sage-50);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
  z-index: 2;
}
.avatar-ring.speaking { box-shadow: 0 0 0 6px var(--sage-100), 0 0 0 12px var(--sage-50); animation: pulse 1.6s ease-in-out infinite; }
.avatar-ring.listening { box-shadow: 0 0 0 6px rgba(176, 141, 79, 0.18); }
.avatar-ring.error { background: linear-gradient(160deg, var(--danger), #8a3e30); }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.waveform {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  height: 40px;
  opacity: 0.85;
  pointer-events: none;
}

.status-line {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-500);
  min-height: 20px;
}

.start-conversation-button {
  margin-top: 16px;
  padding: 13px 28px;
  border: none;
  border-radius: 999px;
  background: var(--ink-900);
  color: var(--white);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-lift);
  transition: background 0.15s ease, transform 0.15s ease;
}
.start-conversation-button:hover:not(:disabled) { background: var(--sage-600); transform: translateY(-1px); }
.start-conversation-button:disabled { background: var(--stone-200); color: var(--ink-400); cursor: not-allowed; box-shadow: none; }

.mic-controls {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.starter-chips.is-gated, .text-fallback.is-gated { opacity: 0.5; pointer-events: none; }

.mic-button {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--ink-900);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lift);
  transition: transform 0.15s ease, background 0.2s ease;
}
.mic-button:hover:not(:disabled) { transform: translateY(-1px); }
.mic-button:disabled { background: var(--stone-200); color: var(--ink-400); box-shadow: none; cursor: not-allowed; }
.mic-button.active { background: var(--sage-600); }
.mic-button.muted { background: var(--danger); }

.secondary-controls { display: flex; gap: 8px; }

.pill-button {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--stone-200);
  background: var(--white);
  color: var(--ink-700);
  font-size: 13px;
  font-weight: 600;
}
.pill-button:hover:not(:disabled) { background: var(--stone-50); }
.pill-button:disabled { color: var(--ink-400); cursor: not-allowed; }
.pill-button.danger { color: var(--danger); border-color: rgba(168, 80, 63, 0.3); }
.pill-button.danger:hover:not(:disabled) { background: rgba(168, 80, 63, 0.06); }
.pill-button.active { background: var(--ink-900); color: var(--white); border-color: var(--ink-900); }

.starter-chips {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--stone-100);
}

.chip {
  border: 1px solid var(--stone-200);
  background: var(--stone-50);
  color: var(--ink-700);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.chip:hover { background: var(--sage-50); border-color: var(--sage-100); color: var(--sage-600); }

.transcript {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.transcript-empty {
  color: var(--ink-400);
  font-size: 13.5px;
  text-align: center;
  margin: auto;
  padding: 20px 10px;
}

.bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.5;
  animation: fadeIn 0.2s ease;
}
.bubble.guest {
  align-self: flex-end;
  background: var(--ink-900);
  color: var(--white);
  border-bottom-right-radius: 4px;
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--sage-50);
  color: var(--ink-900);
  border-bottom-left-radius: 4px;
}
.bubble.pending { opacity: 0.6; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }

.text-fallback {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--stone-100);
  background: var(--stone-50);
}
.text-fallback input {
  flex: 1;
  border: 1px solid var(--stone-200);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  background: var(--white);
  color: var(--ink-900);
}
.text-fallback input:focus { outline: 2px solid var(--sage-100); border-color: var(--sage-500); }
.text-fallback button {
  border: none;
  background: var(--ink-900);
  color: var(--white);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
}
.text-fallback button:hover { background: var(--sage-600); }

/* ===================== BOOKING PANEL ===================== */
.booking-panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto; /* rare fallback - only if the row below genuinely can't fit */
}

.stay-card { flex: 0 0 auto; }

/* Rooms and cart sit side by side sharing the panel's remaining height,
   instead of stacking and competing for the same vertical space - each
   gets the full height, just a share of the width. Cart gets the bigger
   share since it's what the guest (and Suhana) keeps coming back to
   through the whole conversation. Stays a single column (cart alone, full
   width) until there's actually a room list to show - .has-rooms is added
   by rooms-ui.js the moment show_room_options fires. */
.booking-columns {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
}
.booking-columns.has-rooms { grid-template-columns: 36% 64%; }

.rooms-card {
  height: 100%;
  min-height: 0;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.rooms-card .card-title { flex: 0 0 auto; }
.rooms-card .rooms-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 2px; }

.cart-card {
  height: 100%;
  min-height: 0;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cart-card .card-title { flex: 0 0 auto; }
.cart-card .cart-empty { flex: 0 0 auto; }
.cart-items {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 60px;
  padding-right: 2px;
}
.cart-total-row, .make-payment-button { flex: 0 0 auto; }

.stay-empty, .cart-empty { color: var(--ink-400); font-size: 13.5px; }

.stay-dates { display: flex; align-items: center; gap: 16px; }
.stay-date-label { font-size: 11.5px; color: var(--ink-400); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 3px; }
.stay-date-value { font-family: var(--font-display); font-size: 20px; font-weight: 500; color: var(--ink-900); }
.stay-arrow { color: var(--stone-300); font-size: 18px; margin-top: 14px; }
.stay-meta { margin-top: 12px; font-size: 13.5px; color: var(--ink-500); display: flex; gap: 8px; align-items: center; }
.stay-meta-dot { color: var(--stone-300); }

/* 2 columns within the (now narrower, since it shares the row with the
   cart) rooms column, gracefully down to 1 on a smaller window - still
   fills the empty horizontal space a single full-width row per room used
   to waste. */
.rooms-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 8px; }

.room-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  border: 1px solid var(--stone-100);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--stone-50);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.room-row:hover { border-color: var(--sage-100); }
.room-row.selected { border-color: var(--sage-500); background: var(--sage-50); }

.room-row-name { font-size: 13.5px; font-weight: 600; color: var(--ink-900); line-height: 1.3; }
.room-row-price { font-size: 13px; font-weight: 700; color: var(--ink-900); white-space: nowrap; }
.room-row-price span { font-size: 11px; font-weight: 500; color: var(--ink-400); }

.room-select-btn {
  align-self: stretch;
  margin-top: 2px;
  border: 1px solid var(--ink-900);
  background: var(--white);
  color: var(--ink-900);
  border-radius: 999px;
  padding: 7px 0;
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.room-select-btn:hover { background: var(--ink-900); color: var(--white); }
.room-select-btn.selected { background: var(--sage-600); border-color: var(--sage-600); color: var(--white); }

.info-card-body { font-size: 13.5px; color: var(--ink-700); line-height: 1.6; white-space: pre-line; }

.cart-items { display: flex; flex-direction: column; gap: 10px; }

.cart-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--stone-100);
  animation: fadeIn 0.25s ease;
}
.cart-item:last-child { border-bottom: none; }

.cart-item-info { min-width: 0; }
.cart-item-name { font-size: 14px; font-weight: 600; color: var(--ink-900); }
.cart-item-meta { font-size: 12px; color: var(--ink-500); margin-top: 2px; }
.cart-item-discount-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--sage-100);
  color: var(--sage-600);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.cart-item-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.cart-item-price { font-size: 14px; font-weight: 700; color: var(--ink-900); white-space: nowrap; }

.cart-item-remove {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--stone-200);
  background: var(--white);
  color: var(--ink-400);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cart-item-remove:hover { background: rgba(168, 80, 63, 0.08); color: var(--danger); border-color: rgba(168, 80, 63, 0.3); }

.cart-subtotal-row {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--stone-200);
  font-size: 13px;
  color: var(--ink-500);
}
.cart-discount-row {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--sage-600);
}
.cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1.5px solid var(--ink-900);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-500);
}
.cart-total-row span:last-child { font-size: 22px; color: var(--ink-900); }

.make-payment-button {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--ink-900);
  color: var(--white);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.15s ease, transform 0.1s ease;
}
.make-payment-button:hover:not(:disabled) { background: var(--sage-600); }
.make-payment-button:disabled { background: var(--stone-200); color: var(--ink-400); cursor: not-allowed; }

/* ===================== DEBUG DRAWER ===================== */
.debug-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: var(--ink-900);
  color: var(--stone-100);
  z-index: 100;
  box-shadow: -8px 0 30px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  font-family: "SFMono-Regular", Consolas, monospace;
}
.debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
}
.debug-header button { background: none; border: none; color: var(--stone-200); font-size: 14px; }
.debug-body { padding: 14px 18px; overflow-y: auto; flex: 1; }
.debug-row { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.debug-row span:first-child { color: var(--stone-300); }
.debug-row span:last-child { text-align: right; word-break: break-word; }
.debug-section-title { margin-top: 14px; margin-bottom: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--stone-300); }
.debug-json { font-size: 10.5px; background: rgba(255,255,255,0.05); padding: 10px; border-radius: 8px; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow-y: auto; }

/* ===================== CHECKOUT MODAL ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 38, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 22px;
  border-bottom: 1px solid var(--stone-100);
}
.modal-title { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 15px; color: var(--ink-400); }
.modal-body { padding: 22px; }
.modal-note { font-size: 12.5px; color: var(--ink-500); line-height: 1.5; margin: 0 0 16px; }
.checkout-summary { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.checkout-summary-row { display: flex; justify-content: space-between; }
.checkout-summary-row span:first-child { color: var(--ink-500); }
.checkout-summary-discount { font-weight: 600; }
.checkout-summary-discount span:first-child { color: var(--sage-600); }
.checkout-summary-discount span:last-child { color: var(--sage-600); }
.checkout-total-row {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1.5px solid var(--ink-900);
  font-weight: 700;
  font-size: 17px;
}
.checkout-guest-fields { display: flex; gap: 12px; margin-top: 18px; }
.checkout-field { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink-500); }
.checkout-field input {
  border: 1px solid var(--stone-200);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  background: var(--white);
  color: var(--ink-900);
}
.checkout-field input:focus { outline: 2px solid var(--sage-100); border-color: var(--sage-500); }

.checkout-success { text-align: center; padding: 32px 22px; }
.success-icon {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--sage-100); color: var(--sage-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin: 0 auto 16px;
}
.modal-footer { display: flex; gap: 10px; padding: 18px 22px; border-top: 1px solid var(--stone-100); }
.modal-footer .pill-button { flex: 1; }
.modal-footer .make-payment-button { flex: 1.4; margin-top: 0; }

[hidden] { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--stone-200); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
