/* ===========================================================
   SEDUH AI — design tokens
   Palet: kopi gelap, emas antik, krem/putih hangat
   Tipografi: Fraunces (display) + Inter (body/UI)
=========================================================== */

:root {
  --coffee-darkest: #1a0f08;
  --coffee-dark: #2c1810;
  --coffee: #4a2e1f;
  --coffee-light: #6b4a33;
  --gold: #c9a227;
  --gold-light: #e8c766;
  --gold-soft: #f0dfa8;
  --cream: #faf6ef;
  --paper: #fffdf8;
  --ink: #241509;
  --muted: #8a7864;
  --line: rgba(201, 162, 39, 0.28);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-card: 0 24px 60px -20px rgba(26, 15, 8, 0.55);
  --shadow-soft: 0 8px 24px -10px rgba(26, 15, 8, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Inter", system-ui, sans-serif;
  color: var(--ink);
  background: var(--cream);
}

h1, h2, h3, .display {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

a { color: inherit; }

button { font-family: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- LOGIN PAGE ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(201,162,39,0.18), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(201,162,39,0.10), transparent 50%),
    linear-gradient(165deg, var(--coffee-darkest) 0%, var(--coffee-dark) 55%, var(--coffee) 100%);
  padding: 24px;
}

/* cincin noda kopi sebagai motif latar, samar */
.coffee-ring {
  position: absolute;
  border: 1.5px solid rgba(232, 199, 102, 0.16);
  border-radius: 50%;
  pointer-events: none;
}
.ring-1 { width: 520px; height: 520px; top: -180px; left: -160px; }
.ring-2 { width: 760px; height: 760px; bottom: -320px; right: -260px; border-color: rgba(232,199,102,0.10); }
.ring-3 { width: 280px; height: 280px; bottom: 12%; left: 8%; border-color: rgba(232,199,102,0.12); }

.login-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 400px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 44px 36px 36px;
  text-align: center;
  animation: rise 0.6s cubic-bezier(.2,.8,.2,1) both;
}

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

.brand-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-size: 28px;
  background: linear-gradient(120deg, var(--coffee) 0%, var(--gold) 55%, var(--gold-light) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-tagline {
  margin-top: 8px;
  margin-bottom: 30px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
}

.divider-gold {
  height: 1px;
  width: 64px;
  margin: 22px auto;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

#g_id_button_container {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

.login-footnote {
  margin-top: 22px;
  font-size: 12.5px;
  color: var(--muted);
}

.login-error {
  margin-top: 16px;
  font-size: 13px;
  color: #8a2c1d;
  background: #fbe9e4;
  border: 1px solid #eac3b8;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: none;
}

/* ---------- CHAT APP ---------- */

.app {
  display: grid;
  grid-template-columns: 264px 1fr;
  height: 100vh;
  background: var(--cream);
}

.sidebar {
  background: linear-gradient(180deg, var(--coffee-dark), var(--coffee-darkest));
  color: var(--gold-soft);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid rgba(232,199,102,0.18);
  margin-bottom: 16px;
}

.sidebar-brand .brand-mark { width: 30px; height: 30px; margin: 0; }
.sidebar-brand span { font-family: "Fraunces", serif; font-size: 18px; color: var(--gold-light); }

.btn-new-chat {
  width: 100%;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-new-chat:hover { background: var(--gold); color: var(--coffee-darkest); }

.history-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(240,223,168,0.55);
  margin: 22px 0 8px 6px;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item {
  text-align: left;
  background: transparent;
  border: none;
  color: rgba(250,246,239,0.78);
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item:hover, .history-item.active {
  background: rgba(201,162,39,0.16);
  color: var(--gold-light);
}

.sidebar-user {
  border-top: 1px solid rgba(232,199,102,0.18);
  padding-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user img {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--gold);
}

.sidebar-user .who { flex: 1; overflow: hidden; }
.sidebar-user .who .name { font-size: 13px; color: var(--cream); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who .email { font-size: 11.5px; color: rgba(240,223,168,0.55); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn-logout {
  background: transparent;
  border: 1px solid rgba(232,199,102,0.4);
  color: var(--gold-soft);
  border-radius: 50%;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.btn-logout:hover { background: rgba(201,162,39,0.18); }

/* main column */
.main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--paper);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.model-select-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.model-select-label {
  font-size: 12.5px;
  color: var(--muted);
}

#modelSelect {
  appearance: none;
  background: var(--cream);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 32px 8px 14px;
  border-radius: var(--radius-sm);
  background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }

/* chat area */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 28px 0 12px;
}

.chat-inner {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.empty-state {
  margin: 12% auto;
  text-align: center;
  max-width: 420px;
  color: var(--muted);
}
.empty-state .brand-mark { width: 48px; height: 48px; margin: 0 auto 14px; }
.empty-state h2 { font-size: 22px; color: var(--coffee-dark); margin-bottom: 8px; }
.empty-state p { font-size: 14px; line-height: 1.6; }

.msg-row { display: flex; gap: 12px; }
.msg-row.user { justify-content: flex-end; }

.bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.msg-row.user .bubble {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--coffee-darkest);
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.msg-row.assistant .bubble {
  background: var(--cream);
  border: 1px solid var(--line);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.msg-row.assistant .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--coffee-dark);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.bubble.thinking { color: var(--muted); font-style: italic; }
.bubble.error-bubble { background: #fbe9e4; border-color: #eac3b8; color: #8a2c1d; }

.composer {
  border-top: 1px solid var(--line);
  padding: 16px 24px 22px;
  background: var(--paper);
}

.composer-inner {
  max-width: 740px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 10px 10px 10px 18px;
}

#promptInput {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  max-height: 160px;
  padding: 8px 0;
}

.btn-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--coffee-dark);
  color: var(--gold-light);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.12s ease, background 0.15s ease;
}
.btn-send:hover { background: var(--gold); color: var(--coffee-darkest); }
.btn-send:active { transform: scale(0.94); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

.composer-hint {
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 8px;
}

/* responsive */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 30% 0 auto;
    z-index: 30;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    width: 70%;
  }
  .sidebar.open { transform: translateX(0); }
  .topbar .btn-menu { display: inline-flex; }
}

.btn-menu {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  color: var(--coffee-dark);
}
