@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700;800&family=Lora:ital,wght@0,400;0,500;0,600;1,400&family=Montserrat:wght@400;500;600;700&display=swap');

:root {
  /* HSL Tailored Palettes */
  --bg-cream: #F9F6F0; /* Soft anti-glare cream */
  --bg-card: #FDFCF7; /* Slightly lighter cream for cards */
  --franciscan-brown: #4A3B32; /* Primary Franciscan brown */
  --franciscan-brown-light: #5E4C40;
  --franciscan-brown-dark: #372B25;
  --soft-gold: #D4AF37; /* Elegant metallic gold */
  --soft-gold-light: #E6C655;
  --soft-gold-dim: #C09E2E;
  --text-dark: #2B221C; /* Dark brown for high-contrast reading */
  --text-muted: #6C5F55;
  --border-gold: rgba(212, 175, 55, 0.4);
  
  /* Fonts */
  --font-serif-title: 'Cinzel', serif;
  --font-serif-body: 'Lora', serif;
  --font-sans: 'Montserrat', sans-serif;
  
  /* Shadow & Details */
  --shadow-premium: 0 10px 30px rgba(74, 59, 50, 0.12), 0 1px 3px rgba(74, 59, 50, 0.05);
  --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.06);
  --border-radius-main: 16px;
  --border-radius-btn: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #1a1512; /* Dark elegant backdrop on desktop to focus on the mobile viewport */
  color: var(--text-dark);
  font-family: var(--font-serif-body);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow: hidden;
}

/* Simulated Mobile Frame on Desktop, Fullscreen on Mobile */
.app-container {
  width: 100%;
  max-width: 440px;
  height: 100vh;
  height: -webkit-fill-available;
  background-color: var(--bg-cream);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  border: 4px solid var(--franciscan-brown-dark);
  border-radius: 24px;
  overflow: hidden;
}

@media (max-width: 480px) {
  body {
    background-color: var(--bg-cream);
  }
  .app-container {
    max-width: 100%;
    height: 100vh;
    border: none;
    border-radius: 0;
  }
}

/* Header Styles */
header {
  background-color: var(--franciscan-brown);
  border-bottom: 2px solid var(--soft-gold);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.brand-logo-svg {
  width: 32px;
  height: 32px;
  fill: var(--soft-gold);
}

.brand-name {
  font-family: var(--font-serif-title);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 2px;
  color: var(--soft-gold);
  text-transform: uppercase;
}

.stop-selector-wrapper {
  width: 100%;
  position: relative;
}

.stop-selector {
  width: 100%;
  padding: 8px 12px;
  background-color: var(--franciscan-brown-dark);
  border: 1px solid var(--border-gold);
  border-radius: var(--border-radius-btn);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23D4AF37'%3E%3Cpath d='M7 10l5 5 5-5H7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 20px;
  text-align: center;
  transition: all 0.3s ease;
}

.stop-selector:focus {
  outline: none;
  border-color: var(--soft-gold);
  box-shadow: 0 0 5px rgba(212, 175, 55, 0.4);
}

/* Screen Layout */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Stop Info */
.stop-info {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stop-number {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--soft-gold-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.stop-title {
  font-family: var(--font-serif-title);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--franciscan-brown);
}

/* Image Card Container */
.image-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--border-radius-main);
  overflow: hidden;
  box-shadow: var(--shadow-premium);
  border: 2px solid var(--border-gold);
  background-color: var(--franciscan-brown);
}

.stop-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.image-container:hover .stop-image {
  transform: scale(1.05);
}

/* Audio Player Container */
.audio-player-container {
  background-color: var(--bg-card);
  border: 1px solid rgba(74, 59, 50, 0.08);
  border-radius: var(--border-radius-main);
  padding: 16px;
  box-shadow: var(--shadow-premium);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Audio Time Progress */
.progress-bar-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.timeline {
  width: 100%;
  height: 6px;
  background: #E8E2D5;
  border-radius: 3px;
  position: relative;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
}

.timeline::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  background: transparent;
}

.timeline::-webkit-slider-thumb {
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: var(--soft-gold);
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s ease;
}

.timeline::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--soft-gold-light);
}

.time-indicators {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Controls Grid */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 8px;
}

.secondary-control {
  background: none;
  border: none;
  color: var(--franciscan-brown);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.secondary-control svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.secondary-control:hover {
  background-color: rgba(74, 59, 50, 0.05);
  color: var(--soft-gold);
}

.play-pause-btn {
  background-color: var(--franciscan-brown);
  border: 2px solid var(--soft-gold);
  color: #fff;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(74, 59, 50, 0.2);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.play-pause-btn svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}

.play-pause-btn:hover {
  background-color: var(--franciscan-brown-light);
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(74, 59, 50, 0.3);
}

.play-pause-btn:active {
  transform: scale(0.95);
}

/* Speed Selector */
.speed-control {
  position: relative;
}

.speed-btn {
  background-color: transparent;
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  padding: 4px 8px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--franciscan-brown);
  cursor: pointer;
  transition: all 0.2s ease;
}

.speed-btn:hover {
  background-color: var(--franciscan-brown);
  color: #fff;
  border-color: var(--franciscan-brown);
}

/* Footer Section */
footer {
  background-color: var(--bg-cream);
  padding: 16px;
  border-top: 1px solid rgba(74, 59, 50, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
}

.nav-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
}

.btn {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.9rem;
  border: none;
  border-radius: var(--border-radius-btn);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  padding: 14px 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-primary {
  background-color: var(--franciscan-brown);
  border: 2px solid var(--soft-gold);
  color: #fff;
  flex: 2;
  box-shadow: 0 4px 10px rgba(74, 59, 50, 0.2);
}

.btn-primary:hover {
  background-color: var(--franciscan-brown-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(74, 59, 50, 0.3);
}

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

.btn-secondary {
  background-color: transparent;
  border: 2px solid var(--franciscan-brown);
  color: var(--franciscan-brown);
  flex: 1;
}

.btn-secondary:hover {
  background-color: rgba(74, 59, 50, 0.05);
}

.btn-secondary:disabled, .btn-primary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Subtle stop animations */
.fade-enter {
  opacity: 0;
  transform: scale(0.98);
}

.fade-active {
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* SVG icons helper */
.icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Floating Action Button (FAB) */
.ask-guide-fab {
  position: absolute;
  bottom: 84px;
  right: 16px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--franciscan-brown);
  border: 2px solid var(--soft-gold);
  border-radius: 24px;
  padding: 10px 16px;
  color: #fff;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(74, 59, 50, 0.35);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  animation: fab-glow-pulse 3s infinite;
}

.ask-guide-fab svg {
  width: 16px;
  height: 16px;
  fill: var(--soft-gold);
}

.ask-guide-fab:hover {
  transform: translateY(-2px) scale(1.03);
  background-color: var(--franciscan-brown-light);
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.3);
}

.ask-guide-fab:active {
  transform: translateY(0) scale(0.97);
}

/* Chat Slide-up Sheet (Bottom Sheet) */
.chat-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 480px;
  background: rgba(253, 252, 247, 0.96);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-top: 3px solid var(--soft-gold);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  overflow: hidden;
}

.chat-sheet.hidden {
  transform: translateY(100%);
  pointer-events: none;
  opacity: 0;
}

.chat-drag-handle {
  width: 48px;
  height: 4px;
  background: rgba(74, 59, 50, 0.15);
  border-radius: 2px;
  margin: 10px auto 6px auto;
  flex-shrink: 0;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px 14px 16px;
  border-bottom: 1px solid rgba(74, 59, 50, 0.08);
  flex-shrink: 0;
}

.chat-title-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--franciscan-brown);
  border: 1.5px solid var(--soft-gold);
  color: var(--soft-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif-title);
  font-weight: 700;
  font-size: 1.1rem;
}

.chat-title-area h3 {
  font-family: var(--font-serif-title);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--franciscan-brown);
  line-height: 1.2;
}

.chat-status {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  color: var(--text-muted);
  display: block;
}

.chat-header-actions {
  display: flex;
  gap: 8px;
}

.chat-icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.chat-icon-btn:hover {
  background-color: rgba(74, 59, 50, 0.06);
  color: var(--soft-gold-dim);
}

/* API Key Settings Panel */
.chat-config-panel {
  position: absolute;
  top: 64px;
  left: 16px;
  right: 16px;
  background-color: var(--bg-card);
  border: 1.5px solid var(--border-gold);
  border-radius: 16px;
  padding: 16px;
  z-index: 110;
  box-shadow: 0 8px 24px rgba(74, 59, 50, 0.15);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.3s ease;
}

.chat-config-panel.hidden {
  display: none;
}

.chat-config-panel h4 {
  font-family: var(--font-serif-title);
  font-size: 0.9rem;
  color: var(--franciscan-brown);
}

.chat-config-panel p {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.api-key-input-wrapper {
  display: flex;
  gap: 8px;
}

.api-key-input-wrapper input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(74, 59, 50, 0.2);
  font-size: 0.8rem;
  outline: none;
  font-family: var(--font-sans);
}

.api-key-input-wrapper input:focus {
  border-color: var(--soft-gold);
}

.chat-btn {
  background: var(--franciscan-brown);
  border: 1px solid var(--soft-gold);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.chat-btn:hover {
  background-color: var(--franciscan-brown-light);
}

.api-key-help {
  font-size: 0.68rem !important;
}

.api-key-help a {
  color: var(--soft-gold-dim);
  text-decoration: underline;
}

/* Chat Messages Box */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: rgba(249, 246, 240, 0.5);
}

.message-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.message {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.85rem;
  line-height: 1.45;
  position: relative;
  box-shadow: 0 2px 6px rgba(74, 59, 50, 0.04);
}

.message.guide {
  align-self: flex-start;
  background-color: #fff;
  border: 1px solid rgba(74, 59, 50, 0.08);
  border-top-left-radius: 4px;
  color: var(--text-dark);
  font-style: italic;
}

.message.user {
  align-self: flex-end;
  background-color: var(--franciscan-brown);
  border: 1.5px solid rgba(212, 175, 55, 0.15);
  border-top-right-radius: 4px;
  color: #fff;
}

.message-time {
  font-family: var(--font-sans);
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-top: 4px;
  align-self: flex-end;
  opacity: 0.8;
}

.message.user .message-time {
  color: rgba(255, 255, 255, 0.6);
}

/* Typing / Generating Indicator */
.typing-indicator {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid rgba(74, 59, 50, 0.08);
  border-radius: 16px;
  border-top-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 2px 6px rgba(74, 59, 50, 0.04);
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--soft-gold);
  border-radius: 50%;
  animation: typing-bounce 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;
}

/* Chat Input Bar */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background-color: var(--bg-card);
  border-top: 1px solid rgba(74, 59, 50, 0.08);
  flex-shrink: 0;
}

.chat-input-area input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid rgba(74, 59, 50, 0.12);
  border-radius: 20px;
  font-size: 0.82rem;
  outline: none;
  background-color: var(--bg-cream);
  font-family: var(--font-serif-body);
  transition: all 0.25s ease;
}

.chat-input-area input:focus {
  border-color: var(--soft-gold);
  background-color: #fff;
  box-shadow: 0 0 5px rgba(212, 175, 55, 0.15);
}

.chat-round-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background-color: rgba(74, 59, 50, 0.05);
  color: var(--franciscan-brown);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.chat-round-btn:hover {
  background-color: var(--franciscan-brown);
  color: #fff;
}

.chat-round-btn svg {
  fill: currentColor;
}

.chat-round-btn.send-btn {
  background-color: var(--franciscan-brown);
  color: var(--soft-gold);
  border: 1.5px solid var(--soft-gold);
}

.chat-round-btn.send-btn:hover {
  background-color: var(--franciscan-brown-light);
  transform: scale(1.05);
}

.chat-round-btn.voice-btn.recording {
  background-color: #c0392b;
  color: #fff;
  animation: recording-pulse 1.2s infinite ease-in-out;
}

.chat-round-btn.tts-btn {
  color: var(--text-muted);
}

.chat-round-btn.tts-btn.active {
  color: var(--soft-gold-dim);
  background-color: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.chat-round-btn.tts-btn.active:hover {
  background-color: var(--franciscan-brown);
  color: #fff;
}

/* Animations */
@keyframes fab-glow-pulse {
  0% {
    box-shadow: 0 4px 15px rgba(74, 59, 50, 0.35);
  }
  50% {
    box-shadow: 0 4px 22px rgba(212, 175, 55, 0.5);
    border-color: var(--soft-gold-light);
  }
  100% {
    box-shadow: 0 4px 15px rgba(74, 59, 50, 0.35);
  }
}

@keyframes recording-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(192, 57, 43, 0);
    transform: scale(1.08);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(192, 57, 43, 0);
    transform: scale(1);
  }
}

@keyframes typing-bounce {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  50% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

