/* ===== Variables ===== */
:root {
  --bg-deep: #0d0221;
  --bg-card: #1a0a2e;
  --bg-bubble-bot: #2d1b4e;
  --bg-bubble-user: #1e3a5f;
  --accent-purple: #6b21a8;
  --accent-blue: #3730a3;
  --accent-light: #a78bfa;
  --accent-moon: #e0e7ff;
  --text-primary: #f3e8ff;
  --text-secondary: #c4b5fd;
  --border-subtle: rgba(167, 139, 250, 0.2);
  --shadow-glow: 0 0 40px rgba(107, 33, 168, 0.3);
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Outfit', system-ui, sans-serif;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-deep);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== Background Animation ===== */
.bg-animation {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(107, 33, 168, 0.35), transparent),
    radial-gradient(ellipse 60% 40% at 100% 50%, rgba(55, 48, 163, 0.25), transparent),
    radial-gradient(ellipse 50% 30% at 0% 80%, rgba(139, 92, 246, 0.2), transparent),
    var(--bg-deep);
}

.stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20px 30px, var(--accent-moon), transparent),
    radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.6), transparent),
    radial-gradient(1.5px 1.5px at 90px 40px, var(--accent-light), transparent),
    radial-gradient(2px 2px at 160px 120px, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 230px 80px, var(--text-secondary), transparent);
  background-size: 260px 160px;
  animation: drift 90s linear infinite;
  opacity: 0.7;
}

.twinkle {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20px 30px, var(--accent-moon), transparent),
    radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.6), transparent),
    radial-gradient(1.5px 1.5px at 90px 40px, var(--accent-light), transparent),
    radial-gradient(2px 2px at 160px 120px, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 230px 80px, var(--text-secondary), transparent);
  background-size: 260px 160px;
  animation: drift 70s linear infinite reverse;
  opacity: 0;
  animation: twinkle 4s ease-in-out infinite;
}

@keyframes drift {
  from { transform: translate(0, 0); }
  to { transform: translate(-260px, -160px); }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}

.gradient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: float 20s ease-in-out infinite;
}

.orb-1 {
  width: 320px;
  height: 320px;
  background: var(--accent-purple);
  top: -10%;
  left: -5%;
  animation-delay: 0s;
}

.orb-2 {
  width: 280px;
  height: 280px;
  background: var(--accent-blue);
  bottom: -5%;
  right: -5%;
  animation-delay: -7s;
}

.orb-3 {
  width: 200px;
  height: 200px;
  background: #4c1d95;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(30px, -30px); }
  66% { transform: translate(-20px, 20px); }
}

/* ===== Layout ===== */
.header, .main, .footer {
  position: relative;
  z-index: 1;
}

.header {
  padding: 1.5rem 1rem;
  text-align: center;
}

.header-inner {
  max-width: 420px;
  margin: 0 auto;
}

.logo-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.25rem;
  filter: drop-shadow(0 0 12px rgba(167, 139, 250, 0.6));
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0;
  color: var(--accent-moon);
  letter-spacing: 0.02em;
}

.tagline {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0.25rem 0 0;
  font-weight: 300;
}

/* ===== Chat Container (WhatsApp / Instagram style) ===== */
.main {
  padding: 0 1rem 1rem;
  max-width: 520px;
  margin: 0 auto;
}

.chat-container {
  background: rgba(26, 10, 46, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-glow), 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(45, 27, 78, 0.6);
  border-bottom: 1px solid var(--border-subtle);
}

.chat-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-icon {
  font-size: 1.4rem;
}

.chat-header-info h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.chat-header-info .status {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ===== Messages Area ===== */
.messages {
  min-height: 320px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: var(--bg-bubble-bot);
  border-radius: 3px;
}

.welcome-msg {
  align-self: center;
  text-align: center;
  max-width: 90%;
  padding: 12px 16px;
  background: var(--bg-bubble-bot);
  border-radius: 18px 18px 18px 4px;
  border: 1px solid var(--border-subtle);
}

.welcome-msg p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ===== Login Prompt ===== */
.login-prompt {
  padding: 16px;
  text-align: center;
  border-top: 1px solid var(--border-subtle);
  background: rgba(26, 10, 46, 0.3);
}

.login-prompt.hidden {
  display: none;
}

.login-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: white;
  color: #333;
  border: none;
  border-radius: 24px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

.login-hint {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.9;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: msgIn 0.3s ease;
}

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

.msg.user {
  align-self: flex-end;
}

.msg.bot {
  align-self: flex-start;
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.55;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user .msg-bubble {
  background: var(--bg-bubble-user);
  color: var(--accent-moon);
  border-radius: 18px 18px 4px 18px;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.msg.bot .msg-bubble {
  background: var(--bg-bubble-bot);
  color: var(--text-primary);
  border-radius: 18px 18px 18px 4px;
  border: 1px solid var(--border-subtle);
}

.msg-time {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 4px;
  padding: 0 4px;
}

.msg.user .msg-time {
  text-align: right;
}

/* ===== Typing Indicator ===== */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-bubble-bot);
  border-radius: 18px 18px 18px 4px;
  align-self: flex-start;
  margin-left: 16px;
  margin-bottom: 12px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-light);
  animation: typing 1.4s ease-in-out infinite both;
}

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

@keyframes typing {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.typing-indicator.visible {
  display: flex;
}

/* ===== Input Area ===== */
.input-area {
  padding: 12px 16px 16px;
  background: rgba(26, 10, 46, 0.5);
  border-top: 1px solid var(--border-subtle);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: rgba(45, 27, 78, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: 8px 8px 8px 18px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.2);
}

.message-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  resize: none;
  outline: none;
}

.message-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.8;
}

.send-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
}

.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(107, 33, 168, 0.5);
}

.send-btn:active {
  transform: scale(0.98);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.input-hint {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin: 6px 0 0;
  padding-left: 4px;
  opacity: 0.8;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 1.5rem 1rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 12px;
  margin-bottom: 10px;
}

.footer-link {
  background: none;
  border: none;
  color: var(--accent-light);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  padding: 0 4px;
  transition: color 0.2s, opacity 0.2s;
}

.footer-link:hover {
  color: var(--accent-moon);
  opacity: 0.95;
}

a.footer-link {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-sep {
  color: var(--text-secondary);
  font-size: 0.75rem;
  opacity: 0.6;
}

.footer p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  opacity: 0.9;
}

/* ===== Modal (Hakkında, Gizlilik) ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal.open {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  cursor: pointer;
}

.modal .modal-content {
  position: relative;
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-glow);
}

.modal .modal-content h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 16px;
  color: var(--accent-moon);
}

.modal .modal-content p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

.modal .modal-content a {
  color: var(--accent-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.modal .modal-content a:hover {
  color: var(--accent-moon);
}

.modal .modal-close {
  display: block;
  margin-top: 16px;
  padding: 10px 20px;
  background: rgba(107, 33, 168, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.modal .modal-close:hover {
  background: rgba(107, 33, 168, 0.7);
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
  .header { padding: 1rem 0.75rem; }
  .logo-text { font-size: 1.5rem; }
  .main { padding: 0 0.75rem 1rem; }
  .chat-container { border-radius: 20px; }
  .messages {
    min-height: 280px;
    max-height: 50vh;
    padding: 12px;
  }
  .msg { max-width: 92%; }
  .chat-header { padding: 12px 14px; }
  .input-area { padding: 10px 12px 14px; }
}

@media (max-width: 360px) {
  .logo-icon { font-size: 2rem; }
  .logo-text { font-size: 1.35rem; }
  .msg-bubble { font-size: 0.9rem; padding: 10px 14px; }
}

/* ===== Popüler Rüya Tabirleri (Ana sayfa) ===== */
.populer-tabirler {
  padding: 2rem 1rem 2.5rem;
  max-width: 520px;
  margin: 0 auto;
}

.populer-tabirler-baslik {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent-moon);
  margin: 0 0 0.5rem;
  text-align: center;
}

.populer-tabirler-aciklama {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

.tabir-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.tabir-card {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: rgba(45, 27, 78, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  animation: tabirCardIn 0.4s ease backwards;
}

.tabir-grid .tabir-card:nth-child(1) { animation-delay: 0.05s; }
.tabir-grid .tabir-card:nth-child(2) { animation-delay: 0.1s; }
.tabir-grid .tabir-card:nth-child(3) { animation-delay: 0.15s; }
.tabir-grid .tabir-card:nth-child(4) { animation-delay: 0.2s; }
.tabir-grid .tabir-card:nth-child(5) { animation-delay: 0.25s; }
.tabir-grid .tabir-card:nth-child(6) { animation-delay: 0.3s; }
.tabir-grid .tabir-card:nth-child(7) { animation-delay: 0.35s; }
.tabir-grid .tabir-card:nth-child(8) { animation-delay: 0.4s; }
.tabir-grid .tabir-card:nth-child(9) { animation-delay: 0.45s; }
.tabir-grid .tabir-card:nth-child(n+10) { animation-delay: 0.5s; }

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

.tabir-card:hover {
  border-color: var(--accent-light);
  box-shadow: 0 0 20px rgba(167, 139, 250, 0.25);
  transform: translateY(-2px);
}

.tabir-card:active {
  transform: translateY(0);
}

@media (max-width: 380px) {
  .tabir-grid { grid-template-columns: 1fr; }
  .tabir-card { font-size: 0.9rem; }
}

/* ===== Tabir sayfa (tekil rüya tabiri) ===== */
.tabir-page .logo-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}

.tabir-page .logo-link:hover {
  color: var(--accent-light);
}

.tabir-main {
  padding: 1rem 1rem 2rem;
}

.tabir-article {
  background: rgba(26, 10, 46, 0.85);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: var(--shadow-glow);
}

.tabir-article h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--accent-moon);
  margin: 0 0 1rem;
}

.tabir-article p {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin: 0 0 1rem;
}

.tabir-cta-wrap {
  margin-top: 1.5rem;
  text-align: center;
}

.tabir-cta {
  display: inline-block;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  color: white;
  text-decoration: none;
  border-radius: 24px;
  font-weight: 500;
  font-size: 0.95rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.tabir-cta:hover {
  transform: scale(1.03);
  box-shadow: 0 0 24px rgba(107, 33, 168, 0.5);
}

/* ===== Mesaj paylaş butonları ===== */
.msg-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.msg.bot .msg-actions {
  justify-content: flex-start;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-subtle);
  background: rgba(45, 27, 78, 0.5);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.share-btn:hover {
  background: rgba(107, 33, 168, 0.3);
  color: var(--accent-moon);
}

.share-btn svg {
  width: 14px;
  height: 14px;
}

/* ===== Rüya Günlüğü Modal ===== */
.modal-dream-journal {
  max-height: 85vh;
}

.dream-journal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.dream-journal-icon {
  font-size: 1.5rem;
  filter: drop-shadow(0 0 8px rgba(167, 139, 250, 0.4));
}

.dream-journal-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.dream-journal-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 4px;
}

.dream-journal-list::-webkit-scrollbar {
  width: 5px;
}

.dream-journal-list::-webkit-scrollbar-thumb {
  background: var(--bg-bubble-bot);
  border-radius: 3px;
}

.dream-card {
  background: rgba(45, 27, 78, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.dream-card:hover {
  border-color: rgba(167, 139, 250, 0.4);
  box-shadow: 0 0 16px rgba(107, 33, 168, 0.15);
}

.dream-card-date {
  font-size: 0.75rem;
  color: var(--accent-light);
  margin-bottom: 8px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.dream-card-content {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.dream-journal-empty,
.dream-journal-loading {
  text-align: center;
  padding: 2rem 1rem;
}

.dream-journal-empty-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 12px;
  opacity: 0.8;
}

.dream-journal-empty p {
  margin: 0 0 6px;
  color: var(--text-secondary);
}

.dream-journal-empty-hint {
  font-size: 0.8rem !important;
  opacity: 0.85;
}

.dream-journal-loading {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.footer-link-journal.hidden,
.footer-sep-journal.hidden {
  display: none !important;
}

/* ===== Reduce motion ===== */
@media (prefers-reduced-motion: reduce) {
  .stars, .twinkle { animation: none; }
  .gradient-orb { animation: none; }
  .msg { animation: none; }
  .tabir-card { animation: none; }
  .tabir-card:hover { transform: none; }
  .tabir-cta:hover { transform: none; }
}
