/* ===== Variables ===== */
:root {
  --bg: #0f1117;
  --bg-surface: #1a1d27;
  --bg-elevated: #232733;
  --bg-hover: #2a2e3b;
  --border: #2e3345;
  --border-light: #3a3f52;

  --text: #e4e6ed;
  --text-secondary: #9499ad;
  --text-muted: #6b7085;

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.12);

  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.12);
  --yellow: #eab308;
  --yellow-soft: rgba(234, 179, 8, 0.12);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.12);
  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, 0.12);
  --orange: #f97316;
  --orange-soft: rgba(249, 115, 22, 0.12);
  --purple: #a855f7;
  --purple-soft: rgba(168, 85, 247, 0.12);

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.2s ease;
}

/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ===== Auth Screen ===== */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
}

.auth-container {
  text-align: center;
  width: 100%;
  max-width: 400px;
  padding: 0 20px;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

/* Hanko web component theming */
hanko-auth {
  --color: var(--text);
  --color-shade-1: var(--text-secondary);
  --color-shade-2: var(--text-muted);
  --brand-color: var(--accent);
  --brand-color-shade-1: var(--accent-hover);
  --brand-contrast-color: white;
  --background-color: var(--bg-surface);
  --input-bg-color: var(--bg-elevated);
  --border-color: var(--border);
  --item-height: 40px;
  --border-radius: 8px;
  --font-family: 'Inter', sans-serif;
  --font-size: 14px;
}

/* ===== App Layout ===== */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile browsers */
  padding-top: env(safe-area-inset-top);
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text);
}

.logo-accent {
  color: var(--accent);
  font-weight: 600;
}

.header-center {
  display: flex;
  align-items: center;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.logout-btn:hover {
  color: var(--red);
  background: var(--red-soft);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.status-dot.error {
  background: var(--red);
}

.status-dot.loading {
  background: var(--yellow);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== Main Layout ===== */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===== Loading Indicator ===== */
.loading-indicator {
  position: fixed;
  bottom: 100px;
  left: 20%;
  transform: translateX(-50%);
  z-index: 100;
}

.loading-dots {
  display: flex;
  gap: 6px;
  padding: 10px 18px;
  background: var(--bg-elevated);
  border-radius: 20px;
  border: 1px solid var(--border);
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(2) { animation-delay: 0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
  .header {
    padding: 0 16px;
    height: 44px;
  }

  .main {
    flex-direction: column;
    min-height: 0;
  }

  /* Mobile: visuals top ~2/3, chat bottom ~1/3
     flex-basis: 0% forces sizing purely from flex-grow (critical for iOS scroll) */
  .visual-panel {
    flex: 2 1 0%;
    order: 1;
    min-height: 0;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid var(--border);
    border-right: none !important;
  }

  .chat-panel {
    flex: 1 1 0%;
    order: 2;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 0;
    overflow: hidden;
    border-right: none !important;
  }

  .loading-indicator {
    left: 50%;
    bottom: calc(33vh + 10px);
  }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}
