/* SystemLike Antigravity Dev Portal - Premium Dark Mode Mobile CSS */
:root {
  --bg-main: #070a12;
  --bg-card: #0d1527;
  --bg-surface: #131e38;
  --bg-input: #0b1120;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(56, 189, 248, 0.25);
  
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --accent: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.35);
  --danger: #ef4444;
  --warning: #f59e0b;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --diff-add-bg: rgba(34, 197, 94, 0.15);
  --diff-add-text: #4ade80;
  --diff-del-bg: rgba(239, 68, 68, 0.15);
  --diff-del-text: #f87171;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  height: -webkit-fill-available;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(11, 17, 32, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo img {
  border-radius: 8px;
  display: block;
}

.app-title-group {
  display: flex;
  flex-direction: column;
}

.app-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-pro {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  text-transform: uppercase;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.status-dot.offline {
  background-color: var(--danger);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.account-badge:active {
  transform: scale(0.96);
  background: #1e2d52;
}

.acc-indicator {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  color: #070a12;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:active {
  background: var(--bg-surface);
  color: var(--text-main);
}

/* Protocol Action Bar */
.protocol-bar {
  background: rgba(7, 10, 18, 0.95);
  border-bottom: 1px solid var(--border-subtle);
  padding: 8px 12px;
  z-index: 15;
}

.chips-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips-scroll::-webkit-scrollbar {
  display: none;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chip-btn:active {
  background: var(--border-highlight);
  border-color: var(--primary);
  transform: scale(0.96);
}

.chip-icon {
  font-size: 0.85rem;
}

/* Chat Feed */
.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
}

.welcome-card {
  background: linear-gradient(145deg, #0d1527, #070b16);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.welcome-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.welcome-icon {
  font-size: 2rem;
  background: rgba(56, 189, 248, 0.1);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.welcome-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.welcome-header p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.welcome-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.feat-badge {
  font-size: 1rem;
}

/* Messages */
.message-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 100%;
}

.message-row.user {
  align-self: flex-end;
  max-width: 88%;
}

.message-row.agent {
  align-self: flex-start;
  max-width: 100%;
  width: 100%;
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
}

.message-row.user .msg-bubble {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message-row.agent .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

/* Thought Section */
.thought-drawer {
  background: rgba(19, 30, 56, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
}

.thought-header {
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.15);
}

.thought-content {
  padding: 10px 12px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: #cbd5e1;
  white-space: pre-wrap;
  border-top: 1px solid var(--border-subtle);
  max-height: 200px;
  overflow-y: auto;
}

/* Code & Diffs */
pre.code-block {
  background: #040711;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.45;
}

.diff-view {
  background: #040711;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  margin: 10px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.diff-line {
  padding: 2px 10px;
  white-space: pre;
}

.diff-line.add {
  background: var(--diff-add-bg);
  color: var(--diff-add-text);
}

.diff-line.del {
  background: var(--diff-del-bg);
  color: var(--diff-del-text);
}

.diff-line.header {
  color: #38bdf8;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.08);
}

/* Audio Recording Bar */
.recording-banner {
  background: #1e1122;
  border-top: 1px solid #dc2626;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 25;
}

.rec-dot-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ef4444;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  100% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 10px #ef4444; }
}

.rec-timer {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #ef4444;
  font-size: 0.95rem;
}

.rec-label {
  flex: 1;
  font-size: 0.85rem;
  color: #fca5a5;
}

.cancel-rec-btn {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  cursor: pointer;
}

/* Footer / Input Bar */
.app-footer {
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: rgba(11, 17, 32, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-subtle);
  z-index: 20;
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: 6px 10px;
}

.audio-btn, .send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}

.audio-btn {
  background: var(--bg-surface);
  color: var(--primary);
}

.audio-btn.recording {
  background: var(--danger);
  color: #fff;
  animation: pulse 1s infinite alternate;
}

.send-btn {
  background: var(--primary);
  color: #070a12;
}

.send-btn:active {
  transform: scale(0.92);
  background: var(--primary-hover);
}

#messageInput {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.4;
  padding: 8px 4px;
  max-height: 120px;
  resize: none;
  outline: none;
}

#messageInput::placeholder {
  color: var(--text-dim);
}

/* Modals & Drawers */
.modal-overlay, .drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  transition: opacity 0.25s;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
  text-align: center;
  margin-bottom: 20px;
}

.modal-logo {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}

.modal-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-field label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.input-field input, .text-input {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  width: 100%;
}

.input-field input:focus, .text-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.primary-btn {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.primary-btn:active {
  transform: scale(0.97);
}

.secondary-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.85rem;
  padding: 10px;
  cursor: pointer;
  width: 100%;
}

.logout-btn {
  margin-top: 12px;
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.error-msg {
  color: var(--danger);
  font-size: 0.8rem;
  text-align: center;
}

/* Drawer */
.drawer-content {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 85vh;
  background: var(--bg-card);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

.drawer-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
}

.setting-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.account-radio-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.radio-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
}

.radio-card input {
  accent-color: var(--primary);
}

.radio-info {
  display: flex;
  flex-direction: column;
}

.radio-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
}

.radio-desc {
  font-size: 0.68rem;
  color: var(--text-dim);
}

.system-stats-card {
  background: #050813;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px;
  margin-top: 10px;
}

.system-stats-card h4 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stats-text {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #38bdf8;
  line-height: 1.4;
}

.hidden {
  display: none !important;
}
