/* ===================================================================
   Sudo Vision — Stylesheet
   Pure CSS, no frameworks. iOS-inspired, dark-only, premium minimal.
=================================================================== */

:root {
  --bg: #000000;
  --surface: #0d0d0f;
  --bubble-assistant: #1c1c1e;
  --bubble-user: #2c2c2e;
  --text: #f5f5f7;
  --text-dim: #8e8e93;
  --accent: #3aa0ff;
  --accent-2: #7dd3ff;
  --divider: rgba(255,255,255,0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --sf: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sf);
  overscroll-behavior: none;
}

body {
  margin: 0;
  overflow: hidden;
  position: fixed;
  inset: 0;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

textarea { font-family: inherit; }

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

/* ---------------- App shell ---------------- */

.app {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  transition: transform 0.35s cubic-bezier(.32,.72,0,1), filter 0.35s ease;
}

body.sidebar-open .app {
  transform: translateX(78%);
  filter: brightness(0.55) saturate(0.8);
}

@media (min-width: 700px) {
  body.sidebar-open .app { transform: translateX(320px); }
}

.topbar {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 6px;
  flex-shrink: 0;
}

.topbar-title {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.2px;
}

.topbar-spacer { width: 36px; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text);
  transition: background 0.15s ease, transform 0.15s ease;
}

.icon-btn:active {
  background: rgba(255,255,255,0.08);
  transform: scale(0.9);
}

/* ---------------- Orb screen ---------------- */

.orb-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  transition: opacity 0.35s ease, transform 0.4s cubic-bezier(.32,.72,0,1);
}

.orb-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.orb-glow {
  position: absolute;
  inset: -30px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(58,160,255,0.45) 0%, rgba(58,160,255,0.12) 45%, transparent 72%);
  filter: blur(6px);
  animation: breathe 4.2s ease-in-out infinite;
}

.orb-glow--small { inset: -14px; }

.orb {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #eaf7ff 0%, #bfe8ff 16%, #6ec3ff 38%, #2f8fe8 62%, #0b57b8 88%);
  box-shadow:
    inset -14px -18px 40px rgba(0,30,80,0.55),
    inset 10px 10px 30px rgba(255,255,255,0.35),
    0 0 60px rgba(58,160,255,0.35);
  animation: breathe 4.2s ease-in-out infinite;
  transition: transform 0.15s ease;
  overflow: hidden;
}

.orb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(200deg, rgba(255,255,255,0.35), transparent 40%, rgba(0,0,0,0.25));
  mix-blend-mode: overlay;
  animation: swirl 9s linear infinite;
}

.orb--small { width: 84px; height: 84px; }

.orb-wrap:active .orb { transform: scale(0.96); }

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

@keyframes swirl {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.orb.thinking { animation: breathe 1.1s ease-in-out infinite; }
.orb-glow.thinking { animation: breathe 1.1s ease-in-out infinite; }

.orb-hint {
  margin: 0;
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.2px;
}

/* ---------------- Chat screen ---------------- */

.chat-screen {
  position: absolute;
  inset: 0;
  top: 52px;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.45s cubic-bezier(.32,.72,0,1), opacity 0.35s ease;
}

body.chat-open .orb-screen {
  opacity: 0;
  transform: translateY(-10px) scale(0.98);
  pointer-events: none;
}

body.chat-open .chat-screen {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 20px;
  font-size: 15.5px;
  line-height: 1.38;
  animation: msgIn 0.28s cubic-bezier(.32,.72,0,1);
  word-wrap: break-word;
  white-space: pre-wrap;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.msg--assistant {
  align-self: flex-start;
  background: var(--bubble-assistant);
  border-bottom-left-radius: 6px;
  color: var(--text);
}

.msg--user {
  align-self: flex-end;
  background: var(--bubble-user);
  border-bottom-right-radius: 6px;
  color: var(--text);
}

.msg--thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: dotPulse 1.1s ease-in-out infinite;
}
.dot:nth-child(2) { animation-delay: 0.15s; }
.dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotPulse {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.cursor-blink {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent-2);
  margin-left: 1px;
  vertical-align: -2px;
  animation: blink 0.9s step-start infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------------- Input bar ---------------- */

.input-bar-wrap {
  flex-shrink: 0;
  padding: 8px 10px calc(10px + var(--safe-bottom));
  background: linear-gradient(to top, #000 55%, transparent);
}

.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 24px;
  padding: 6px 6px 6px 10px;
}

.input-field {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
  line-height: 1.3;
  max-height: 120px;
  padding: 8px 4px;
  resize: none;
}

.input-field::placeholder { color: var(--text-dim); }

.input-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: background 0.15s ease, transform 0.12s ease, color 0.15s ease;
}

.input-btn:active { transform: scale(0.88); background: rgba(255,255,255,0.08); }

.input-btn--send {
  background: var(--accent);
  color: #fff;
}
.input-btn--send:active { background: var(--accent); transform: scale(0.88); }

.input-btn.recording {
  color: #fff;
  background: #ff3b30;
  animation: recPulse 1s ease-in-out infinite;
}

@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,59,48,0.5); }
  50% { box-shadow: 0 0 0 8px rgba(255,59,48,0); }
}

/* ---------------- Sidebar ---------------- */

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.001);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

body.sidebar-open .sidebar-overlay {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 78%;
  max-width: 320px;
  background: #0a0a0c;
  border-right: 1px solid var(--divider);
  z-index: 31;
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(.32,.72,0,1);
  padding: calc(14px + var(--safe-top)) 14px calc(14px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
}

body.sidebar-open .sidebar { transform: translateX(0); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 0 2px;
}

.sidebar-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 12px;
  border-radius: 14px;
  font-size: 15px;
  color: var(--text);
  text-align: left;
  transition: background 0.15s ease;
}

.sidebar-item:active { background: rgba(255,255,255,0.08); }

.sidebar-item--primary {
  background: rgba(58,160,255,0.14);
  color: var(--accent-2);
  font-weight: 600;
  margin-bottom: 18px;
}

.sidebar-section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  padding: 6px 12px 8px;
}

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

.sidebar-empty {
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--text-dim);
}

.sidebar-history-item {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s ease;
}
.sidebar-history-item:active { background: rgba(255,255,255,0.08); }

.sidebar-footer {
  border-top: 1px solid var(--divider);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ---------------- Panels (Settings / About) ---------------- */

.panel {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 40;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.38s cubic-bezier(.32,.72,0,1), opacity 0.3s ease;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  padding-bottom: var(--safe-bottom);
}

.panel.open {
  transform: translateX(0);
  opacity: 1;
}

.panel-header {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 6px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--divider);
}

.panel-title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
}

.panel-body--center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 20px 32px;
}

.settings-group {
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid var(--divider);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 15px;
  border-bottom: 1px solid var(--divider);
  width: 100%;
  text-align: left;
  color: var(--text);
}

.settings-row:last-child { border-bottom: none; }
.settings-row--action { color: #ff453a; }
.settings-row--action:active { background: rgba(255,69,58,0.1); }

.settings-value { color: var(--text-dim); }

.switch { position: relative; display: inline-block; width: 46px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0;
  background: #39393d;
  border-radius: 999px;
  transition: background 0.2s ease;
}
.switch-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 24px; height: 24px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s cubic-bezier(.32,.72,0,1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); }

.about-orb { position: relative; margin-bottom: 18px; display:flex; align-items:center; justify-content:center; width: 84px; height: 84px;}
.about-name { font-size: 24px; font-weight: 700; margin: 0 0 8px; letter-spacing: 0.2px; }
.about-desc { font-size: 15px; color: var(--text-dim); line-height: 1.5; max-width: 280px; margin: 0 0 40px; }
.about-footer { font-size: 12px; color: var(--text-dim); line-height: 1.6; }
.about-footer p { margin: 0; }

/* ---------------- Ripple ---------------- */

.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transform: scale(0);
  animation: rippleAnim 0.6s ease-out;
  pointer-events: none;
}

@keyframes rippleAnim {
  to { transform: scale(3); opacity: 0; }
}

/* ---------------- Scrollbars ---------------- */

.messages::-webkit-scrollbar, .sidebar-history::-webkit-scrollbar, .panel-body::-webkit-scrollbar { width: 0; }

/* ---------------- Responsive ---------------- */

@media (min-width: 700px) {
  .msg { max-width: 60%; }
  .orb-wrap { width: 260px; height: 260px; }
  .orb { width: 240px; height: 240px; }
}

@media (max-width: 360px) {
  .orb-wrap { width: 180px; height: 180px; }
  .orb { width: 164px; height: 164px; }
}
