/* ============================================
   Claude Launcher -- Design System
   Mobile-first, Dark/Light, Android Chrome
   ============================================ */

/* --- Theme variables --- */
:root {
  color-scheme: dark light;
  /* Dark theme (default) */
  --bg-primary: #1a1613;
  --bg-secondary: #252220;
  --bg-tertiary: #302c28;
  --bg-input: #352f2a;
  --bg-code: #1e1a17;
  --bg-user-msg: #3a2f28;
  --text-primary: #ece3d5;
  --text-secondary: #9a918a;
  --text-placeholder: #6b6360;
  --accent: #c2714e;
  --accent-hover: #d4825f;
  --accent-subtle: rgba(194, 113, 78, 0.15);
  --border: #3d3733;
  --danger: #c44e4e;
  --success: #4ec47a;
  --warning: #c4a14e;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 9999px;
}

/* Light theme */
[data-theme="light"] {
  --bg-primary: #faf7f4;
  --bg-secondary: #f0ece7;
  --bg-tertiary: #e6e0d9;
  --bg-input: #eee9e3;
  --bg-code: #f5f0eb;
  --bg-user-msg: #dfd5ca;
  --text-primary: #2c2420;
  --text-secondary: #7a706a;
  --text-placeholder: #a09890;
  --accent: #c2714e;
  --accent-hover: #b0634a;
  --accent-subtle: rgba(194, 113, 78, 0.12);
  --border: #d9d0c8;
  --danger: #c44e4e;
  --success: #3aaa60;
  --warning: #a08830;
}

/* System preference auto-detect */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-primary: #faf7f4;
    --bg-secondary: #f0ece7;
    --bg-tertiary: #e6e0d9;
    --bg-input: #eee9e3;
    --bg-code: #f5f0eb;
    --bg-user-msg: #dfd5ca;
    --text-primary: #2c2420;
    --text-secondary: #7a706a;
    --text-placeholder: #a09890;
    --accent: #c2714e;
    --accent-hover: #b0634a;
    --accent-subtle: rgba(194, 113, 78, 0.12);
    --border: #d9d0c8;
    --danger: #c44e4e;
    --success: #3aaa60;
    --warning: #a08830;
  }
}

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

/* --- Base --- */
html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', 'Roboto', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100%;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  /* Prevent input zoom on Android */
  font-size: 16px;
}

/* --- Typography --- */
h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

/* Section labels */
.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-placeholder);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Layout utilities --- */
.flex-col {
  display: flex;
  flex-direction: column;
}

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

.flex-1 {
  flex: 1;
  min-width: 0;
}

.gap-sm { gap: 6px; }
.gap-md { gap: 10px; }
.gap-lg { gap: 16px; }

/* Full-height app shell */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* dynamic viewport for mobile keyboards */
  overflow: hidden;
}

/* Scrollable content area */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease;
}

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

.btn-primary {
  height: 48px;
  width: 100%;
  background: var(--accent);
  color: white;
  border-radius: var(--radius);
}

.btn-primary:active {
  background: var(--accent-hover);
}

/* Pill button (header toggles) */
.btn-pill {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 22px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Menlo', 'Roboto Mono', monospace;
  cursor: pointer;
}

/* Kill button (danger pill) */
.btn-kill {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-kill:active {
  background: var(--danger);
  color: white;
}

/* Reactive buttons (inline in chat) */
.btn-reactive {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-reactive.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* FAB (floating action button) */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  height: 48px;
  padding: 0 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  z-index: 10;
}

/* --- Inputs --- */
.input-field {
  width: 100%;
  height: 48px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 16px;
  font-size: 16px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

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

.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* --- Search bar --- */
.search-bar {
  height: 40px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  color: var(--text-placeholder);
  font-size: 15px;
}

/* --- Input card (chat input, Claude-app style) --- */
.input-card {
  background: var(--bg-tertiary);
  border-radius: 20px;
  overflow: hidden;
}

.input-card textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  padding: 12px 16px 6px;
  min-height: 40px;
  max-height: 120px;
}

.input-card textarea::placeholder {
  color: var(--text-placeholder);
}

.input-toolbar {
  display: flex;
  align-items: center;
  padding: 4px 8px 8px;
}

/* --- Headers --- */
.app-header {
  display: flex;
  align-items: center;
  padding: 10px 8px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  gap: 6px;
  flex-shrink: 0;
}

/* --- Touch targets (44px minimum) --- */
.touch-target {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.touch-target:active {
  background: var(--bg-tertiary);
}

/* --- Circle buttons (send, mic, voice, stop) --- */
.circle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  border: none;
  background: none;
}

.circle-btn.send {
  background: var(--accent);
}

.circle-btn.voice {
  background: var(--text-primary);
  border-radius: 12px;
}


/* --- Status dot --- */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.active {
  background: var(--success);
  box-shadow: 0 0 6px rgba(78, 196, 122, 0.4);
}

.status-dot.inactive {
  background: var(--text-placeholder);
}

/* --- Code blocks --- */
.code-block {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 8px 0;
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  font-size: 12px;
  font-weight: 600;
}

.code-block-content {
  padding: 12px;
  font-family: 'SF Mono', 'Menlo', 'Roboto Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
}

/* --- Messages --- */
.msg {
  max-width: 100%;
  line-height: 1.5;
  font-size: 15px;
}

.msg p {
  margin-bottom: 8px;
}

.msg p:last-child {
  margin-bottom: 0;
}

.msg-user {
  background: var(--bg-user-msg);
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  padding: 12px 16px;
  align-self: flex-end;
  max-width: 85%;
}

/* --- Project list items --- */
.project-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 14px;
  cursor: pointer;
  border-radius: var(--radius);
}

.project-item:active {
  background: var(--bg-secondary);
}

.project-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

/* --- Session history --- */
.history-toggle {
  padding: 8px 16px 8px 52px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
}

.history-toggle:active {
  background: var(--bg-secondary);
}

.history-arrow {
  font-size: 10px;
  color: var(--text-placeholder);
}

.history-item {
  opacity: 0.5;
}

.history-badge {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
}

/* --- Toggle switch --- */
.toggle {
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle.on {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle .knob {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: 1px;
  left: 1px;
  transition: left 0.2s;
}

.toggle.on .knob {
  left: 19px;
}

/* --- Spinner --- */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Utility --- */
.hidden { display: none !important; }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.mono { font-family: 'SF Mono', 'Menlo', 'Roboto Mono', monospace; }
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
