/* ═══════════════════════════════════════════════════════════
   CHAT WITH DAN — Mobile-First Style  
   Clean, warm, iOS/Android native feel
═══════════════════════════════════════════════════════════ */

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

:root {
  --bg:          #0f0f17;
  --surface:     #191926;
  --card:        #20202e;
  --input-bg:    #252538;
  --border:      rgba(255,255,255,0.07);

  --pink:        #e91e63;
  --pink-dark:   #c2185b;
  --pink-light:  #f48fb1;
  --violet:      #a78bfa;
  --green:       #34d399;

  --txt:         #f0eff8;
  --txt2:        #9896b8;
  --txt3:        #5a5878;

  --radius:      18px;
  --font:        'Inter', system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--txt);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ── Screens ─────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.38s cubic-bezier(0.4,0,0.2,1);
  will-change: transform;
}
.screen.active {
  transform: translateX(0);
}

/* ══ SPLASH / NAME SCREEN ═══════════════════════════════════ */
#nameScreen {
  background: var(--bg);
  align-items: center;
  justify-content: center;
  padding: 32px 28px;
  overflow-y: auto;
}

.splash-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 60% 10%, rgba(233,30,99,0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 30% 90%, rgba(167,139,250,0.12) 0%, transparent 50%);
  pointer-events: none;
}

.splash-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 360px;
}

/* Splash avatar */
.splash-avatar-wrap {
  position: relative;
  margin-bottom: 4px;
}
.splash-avatar,
.splash-avatar-fallback {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.splash-avatar-fallback {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--card);
  font-size: 44px;
  border: 3px solid var(--pink);
}
.splash-avatar { border: 3px solid var(--pink); }
.online-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(233,30,99,0.3);
  animation: ring-pulse 2.5s ease-in-out infinite;
}
@keyframes ring-pulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50%       { transform: scale(1.08); opacity: 0.2; }
}

.splash-name {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.splash-sub {
  font-size: 14px;
  color: var(--txt2);
}
.splash-tagline {
  font-size: 13px;
  color: var(--pink-light);
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* Name form */
.name-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
}

.name-input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  color: var(--txt);
  font-family: var(--font);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.name-input::placeholder { color: var(--txt3); }
.name-input:focus { border-color: var(--pink); }

.start-btn {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, var(--pink-dark), var(--pink));
  color: #fff;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(233,30,99,0.35);
}
.start-btn:active { transform: scale(0.97); }

.cancel-btn {
  width: 100%;
  padding: 13px;
  background: transparent;
  color: var(--txt2);
  font-family: var(--font);
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  margin-top: 4px;
}

.splash-hint {
  font-size: 12px;
  color: var(--txt3);
  margin-top: 4px;
}

/* ══ CHAT SCREEN ═════════════════════════════════════════════ */
#chatScreen {
  background: var(--bg);
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(15,15,23,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-shrink: 0;
  z-index: 10;
}

.back-btn {
  font-size: 26px;
  color: var(--txt2);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  flex-shrink: 0;
}

.header-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.header-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.header-avatar,
.header-avatar-fb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 2px solid var(--pink);
}
.header-avatar-fb {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--card);
  font-size: 18px;
}
.header-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--bg);
  animation: dot-pulse 2s infinite;
}
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.5); }
  50%       { box-shadow: 0 0 0 4px rgba(52,211,153,0); }
}

.header-name { font-size: 16px; font-weight: 600; }
.header-status { font-size: 12px; color: var(--green); }

.header-action {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
  color: var(--txt2);
  flex-shrink: 0;
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.messages::-webkit-scrollbar { display: none; }

/* Message bubbles */
.msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: msg-in 0.25s ease;
  max-width: 82%;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg.from-dan { align-self: flex-start; }
.msg.from-user { align-self: flex-end; flex-direction: row-reverse; }

.msg-av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border: 1.5px solid rgba(233,30,99,0.3);
}
.msg-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg.from-user .msg-av { display: none; }

.bubble {
  padding: 10px 14px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

.from-dan .bubble {
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--txt);
}

.from-user .bubble {
  background: linear-gradient(135deg, #c2185b, #e91e63);
  border-bottom-right-radius: 4px;
  color: #fff;
}

/* Date separator */
.date-sep {
  text-align: center;
  font-size: 12px;
  color: var(--txt3);
  margin: 8px 0 4px;
}

/* Typing dots */
.typing-dots {
  display: flex;
  gap: 5px;
  padding: 4px 2px;
  align-items: center;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pink-light);
  animation: dot-bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

/* Input bar */
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(15,15,23,0.95);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 11px 16px;
  color: var(--txt);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  outline: none;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  -webkit-appearance: none;
  transition: border-color 0.2s;
}
.chat-input::placeholder { color: var(--txt3); }
.chat-input:focus { border-color: rgba(233,30,99,0.4); }

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink-dark), var(--pink));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 14px rgba(233,30,99,0.4);
  transition: all 0.2s;
}
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.35; }
.send-btn svg { width: 18px; height: 18px; stroke: #fff; display: block; }

/* ══ GALLERY MODAL ═══════════════════════════════════════════ */
.gallery-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
}
.gallery-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.gallery-modal {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  z-index: 201;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  padding-bottom: env(safe-area-inset-bottom);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.gallery-modal.open {
  transform: translateY(0);
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px 10px;
  position: relative;
  flex-shrink: 0;
}
.gallery-title { font-size: 16px; font-weight: 600; }
.gallery-close {
  position: absolute;
  right: 16px;
  top: 14px;
  background: var(--card);
  border: none;
  color: var(--txt2);
  font-size: 15px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-hero {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  height: 50vw;
  max-height: 280px;
  overflow: hidden;
}
.gallery-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-thumbs {
  display: flex;
  gap: 6px;
  padding: 12px 14px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.gallery-thumbs::-webkit-scrollbar { display: none; }

.thumb {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s;
}
.thumb.active { border-color: var(--pink); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ══ SETTINGS DRAWER ═════════════════════════════════════════ */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.settings-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  z-index: 301;
  padding: 20px 24px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.settings-drawer.open { transform: translateY(0); }
.drawer-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 10px;
  align-self: center;
  margin-bottom: 4px;
}
.settings-drawer h3 { font-size: 18px; font-weight: 600; }
.settings-hint { font-size: 13px; color: var(--txt2); line-height: 1.5; margin-top: -4px; }

/* ══ TOAST ═══════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--txt);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 999;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
