/* ============================================
   Obsidian Vault PWA — Mobile-first styles
   ============================================ */

:root {
  --bg-primary: #1e1e2e;
  --bg-secondary: #262637;
  --bg-surface: #2e2e42;
  --bg-input: #363650;
  --text-primary: #e0def4;
  --text-secondary: #908caa;
  --text-muted: #6e6a86;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-subtle: rgba(124, 58, 237, 0.15);
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.15);
  --error: #f87171;
  --error-bg: rgba(248, 113, 113, 0.15);
  --border: #3e3e56;
  --radius: 8px;
  --radius-lg: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, 'Cascadia Code', monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Header / Nav ---- */

#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
}

#app-header nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  max-width: 640px;
  margin: 0 auto;
}

.nav-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: all 0.15s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-primary);
  background: var(--accent-subtle);
}

/* ---- Main Content ---- */

#app-content {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px;
  padding-bottom: calc(20px + var(--safe-bottom));
  min-height: calc(100vh - 60px);
}

/* ---- Typography ---- */

h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

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

/* ---- Forms ---- */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 12px;
  font-size: 16px; /* Prevents iOS zoom on focus */
  font-family: var(--font-sans);
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent);
}

.form-textarea {
  min-height: 200px;
  resize: vertical;
  line-height: 1.6;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23908caa' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-sans);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: white;
}

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

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

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-input);
}

/* ---- Toast / Feedback ---- */

.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 16px;
  right: 16px;
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  z-index: 200;
  animation: toast-in 0.3s ease;
}

.toast-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success);
}

.toast-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Settings-specific ---- */

.settings-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.settings-section h2 {
  margin-bottom: 4px;
}

.settings-section .subtitle {
  margin-bottom: 16px;
}

.token-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}

.token-status.connected {
  background: var(--success-bg);
  color: var(--success);
}

.token-status.disconnected {
  background: var(--error-bg);
  color: var(--error);
}

.token-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.token-status.connected .dot {
  background: var(--success);
}

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

.help-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 12px;
}

.help-text ol {
  padding-left: 20px;
  margin-top: 8px;
}

.help-text li {
  margin-bottom: 6px;
}

.help-text code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ---- Home View ---- */

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.action-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.action-card:hover {
  border-color: var(--accent);
  background: var(--bg-surface);
}

.action-card .icon {
  font-size: 28px;
  flex-shrink: 0;
}

.action-card .label {
  font-size: 16px;
  font-weight: 600;
}

.action-card .desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ---- Capture-specific ---- */

.capture-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.capture-header .icon {
  font-size: 28px;
}

.char-count {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  margin-top: 4px;
}

/* ---- Utility ---- */

.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.hidden { display: none !important; }
