/* =============================================
   HypnoDIALOG® Chat App – Stylesheet
   ============================================= */

/* --- CSS Custom Properties --- */
:root {
  --color-petrol:       #037e82;
  --color-petrol-light: #04a6ab;
  --color-petrol-dark:  #005b5e;
  --color-gold:         #db9e02;
  --color-gold-light:   #f0b81a;
  --color-bg:           #f9f7f2;
  --color-text:         #202020;
  --color-text-muted:   #6b7280;
  --color-white:        #ffffff;
  --color-bubble-ai:    #ffffff;
  --color-bubble-user:  #037e82;
  --color-border:       #e5e1d8;
  --color-shadow:       rgba(3, 126, 130, 0.10);

  --font-heading: 'Fraunces', Georgia, serif;
  --font-body:    'Inter', system-ui, sans-serif;

  --radius-btn:     8px;
  --radius-bubble:  18px;
  --radius-card:    20px;
  --max-width:      720px;

  --transition: 0.25s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* --- Header --- */
.app-header {
  background: linear-gradient(135deg, #04a6ab 0%, #037e82 50%, #005b5e 100%);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.18);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.brand {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--color-white);
  letter-spacing: 0.01em;
}

.brand sup {
  font-size: 0.6em;
  vertical-align: super;
  letter-spacing: 0;
}

.header-tagline {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.75);
  letter-spacing: 0.04em;
}

/* --- Main wrapper --- */
.app-wrapper {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 32px 16px 24px;
  position: relative;
}

/* --- Screen visibility --- */
.screen {
  display: none;
  animation: fadeIn 0.4s ease;
}

.screen.active {
  display: block;
}

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

/* =============================================
   WELCOME SCREEN
   ============================================= */
.welcome-card {
  background: var(--color-white);
  border-radius: var(--radius-card);
  padding: 48px 40px 40px;
  box-shadow: 0 4px 32px var(--color-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  text-align: center;
}

.welcome-title {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 2rem;
  color: var(--color-petrol-dark);
  line-height: 1.2;
}

.welcome-lead {
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--color-text-muted);
  font-weight: 300;
}

/* Breath box */
.breath-box {
  background: linear-gradient(135deg, rgba(4,166,171,0.06) 0%, rgba(3,126,130,0.04) 100%);
  border: 1px solid rgba(3,126,130,0.15);
  border-radius: var(--radius-card);
  padding: 32px 28px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.breath-icon {
  width: 80px;
  height: 80px;
  transition: transform 0.8s ease;
}

.breath-core {
  transition: r 0.8s ease;
}

.breath-icon.inhale {
  transform: scale(1.4);
}

.breath-icon.exhale {
  transform: scale(0.85);
}

.breath-instruction {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-style: italic;
  color: var(--color-petrol);
  font-weight: 300;
  min-height: 1.5em;
}

.breath-hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.btn-breath {
  background: transparent;
  border: 1.5px solid var(--color-petrol);
  color: var(--color-petrol);
  border-radius: var(--radius-btn);
  padding: 10px 24px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.btn-breath:hover {
  background: var(--color-petrol);
  color: var(--color-white);
}

/* Theme prompt */
.theme-prompt {
  background: rgba(219,158,2,0.07);
  border-left: 3px solid var(--color-gold);
  border-radius: 0 12px 12px 0;
  padding: 16px 20px;
  text-align: left;
  width: 100%;
}

.theme-prompt p {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--color-text);
}

/* Primary button */
.btn-primary {
  background: var(--color-petrol);
  color: var(--color-white);
  border: none;
  border-radius: var(--radius-btn);
  padding: 14px 36px;
  min-height: 48px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.btn-primary:hover {
  background: var(--color-gold);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(219,158,2,0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-start {
  min-width: 260px;
  justify-content: center;
}

/* Privacy hint */
.privacy-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* =============================================
   CHAT SCREEN
   ============================================= */
.chat-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: calc(100vh - 200px);
}

.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 12px;
  overflow-y: auto;
}

/* Chat bubbles */
.message {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: bubbleIn 0.3s ease;
}

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

.message.ai {
  align-self: flex-start;
  align-items: flex-start;
}

.message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-bubble);
  font-size: 0.97rem;
  line-height: 1.75;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}

.message.ai .message-bubble {
  background: var(--color-bubble-ai);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--color-border);
}

.message.user .message-bubble {
  background: var(--color-bubble-user);
  color: var(--color-white);
  border-bottom-right-radius: 4px;
}

.message-sender {
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  padding: 0 4px;
}

.message.user .message-sender {
  color: var(--color-petrol);
}

/* Typing indicator */
.typing-indicator {
  align-self: flex-start;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-bubble);
  border-bottom-left-radius: 4px;
  padding: 14px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  margin-bottom: 4px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  background: var(--color-petrol);
  border-radius: 50%;
  opacity: 0.4;
  animation: typingDot 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 80%, 100% { opacity: 0.4; transform: scale(0.9); }
  40%           { opacity: 1;   transform: scale(1.15); }
}

/* Step counter / progress bar */
.step-counter {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 8px;
}

.step-bar-bg {
  flex: 1;
  height: 4px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}

.step-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-petrol-light), var(--color-gold));
  border-radius: 4px;
  transition: width 0.5s ease;
}

.step-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* Input area */
.input-area {
  background: var(--color-white);
  border: 1.5px solid var(--color-border);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 -2px 20px rgba(0,0,0,0.04);
  position: sticky;
  bottom: 12px;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.user-textarea {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.97rem;
  line-height: 1.5;
  color: var(--color-text);
  max-height: 120px;
  overflow-y: auto;
  padding: 4px 0;
}

.user-textarea::placeholder {
  color: #b0aba0;
}

/* Mic button */
.btn-mic {
  width: 44px;
  height: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.btn-mic:hover {
  border-color: var(--color-petrol);
  color: var(--color-petrol);
  background: rgba(3,126,130,0.05);
}

.btn-mic.recording {
  background: #fee2e2;
  border-color: #ef4444;
  color: #ef4444;
  animation: pulse-mic 1s infinite;
}

@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
  50%       { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* Send button */
.btn-send {
  width: 44px;
  height: 44px;
  min-height: 44px;
  border-radius: var(--radius-btn);
  border: none;
  background: var(--color-petrol);
  color: var(--color-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform var(--transition);
  flex-shrink: 0;
}

.btn-send:hover {
  background: var(--color-gold);
  transform: scale(1.05);
}

.btn-send:disabled {
  background: var(--color-border);
  color: var(--color-text-muted);
  cursor: not-allowed;
  transform: none;
}

/* Mic status */
.mic-status {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  min-height: 1.2em;
  padding-top: 6px;
  padding-left: 4px;
  text-align: center;
}

.mic-status.recording {
  color: #ef4444;
  font-weight: 500;
}

/* =============================================
   SUMMARY SCREEN
   ============================================= */
.summary-card {
  background: var(--color-white);
  border-radius: var(--radius-card);
  padding: 44px 40px 40px;
  box-shadow: 0 4px 32px var(--color-shadow);
}

.summary-header {
  text-align: center;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
}

.summary-title {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 1.8rem;
  color: var(--color-petrol-dark);
  margin-bottom: 8px;
}

.summary-subtitle {
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

.summary-content {
  font-size: 0.97rem;
  line-height: 1.8;
  color: var(--color-text);
  white-space: pre-wrap;
}

/* Summary actions */
.summary-actions {
  margin-top: 36px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-secondary {
  background: transparent;
  color: var(--color-petrol);
  border: 1.5px solid var(--color-petrol);
  border-radius: var(--radius-btn);
  padding: 14px 28px;
  min-height: 48px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary:hover {
  background: var(--color-petrol);
  color: var(--color-white);
}

.btn-copy {
  min-width: 220px;
  justify-content: center;
}

.copy-feedback {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--color-petrol);
  text-align: center;
  min-height: 1.2em;
  font-weight: 500;
}

/* =============================================
   FOOTER
   ============================================= */
.app-footer {
  background: var(--color-white);
  border-top: 1px solid var(--color-border);
  padding: 18px 24px;
  text-align: center;
}

.footer-disclaimer {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.footer-copy {
  font-size: 0.78rem;
  color: #b0aba0;
}

/* =============================================
   ERROR / INFO TOAST
   ============================================= */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--color-petrol-dark);
  color: var(--color-white);
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.toast.visible {
  opacity: 1;
}

.toast.error {
  background: #dc2626;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 600px) {
  .app-wrapper {
    padding: 16px 10px 16px;
  }

  .welcome-card,
  .summary-card {
    padding: 32px 20px 28px;
  }

  .welcome-title {
    font-size: 1.6rem;
  }

  .summary-title {
    font-size: 1.4rem;
  }

  .message {
    max-width: 94%;
  }

  .header-tagline {
    display: none;
  }

  .summary-actions {
    flex-direction: column;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    justify-content: center;
  }

  .input-area {
    border-radius: 12px;
    bottom: 6px;
  }
}

@media (max-width: 380px) {
  .brand {
    font-size: 1.15rem;
  }
}
