/* aas-chat-app — Apple-like polished UI
   - system fonts, soft glass, subtle shadows, generous spacing
   - responsive, respects reduced-motion
*/

/* -------- variables -------- */
:root{
  --bg-screen: #f6f8fb;            /* page background */
  --card: rgba(255,255,255,0.85);  /* frosted card */
  --glass-tint: rgba(255,255,255,0.6);
  --accent: #0a84ff;               /* Apple blue */
  --muted: #6b7280;
  --ink: #0f172a;
  --soft-shadow: 0 6px 18px rgba(15,23,42,0.06);
  --soft-shadow-2: 0 2px 8px rgba(15,23,42,0.04);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --glass-blur: 10px;
  --glass-border: rgba(255,255,255,0.6);
  --chip-border: rgba(13, 26, 55, 0.06);
  --chip-bg: rgba(248,252,255,0.9);
  --ui-gap: 10px;
  --max-chat-width: 900px;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce){
  * { transition: none !important; animation: none !important; }
}

/* Base */
body {
  background: linear-gradient(180deg, #f8fafc 0%, var(--bg-screen) 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.aas-chat-card {
  max-width: var(--max-chat-width);
  margin: 18px auto;
  padding: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.7), rgba(255,255,255,0.6));
  border-radius: calc(var(--radius-lg));
  box-shadow: var(--soft-shadow);
  border: 1px solid rgba(14,30,60,0.04);
}

/* root container */
#aas-chat-app {
  font-family: -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI",
               Roboto, "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  color: var(--ink);
  width: 100%;
  box-sizing: border-box;
}

/* status line */
#aas-chat-app .status {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 8px 12px;
  letter-spacing: -0.01em;
}

/* chat area (glass) */
#aas-chat-app .chat {
  background: linear-gradient(180deg, rgba(255,255,255,0.75), rgba(247,250,255,0.6));
  border-radius: calc(var(--radius-md));
  padding: 14px;
  border: 1px solid rgba(15,23,42,0.03);
  box-shadow: var(--soft-shadow-2);
  overflow: auto;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  min-height: 180px;
}

/* rows and bubbles */
#aas-chat-app .row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin: 12px 4px;
}

/* avatar (AI) */
#aas-chat-app .row.ai .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, #f3f6fb);
  border: 1px solid rgba(15,23,42,0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 2px 6px rgba(15,23,42,0.06);
}

/* bubble base */
#aas-chat-app .bubble {
  max-width: 74%;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.5;
  word-break: break-word;
  box-shadow: 0 4px 12px rgba(12,18,30,0.05);
  transition: transform .12s ease, box-shadow .12s ease;
}

/* AI bubble (white card) */
#aas-chat-app .bubble.ai {
  background: var(--card);
  color: var(--ink);
  border: 1px solid rgba(10,20,40,0.04);
  border-top-left-radius: 8px;
  align-self: flex-start;
}

/* user bubble (accent) */
#aas-chat-app .bubble.me {
  margin-left: auto;
  background: linear-gradient(180deg, var(--accent), #0070e0);
  color: #fff;
  border-radius: 16px;
  border-top-right-radius: 8px;
  box-shadow: 0 6px 18px rgba(10,132,255,0.18);
  align-self: flex-end;
}

/* bubble hover/active subtle */
#aas-chat-app .bubble:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(12,18,30,0.06); }

/* input area */
#aas-chat-app .input {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  align-items: center;
  padding: 8px;
}

/* text input */
#aas-chat-app .input input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,0.06);
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(250,252,255,0.9));
  box-shadow: 0 2px 10px rgba(12,18,30,0.03) inset;
  outline: none;
  font-size: 14px;
  color: var(--ink);
  transition: box-shadow .12s ease, transform .12s ease;
}

/* focus */
#aas-chat-app .input input:focus {
  box-shadow: 0 6px 18px rgba(10,132,255,0.12);
  border-color: rgba(10,132,255,0.28);
  transform: translateY(-1px);
}

/* send button */
#aas-chat-app .input button {
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), #0066d6);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(10,132,255,0.12);
  transition: transform .08s ease, box-shadow .12s ease;
}
#aas-chat-app .input button:active{ transform: translateY(1px); box-shadow: 0 6px 18px rgba(10,132,255,0.10); }

/* quick replies / chips */
#aas-chat-app .quick-wrap {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

#aas-chat-app .chip {
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--ink);
  cursor: pointer;
  min-width: 180px;
  box-shadow: 0 4px 12px rgba(12,18,30,0.04);
  transition: transform .09s ease, box-shadow .12s ease, background .12s ease;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
}
#aas-chat-app .chip:hover { transform: translateY(-4px); box-shadow: 0 10px 28px rgba(12,18,30,0.06); background:#f3f8ff; }
#aas-chat-app .chip:disabled { opacity: .6; cursor: not-allowed; transform:none; box-shadow:none; }

/* chip content */
#aas-chat-app .chip-title { font-weight: 700; margin-bottom: 4px; font-size: 14px; }
#aas-chat-app .chip-sub { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
#aas-chat-app .chip-meta { font-size: 12px; color: var(--muted); }

/* toolbar (appMode toggle + analyze button) */
#aas-chat-app .toolbar {
  display:flex;
  align-items:center;
  gap:10px;
  padding: 6px 8px;
  margin-bottom: 6px;
}
#aas-chat-app .toolbar label { font-size: 13px; color: var(--muted); display:inline-flex; align-items:center; gap:8px; }
#aas-chat-app .toolbar button { padding:8px 12px; border-radius:10px; border:1px solid rgba(15,23,42,0.04); background: linear-gradient(180deg,#fff,#fbfdff); cursor:pointer; }

/* fixed-header behavior removed — keep simple highlight (avoid sticky) */
#aas-chat-app .chat .ai.fixed-header {
  position: static;
  top: auto;
  z-index: auto;
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(15,23,42,0.04);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 6px 0;
  font-weight: 700;
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(12,18,30,0.04);
}

/* responsive tweaks */
@media (max-width: 640px){
  #aas-chat-app .bubble { max-width: 86%; padding: 10px 12px; }
  #aas-chat-app .chip { min-width: calc(50% - 8px); }
  #aas-chat-app .row { margin: 10px 2px; gap: 8px; }
  #aas-chat-app .chat { padding: 10px; }
  #aas-chat-app .input { padding: 6px; }
  #aas-chat-app .toolbar { padding: 4px; gap:8px; font-size:13px; }
}

/* accessibility: focus ring for keyboard users */
#aas-chat-app button:focus, #aas-chat-app .chip:focus, #aas-chat-app .input input:focus {
  outline: 3px solid rgba(10,132,255,0.14);
  outline-offset: 2px;
}

/* small helper to keep everything crisp on retina */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  #aas-chat-app .bubble { will-change: transform; }
}
