/* ============================================================
   OSHADI dashboard — white & pink theme
   ============================================================ */
:root {
  --pink: #ff6fa5;
  --pink-deep: #ff4f9a;
  --pink-soft: #ffd6e6;
  --pink-mist: #fff2f7;
  --ink: #4a3340;
  --ink-soft: #9b8893;
  --white: #ffffff;
  --shadow: 0 18px 50px rgba(255, 111, 165, 0.18);
  --accent: var(--pink); /* changes with mood */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: "Quicksand", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, #ffe3ef 0%, transparent 60%),
    radial-gradient(1000px 500px at -10% 110%, #ffe9f2 0%, transparent 55%),
    #fff;
}

.app {
  display: grid;
  grid-template-columns: clamp(260px, 24vw, 300px) 1fr;
  gap: clamp(14px, 1.6vw, 22px);
  height: 100vh;
  height: 100dvh;
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(14px, 1.8vw, 22px);
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--white);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border: 1px solid #ffe6f0;
  max-height: calc(100vh - 44px);
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--pink-soft); border-radius: 99px; }

.brand { text-align: center; }
.brand-avatar {
  width: 84px; height: 84px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 42px;
  background: linear-gradient(145deg, var(--pink-soft), #fff);
  box-shadow: 0 10px 26px rgba(255, 111, 165, 0.35), inset 0 0 0 4px #fff;
  border: 2px solid var(--accent);
  transition: border-color .5s, box-shadow .5s;
  animation: bob 4s ease-in-out infinite;
}
@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }

.brand-name {
  font-family: "Dancing Script", cursive;
  font-size: 38px; font-weight: 700;
  color: var(--pink-deep);
  line-height: 1;
}
.brand-tag { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

.mood-card {
  background: var(--pink-mist);
  border-radius: 18px;
  padding: 16px;
  text-align: center;
  border: 1px solid #ffe0ec;
}
.mood-card-title {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 8px;
}
.mood-now { display: flex; align-items: center; justify-content: center; gap: 8px; }
.mood-now-emoji { font-size: 30px; animation: pop .5s ease; }
.mood-now-label { font-size: 18px; font-weight: 600; color: var(--accent); transition: color .5s; }
@keyframes pop { 0%{transform:scale(.4)} 70%{transform:scale(1.2)} 100%{transform:scale(1)} }

.mood-bar {
  height: 7px; border-radius: 99px; margin-top: 12px;
  background: #ffe0ec; overflow: hidden;
}
.mood-bar span {
  display: block; height: 100%; width: 70%;
  background: linear-gradient(90deg, var(--accent), #ffb3d1);
  border-radius: 99px; transition: width .6s, background .5s;
}

/* ---- Bond / affection ---- */
.bond-card {
  background: linear-gradient(180deg, #fff, var(--pink-mist));
  border: 1px solid #ffe0ec; border-radius: 18px; padding: 14px 16px;
}
.bond-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--ink); }
.bond-pct { color: var(--pink-deep); }
.bond-bar { height: 9px; border-radius: 99px; background: #ffe0ec; overflow: hidden; margin: 9px 0 7px; }
.bond-bar span {
  display: block; height: 100%; width: 20%;
  background: linear-gradient(90deg, #ff9ec4, var(--pink-deep));
  border-radius: 99px; transition: width .6s ease;
}
.bond-label { font-size: 12px; color: var(--ink-soft); text-align: center; font-style: italic; }

.panel { display: flex; flex-direction: column; gap: 14px; }
.panel.scroll { overflow-y: auto; padding-right: 4px; }
.panel.scroll::-webkit-scrollbar { width: 6px; }
.panel.scroll::-webkit-scrollbar-thumb { background: var(--pink-soft); border-radius: 99px; }

/* ---- Personality sliders ---- */
.traits { display: flex; flex-direction: column; gap: 12px; }
.traits-title, .memory-title {
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 600;
}
.trait { display: flex; flex-direction: column; gap: 5px; }
.trait-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink); }
.trait-head b { color: var(--pink-deep); font-weight: 700; }
.trait input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 6px; border-radius: 99px;
  background: #ffe0ec; outline: none; cursor: pointer;
}
.trait input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  box-shadow: 0 2px 6px rgba(255,79,154,.5); border: 2px solid #fff;
}
.trait input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff;
  background: var(--pink-deep);
}

/* ---- Memory list ---- */
.memory { display: flex; flex-direction: column; gap: 8px; }
.memory-title { display: flex; justify-content: space-between; align-items: center; }
.memory-count {
  background: var(--pink-soft); color: var(--pink-deep); font-size: 11px;
  padding: 1px 8px; border-radius: 99px; font-weight: 700;
}
.memory-list { list-style: none; display: flex; flex-direction: column; gap: 6px; max-height: 160px; overflow-y: auto; }
.memory-list li {
  font-size: 12.5px; color: var(--ink); background: var(--pink-mist);
  border: 1px solid #ffe0ec; border-radius: 11px; padding: 7px 10px; line-height: 1.35;
  animation: rise .3s ease;
}
.memory-empty { color: var(--ink-soft) !important; font-style: italic; }

.btn-row { display: flex; flex-direction: column; gap: 8px; }
.ghost-btn.danger { color: #c0497a; border-color: #ffc9dd; }
.ghost-btn.danger:hover { background: #fff0f5; }

/* learned toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #fff; color: var(--ink); border: 1px solid var(--pink-soft);
  box-shadow: var(--shadow); border-radius: 16px; padding: 12px 18px; font-size: 13.5px;
  opacity: 0; transition: opacity .3s, transform .3s; z-index: 50; max-width: 320px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast b { color: var(--pink-deep); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.field input, .field select {
  font-family: inherit; font-size: 15px; color: var(--ink);
  padding: 11px 13px; border-radius: 13px;
  border: 1.5px solid #ffe0ec; background: var(--pink-mist);
  outline: none; transition: border-color .2s;
}
.field input:focus, .field select:focus { border-color: var(--pink); background: #fff; }

.ghost-btn {
  font-family: inherit; font-size: 14px; font-weight: 600;
  color: var(--pink-deep); cursor: pointer;
  background: #fff; border: 1.5px solid var(--pink-soft);
  padding: 11px; border-radius: 13px; transition: .2s;
}
.ghost-btn:hover { background: var(--pink-mist); }

.status {
  margin-top: auto; font-size: 12px; text-align: center; color: var(--ink-soft);
  background: var(--pink-mist); padding: 9px; border-radius: 11px;
}
.status.bad { color: #c0392b; background: #fff0ee; }
.status.good { color: #1e9e6a; background: #effaf3; }

/* ---------- Chat ---------- */
.chat {
  background: var(--white);
  border-radius: 26px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  border: 1px solid #ffe6f0;
}

.chat-head {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid #ffe9f2;
  background: linear-gradient(180deg, #fff, var(--pink-mist));
}
.chat-head-avatar {
  width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center; font-size: 26px;
  background: linear-gradient(145deg, var(--pink-soft), #fff);
  border: 2px solid var(--accent); transition: border-color .5s;
}
.chat-head-info { flex: 1; min-width: 0; }
.chat-head-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.lang-badge {
  font-size: 12px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  padding: 4px 10px; border-radius: 99px; letter-spacing: .03em;
  box-shadow: 0 4px 10px rgba(255,79,154,.35); transition: background .4s;
}
.lang-badge.si { background: linear-gradient(135deg, #4f9aff, #2f6fff); box-shadow: 0 4px 10px rgba(47,111,255,.35); }
.install-btn {
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--pink-deep); background: #fff; border: 1.5px solid var(--pink-soft);
  padding: 6px 12px; border-radius: 99px; white-space: nowrap;
}
.install-btn:hover { background: var(--pink-mist); }
.menu-btn {
  display: none; font-size: 22px; line-height: 1; cursor: pointer;
  background: none; border: none; color: var(--pink-deep); padding: 4px 8px 4px 0;
}
.backdrop {
  display: none; position: fixed; inset: 0; background: rgba(120,40,80,.28);
  z-index: 40; opacity: 0; transition: opacity .25s;
}
.backdrop.show { display: block; opacity: 1; }

.chat-head-name { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.chat-head-status { font-size: 13px; color: var(--ink-soft); }
.chat-head-activity {
  font-size: 12px; color: var(--accent); font-weight: 600;
  margin-top: 1px; transition: color .4s;
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.online { background: #36d399; box-shadow: 0 0 0 3px rgba(54,211,153,.2); }

.messages {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: clamp(14px, 2.5vw, 24px);
  display: flex; flex-direction: column; gap: clamp(10px, 1.4vw, 14px);
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: var(--pink-soft); border-radius: 99px; }

.row { display: flex; gap: 10px; max-width: min(78%, 560px); align-items: flex-end; }
.row.me { align-self: flex-end; flex-direction: row-reverse; }
.row .av {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
  display: grid; place-items: center; font-size: 18px;
  background: linear-gradient(145deg, var(--pink-soft), #fff);
  border: 1.5px solid var(--accent);
}
.row.me .av { background: linear-gradient(145deg, #e7ecff, #fff); border-color: #b9c6ff; }

.bubble {
  padding: 11px 15px; border-radius: 20px; font-size: clamp(14px, 1.05vw + 12px, 15.5px); line-height: 1.5;
  background: var(--pink-mist); color: var(--ink);
  border: 1px solid #ffe0ec;
  border-bottom-left-radius: 6px;
  white-space: pre-wrap; word-wrap: break-word;
  animation: rise .25s ease;
  transition: background .4s, border-color .4s, box-shadow .4s;
}
/* Her bubble takes the colour of the mood she was in (--bm) */
.row.her .bubble {
  background: color-mix(in srgb, var(--bm, var(--pink)) 14%, #fff);
  border-color: color-mix(in srgb, var(--bm, var(--pink)) 35%, #fff);
  border-left: 3px solid var(--bm, var(--pink));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--bm, var(--pink)) 18%, transparent);
}
.row.her .av { border-color: var(--bm, var(--accent)); }
.mood-chip {
  display: inline-block; font-size: 11px; font-weight: 600;
  margin-top: 5px; padding: 2px 9px; border-radius: 99px;
  color: var(--bm, var(--pink));
  background: color-mix(in srgb, var(--bm, var(--pink)) 12%, #fff);
}
.bubble-wrap { display: flex; flex-direction: column; }
.row.me .bubble {
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  color: #fff; border: none;
  border-bottom-left-radius: 20px; border-bottom-right-radius: 6px;
}
@keyframes rise { from{opacity:0; transform:translateY(8px)} to{opacity:1; transform:none} }

/* typing indicator */
.typing { display: flex; align-items: center; gap: 10px; padding: 0 24px 8px; }
.typing[hidden] { display: none; }
.typing-avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-size: 18px; background: linear-gradient(145deg, var(--pink-soft), #fff);
  border: 1.5px solid var(--accent);
}
.typing-bubble { display: inline-flex; gap: 5px; padding: 14px 16px; }
.typing-bubble i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--pink);
  animation: blink 1.2s infinite;
}
.typing-bubble i:nth-child(2) { animation-delay: .2s; }
.typing-bubble i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,60%,100%{opacity:.3; transform:translateY(0)} 30%{opacity:1; transform:translateY(-4px)} }

/* composer */
.composer {
  display: flex; gap: 12px; padding: 16px 20px;
  border-top: 1px solid #ffe9f2; background: #fff;
}
.composer input {
  flex: 1; font-family: inherit; font-size: 15px; color: var(--ink);
  padding: 14px 18px; border-radius: 99px;
  border: 1.5px solid #ffe0ec; background: var(--pink-mist); outline: none;
  transition: border-color .2s;
}
.composer input:focus { border-color: var(--pink); background: #fff; }
.composer button {
  width: 52px; height: 52px; flex: 0 0 52px; border: none; cursor: pointer;
  border-radius: 50%; font-size: 20px; color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  box-shadow: 0 8px 20px rgba(255,79,154,.4);
  transition: transform .15s, opacity .2s;
}
.composer button:hover { transform: scale(1.06); }
.composer button:disabled { opacity: .5; cursor: default; transform: none; }

.welcome { text-align: center; color: var(--ink-soft); margin: auto; padding: 30px; }
.welcome .big { font-size: 46px; }
.welcome h2 { font-family: "Dancing Script", cursive; color: var(--pink-deep); font-size: 32px; margin: 6px 0; }

/* ============================================================
   RESPONSIVE — works across phones, foldables, tablets, laptops,
   desktops, and landscape. Mobile-first app feel under 900px.
   ============================================================ */

/* ---- Roomier two-column on big screens ---- */
@media (min-width: 1500px) {
  .app { max-width: 1440px; grid-template-columns: 320px 1fr; }
  .row { max-width: min(72%, 680px); }
}

/* ---- Tablet portrait & below: full-screen app layout ---- */
@media (max-width: 900px) {
  html, body { height: 100%; overflow: hidden; }
  .app {
    grid-template-columns: 1fr;
    padding: 0; gap: 0;
    height: 100dvh;
  }
  .menu-btn { display: block; }

  /* chat fills the screen like a messaging app */
  .chat {
    order: 1; height: 100dvh; border-radius: 0; border: none;
  }
  .chat-head { padding-top: max(16px, env(safe-area-inset-top)); }
  .composer {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .row { max-width: min(88%, 620px); }

  /* iOS: 16px inputs stop auto-zoom on focus */
  .composer input, .field input, .field select { font-size: 16px; }

  /* sidebar becomes a slide-in panel, centered on tablets */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: min(86vw, 360px); max-width: none; border-radius: 0 24px 24px 0;
    transform: translateX(-105%); transition: transform .28s ease;
    padding-top: max(26px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    max-height: none; overflow-y: auto;
  }
  body.show-panel .sidebar { transform: translateX(0); }
}

/* ---- Large phones / small tablets: a touch more breathing room ---- */
@media (min-width: 600px) and (max-width: 900px) {
  .chat-head { padding-left: 28px; padding-right: 28px; }
  .messages { padding-left: clamp(24px, 6vw, 60px); padding-right: clamp(24px, 6vw, 60px); }
  .composer { padding-left: clamp(20px, 6vw, 56px); padding-right: clamp(20px, 6vw, 56px); }
}

/* ---- Small phones (≤380px): tighten everything ---- */
@media (max-width: 380px) {
  .chat-head { gap: 9px; padding: 12px 14px; }
  .chat-head-avatar { width: 42px; height: 42px; font-size: 22px; }
  .chat-head-name { font-size: 16px; }
  .chat-head-status, .chat-head-activity { font-size: 11.5px; }
  .install-btn { display: none; } /* keep header from crowding; install still works from browser menu */
  .messages { padding: 12px; }
  .row { max-width: 90%; gap: 7px; }
  .row .av { width: 30px; height: 30px; flex-basis: 30px; font-size: 16px; }
  .composer { padding: 12px 12px; gap: 9px; }
  .composer button { width: 46px; height: 46px; flex-basis: 46px; font-size: 18px; }
}

/* ---- Landscape phones (short height): compact vertical chrome ---- */
@media (max-height: 500px) and (orientation: landscape) {
  .chat-head { padding-top: 8px; padding-bottom: 8px; }
  .chat-head-avatar { width: 40px; height: 40px; font-size: 20px; }
  .chat-head-activity { display: none; }
  .composer { padding-top: 10px; padding-bottom: 10px; }
  .messages { padding-top: 10px; padding-bottom: 10px; }
  .sidebar { padding-top: 14px; gap: 14px; }
}

/* ---- Touch devices: bigger comfortable tap targets ---- */
@media (hover: none) and (pointer: coarse) {
  .ghost-btn, .field select, .install-btn { min-height: 44px; }
  .menu-btn { padding: 6px 10px 6px 0; }
  .trait input[type="range"] { height: 10px; }
  .trait input[type="range"]::-webkit-slider-thumb { width: 22px; height: 22px; }
}

/* ---- Respect reduced-motion preference ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* installed (standalone) app tweaks */
@media (display-mode: standalone) {
  .install-btn { display: none !important; }
}
