/* ═══════════════════════════════════════════════════════════════
   CLARYLIFE GLOBAL — BRAND OS  ·  Dark Theme Interface Styles
   Version: 2.0  |  March 2026
   Primary: #5400A8  |  Accent: #A80054
   Fonts: Poppins (display) · Arimo (body)
   To customise: edit the CSS variables in :root below.
═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Arimo:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Poppins:wght@500;600;700;800&display=swap');

:root {
  /* Brand colours */
  --brand-primary:    #5400A8;
  --brand-primary-dk: #3D0080;
  --brand-primary-md: #6B12C8;
  --brand-primary-lt: #EDE0FF;
  --brand-accent:     #A80054;
  --brand-accent-lt:  #FFE0EF;

  /* Dark surface palette */
  --brand-dark:      #1C1128;
  --brand-mid:       #261640;
  --brand-surface:   #2E1D52;
  --brand-border:    rgba(255,255,255,0.08);

  /* Text */
  --text-primary:   #F2EEF9;
  --text-secondary: #B0A2CC;
  --text-muted:     #7A6E9A;

  /* Chat bubble colours */
  --bubble-user-grad:  linear-gradient(135deg, #5400A8, #6B12C8);
  --bubble-ai:         #241640;
  --bubble-ai-border:  rgba(84,58,168,0.25);

  /* UI */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  22px;
  --sidebar-w:  268px;

  /* Typography */
  --font-display: 'Poppins', sans-serif;
  --font-body:    'Arimo', sans-serif;
}

/* ── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-body);
  background: var(--brand-dark);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-primary-md); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── SCREENS ────────────────────────────────────────────────── */
.screen {
  display: none;
  width: 100%;
  height: 100%;
}
.screen.active { display: flex; }

/* ── LOGIN SCREEN ───────────────────────────────────────────── */
#login-screen {
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 55% 45% at 50% -5%, rgba(168,0,84,0.14) 0%, transparent 65%),
    radial-gradient(ellipse 70% 55% at 50% 110%, rgba(84,0,168,0.22) 0%, transparent 70%),
    var(--brand-dark);
  padding: 24px;
}

.login-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-accent) 100%);
  box-shadow: 0 4px 16px rgba(84,0,168,0.4);
}

.brand-icon.small {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.login-card {
  width: 100%;
  background: var(--brand-mid);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
}

.login-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: -10px;
  line-height: 1.6;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.input-wrap {
  position: relative;
}

.input-wrap input,
textarea {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 12px 44px 12px 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrap input:focus,
textarea:focus {
  border-color: rgba(84,0,168,0.6);
  box-shadow: 0 0 0 3px rgba(84,0,168,0.15);
}

.toggle-vis {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}
.toggle-vis:hover { color: var(--text-secondary); }

.error-msg {
  font-size: 12px;
  color: #F87171;
  min-height: 18px;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 20px;
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-md) 100%);
  color: white;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(84,0,168,0.4);
  letter-spacing: 0.02em;
}
.btn-primary:hover  { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(84,0,168,0.5); }
.btn-primary:active { transform: translateY(0); }

.login-footer {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ── CHAT SCREEN ─────────────────────────────────────────────── */
#chat-screen {
  flex-direction: row;
  height: 100%;
  overflow: hidden;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--brand-mid);
  border-right: 1px solid var(--brand-border);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  gap: 18px;
  transition: transform 0.25s ease;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}

.sidebar-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
}

.session-info {
  background: rgba(84,0,168,0.1);
  border: 1px solid rgba(84,0,168,0.2);
  border-radius: var(--radius-md);
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.role-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.role-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3CE0A4;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(60,224,164,0.6);
}

#role-label {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.session-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: auto;
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: none;
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-align: left;
}
.sidebar-btn:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.12);
}
.sidebar-btn.danger:hover {
  background: rgba(168,0,84,0.1);
  color: #F4699F;
  border-color: rgba(168,0,84,0.25);
}

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--brand-border);
}

.site-link {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── CHAT MAIN ───────────────────────────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--brand-dark);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--brand-border);
  background: var(--brand-mid);
  flex-shrink: 0;
}

.menu-btn {
  background: none;
  border: 1px solid var(--brand-border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 7px;
  display: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.menu-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

#chat-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3CE0A4;
  animation: pulse 2s infinite;
  box-shadow: 0 0 5px rgba(60,224,164,0.5);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Provider toggle */
.provider-toggle { flex-shrink: 0; }

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.12);
  border-radius: 20px;
  transition: background 0.2s;
  cursor: pointer;
}

.slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .slider { background: var(--brand-primary); }
.toggle-switch input:checked + .slider::before { transform: translateX(16px); }

/* ── MESSAGES ────────────────────────────────────────────────── */
.messages-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  scroll-behavior: smooth;
}
.messages-wrap::-webkit-scrollbar { width: 4px; }
.messages-wrap::-webkit-scrollbar-track { background: transparent; }
.messages-wrap::-webkit-scrollbar-thumb { background: var(--brand-border); border-radius: 4px; }

.messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 760px;
  margin: 0 auto;
}

.message {
  display: flex;
  animation: fadeUp 0.2s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message.user      { justify-content: flex-end; }
.message.assistant { justify-content: flex-start; }

.bubble {
  max-width: 72%;
  padding: 12px 17px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.65;
}

.message.user .bubble {
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-md) 100%);
  color: white;
  border-bottom-right-radius: var(--radius-sm);
  box-shadow: 0 2px 12px rgba(84,0,168,0.3);
}

.message.assistant .bubble {
  background: var(--bubble-ai);
  color: var(--text-primary);
  border: 1px solid var(--bubble-ai-border);
  border-bottom-left-radius: var(--radius-sm);
}

.bubble p { margin-bottom: 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { font-weight: 600; color: #E0CCFF; }
.bubble code {
  font-size: 12px;
  background: rgba(255,255,255,0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

/* Thinking animation */
.message.thinking .bubble {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 16px 20px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite;
}

.dot:nth-child(2) { animation-delay: 0.15s; }
.dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-6px); opacity: 1; }
}

/* ── INPUT AREA ──────────────────────────────────────────────── */
.input-area {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--brand-border);
  background: var(--brand-mid);
  flex-shrink: 0;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 760px;
  margin: 0 auto;
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-lg);
  padding: 10px 10px 10px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-row:focus-within {
  border-color: rgba(84,0,168,0.5);
  box-shadow: 0 0 0 3px rgba(84,0,168,0.12);
}

.input-row textarea {
  flex: 1;
  background: none;
  border: none;
  border-radius: 0;
  padding: 4px 6px;
  resize: none;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.55;
  max-height: 160px;
  outline: none;
}

.input-row textarea::placeholder { color: var(--text-muted); }
.input-row textarea:disabled { opacity: 0.5; }

.send-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-md) 100%);
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(84,0,168,0.35);
}

.send-btn:hover:not(:disabled)  { opacity: 0.88; transform: scale(1.05); box-shadow: 0 4px 14px rgba(84,0,168,0.5); }
.send-btn:active:not(:disabled) { transform: scale(0.97); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none; }

.input-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 9px;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 28px rgba(0,0,0,0.5);
  }

  .menu-btn { display: flex; }

  .bubble { max-width: 88%; }

  .provider-toggle { display: none; }

  .login-card { padding: 28px 20px; }

  .chat-header { padding: 12px 14px; }
  .messages-wrap { padding: 16px 14px; }
  .input-area { padding: 10px 12px 14px; }
}