/* ==========================================================================
   Jyoti — WhatsApp simulator styles
   Plain CSS, no framework, no build step.
   ========================================================================== */

:root {
  --wa-header-green: #075E54;
  --wa-chat-bg: #E5DDD5;
  --wa-user-bubble: #DCF8C6;
  --wa-purohit-bubble: #FFFFFF;
  --wa-disclaimer-bg: #FFF3C4;
  --wa-tick-grey: #8696a0;
  --text-dark: #111b21;
  --text-muted: #667781;
  --panel-width: 420px;
  --phone-max-width: 480px;
}

* {
  box-sizing: border-box;
}

/* Generic hide utility — app.js toggles this on the input bar (while
   recording), buttons, toast, dev panel, etc. */
.hidden {
  display: none !important;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #d9d9d9;
  color: var(--text-dark);
}

/* ============ App shell / layout ============ */

.app-shell {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.phone {
  flex: 1 1 auto;
  max-width: var(--phone-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--wa-chat-bg);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.25);
  min-width: 0;
}

/* When the dev panel is open, drop the auto side margins so the two
   columns sit side by side instead of the phone staying centered
   under the panel. */
.app-shell:has(.dev-panel:not(.hidden)) .phone {
  margin: 0;
}

/* ============ Chat header ============ */

.chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--wa-header-green);
  color: #fff;
  padding: 10px 14px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffffff33;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex: 0 0 auto;
}

.header-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.contact-name {
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-line {
  font-size: 12.5px;
  color: #d9fdd3;
  opacity: 0.9;
}

.dev-toggle-btn {
  flex: 0 0 auto;
  background: #ffffff22;
  color: #fff;
  border: 1px solid #ffffff55;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.dev-toggle-btn:hover {
  background: #ffffff3a;
}

.round-header-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  background: #ffffff22;
  color: #fff;
  border: 1px solid #ffffff55;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.round-header-btn:hover {
  background: #ffffff3a;
}

/* ============ Chat area ============ */

.chat-area {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background-color: var(--wa-chat-bg);
  background-image:
    radial-gradient(circle at 25% 15%, rgba(0,0,0,0.02) 0, transparent 40%),
    radial-gradient(circle at 75% 65%, rgba(0,0,0,0.02) 0, transparent 40%);
}

/* ============ Message bubbles ============ */

.bubble-row {
  display: flex;
  width: 100%;
}

.bubble-row.from-user {
  justify-content: flex-end;
}

.bubble-row.from-purohit {
  justify-content: flex-start;
}

.bubble-row.from-system {
  justify-content: center;
}

.bubble {
  max-width: 78%;
  padding: 6px 9px 6px 10px;
  border-radius: 8px;
  font-size: 14.3px;
  line-height: 1.35;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
  word-wrap: break-word;
  white-space: pre-wrap;
}

.bubble.user {
  background: var(--wa-user-bubble);
  border-top-right-radius: 0;
}

.bubble.purohit {
  background: var(--wa-purohit-bubble);
  border-top-left-radius: 0;
}

.bubble.disclaimer {
  background: var(--wa-disclaimer-bg);
  border-radius: 8px;
  text-align: center;
  font-size: 12.5px;
  color: #6b5b00;
  max-width: 90%;
  box-shadow: none;
}

.bubble.translation {
  background: #F5F5F0;
  font-size: 13px;
  font-style: italic;
  color: var(--text-muted);
  padding-top: 16px;
}

.translation-tag {
  position: absolute;
  top: 3px;
  left: 8px;
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #8a8a80;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
  padding: 1px 4px;
}

.bubble-text {
  display: block;
}

.bubble-image {
  display: block;
  width: 100%;
  max-width: 280px;
  border-radius: 8px;
  background: #fffdf8;
}

.bubble-text code,
.bubble-text-code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 3px;
  padding: 1px 4px;
}

.bubble-text pre {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 6px;
  padding: 6px 8px;
  margin: 4px 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.bubble-text pre code {
  background: none;
  padding: 0;
}

/* Tap-to-answer chips (e.g. the language chooser) */
.quick-reply-row {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  padding: 2px 4px 4px;
  flex-wrap: wrap;
}

.quick-reply-chip {
  border: 1.5px solid var(--wa-header-green);
  background: #fff;
  color: var(--wa-header-green);
  border-radius: 18px;
  padding: 7px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.quick-reply-chip:hover {
  background: #e7f5f1;
}

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-muted);
  user-select: none;
}

.bubble.user .bubble-meta {
  color: #667781;
}

.tick {
  color: var(--wa-tick-grey);
  font-size: 12px;
}

.transcript-line {
  margin-top: 3px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
  text-align: right;
}

.bubble audio {
  max-width: 220px;
  height: 32px;
}

/* Typing indicator bubble (reuses purohit bubble style) */
.typing-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 1px;
  background: #9aa5aa;
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ============ Input bar ============ */

.input-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #f0f0f0;
}

.text-input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14.5px;
  outline: none;
  background: #fff;
}

.round-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--wa-header-green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.round-btn:hover {
  filter: brightness(1.08);
}

.round-btn.hidden {
  display: none;
}

/* ============ Recording bar ============ */

.record-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #f0f0f0;
}

.record-bar.hidden {
  display: none;
}

.rec-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e34141;
  animation: pulse-red 1s infinite;
  flex: 0 0 auto;
}

@keyframes pulse-red {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

#recTimer {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--text-dark);
}

.rec-hint {
  flex: 1 1 auto;
  font-size: 13px;
  color: var(--text-muted);
}

.stop-record-btn {
  flex: 0 0 auto;
  border: none;
  border-radius: 18px;
  background: #e34141;
  color: #fff;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}

.stop-record-btn:hover {
  filter: brightness(1.08);
}

/* ============ Toast (errors) ============ */

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #d32f2f;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-width: 90vw;
  text-align: center;
}

.toast.hidden {
  display: none;
}

/* ============ Identity modal ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 22px 24px;
  width: 340px;
  max-width: 90vw;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  border-top: 4px solid var(--wa-header-green);
}

.modal-title {
  margin: 0 0 14px;
  font-size: 18px;
  color: var(--text-dark);
}

.modal-input {
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14.5px;
  outline: none;
}

.modal-input:focus {
  border-color: var(--wa-header-green);
}

.modal-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 10px 0 0;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.modal-btn-primary {
  width: 100%;
  text-align: center;
  padding: 10px 14px;
}

.modal-btn-secondary {
  width: 100%;
  text-align: center;
  padding: 8px 14px;
  border-color: #ccc;
  color: var(--text-muted);
}

/* ============ Auth gate modals (main + dev) — visually distinct ============ */

.modal-box-auth {
  border-top: 4px solid #222;
  background: #1f1f22;
  color: #f5f5f5;
}

.modal-box-auth .modal-title {
  color: #f5f5f5;
  text-align: center;
}

.modal-box-auth .modal-input {
  background: #2c2c30;
  border: 1px solid #444;
  color: #f5f5f5;
}

.modal-box-auth .modal-input:focus {
  border-color: #8ab4f8;
}

.modal-box-auth .modal-actions {
  margin-top: 14px;
}

/* ============ Dev panel identity line ============ */

.identity-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 2px 10px;
  border-bottom: 1px solid #eee;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

#identityUserIdLabel {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  color: var(--text-dark);
  font-weight: 600;
}

.link-btn {
  background: none;
  border: none;
  color: var(--wa-header-green);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.link-btn:hover {
  filter: brightness(1.2);
}

/* ============ Dev panel ============ */

.dev-panel {
  flex: 0 0 auto;
  width: var(--panel-width);
  max-width: 90vw;
  height: 100%;
  background: #fafafa;
  border-left: 1px solid #d0d0d0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dev-panel.hidden {
  display: none;
}

.dev-panel-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--wa-header-green);
  color: #fff;
}

.dev-panel-header h2 {
  font-size: 16px;
  margin: 0;
}

.dev-close-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}

.dev-panel-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 14px 30px;
}

.dev-section {
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  margin-bottom: 12px;
  overflow: hidden;
}

.dev-section summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 14px;
  background: #f3f3f3;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.dev-section-content {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mono-textarea {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  min-height: 260px;
  width: 100%;
  resize: vertical;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 8px;
  line-height: 1.4;
}

.saved-context-textarea {
  min-height: 200px;
}

.dev-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dev-btn {
  border: 1px solid var(--wa-header-green);
  background: var(--wa-header-green);
  color: #fff;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}

.dev-btn:hover {
  filter: brightness(1.1);
}

.dev-btn-secondary {
  background: #fff;
  color: var(--wa-header-green);
}

.saved-flash {
  color: #1b7d1b;
  font-size: 13px;
  transition: opacity 0.4s ease;
}

.saved-flash.hidden {
  display: none;
}

.saved-flash.fade-out {
  opacity: 0;
}

.badge {
  display: inline-block;
  background: #e2f6e2;
  color: #146c14;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  padding: 2px 8px;
  margin-left: auto;
}

.badge-muted {
  background: #eee;
  color: #666;
}

.badge-active {
  background: #ffe3b3;
  color: #8a5300;
}

.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-error {
  color: #c0392b;
  font-size: 12.5px;
  background: #fdecea;
  border: 1px solid #f5c6c0;
  border-radius: 6px;
  padding: 6px 10px;
}

.inline-error.hidden {
  display: none;
}

.inspect-meta {
  font-size: 13px;
  color: var(--text-dark);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.inspect-pre {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  background: #f7f7f7;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 10px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.settings-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.settings-select {
  padding: 6px 8px;
  font-size: 14px;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: #fff;
}

.settings-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.settings-checkbox-label {
  gap: 3px;
}

.settings-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dark);
}

.settings-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--wa-header-green, #075E54);
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid #eee;
  padding-top: 8px;
  margin-top: 2px;
}

.settings-group-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
}

.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-range {
  flex: 1 1 auto;
  min-width: 0;
}

.range-value {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--text-dark);
  font-variant-numeric: tabular-nums;
  min-width: 88px;
  text-align: right;
}

.dev-btn-danger {
  border: 1px solid #d32f2f;
  background: #fff;
  color: #d32f2f;
}

.dev-btn-danger:hover {
  background: #fdecea;
}

/* ============ Responsive ============ */

@media (max-width: 900px) {
  .dev-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: min(var(--panel-width), 100vw);
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.25);
    z-index: 500;
  }
}

@media (max-width: 480px) {
  .phone {
    max-width: 100%;
    box-shadow: none;
  }
}
