/* ===== NoteScribe — Red & Black Mobile-First PWA ===== */

:root {
  --red: #dc2626;
  --red-dark: #991b1b;
  --red-light: #fca5a5;
  --red-glow: rgba(220, 38, 38, 0.4);
  --bg: #0a0a0a;
  --bg-card: #141414;
  --bg-elevated: #1a1a1a;
  --bg-input: #1e1e1e;
  --text: #f5f5f5;
  --text-muted: #a3a3a3;
  --text-dim: #525252;
  --border: #262626;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: manipulation;
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ===== SCREENS ===== */
.screen { display: none; height: 100vh; width: 100%; }
.screen.active { display: flex; flex-direction: column; }

/* ===== LOGIN ===== */
#login-screen {
  justify-content: center;
  align-items: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(220,38,38,0.08) 0%, var(--bg) 70%);
}

.login-container {
  width: 100%;
  max-width: 380px;
  padding: 32px 24px;
}

.login-logo {
  text-align: center;
  margin-bottom: 40px;
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 700;
  margin-top: 16px;
  letter-spacing: -0.5px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px; /* prevents iOS zoom */
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--red);
}

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

.btn-primary-full {
  width: 100%;
  padding: 14px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.btn-primary-full:hover { background: var(--red-dark); }
.btn-primary-full:disabled { opacity: 0.5; cursor: not-allowed; }

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
  min-height: 20px;
}

.info-text {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 16px;
  text-align: center;
}

/* ===== TOP BAR ===== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.top-title {
  font-size: 18px;
  font-weight: 700;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover { background: var(--bg-elevated); }

/* ===== VIEWS ===== */
.view {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(72px + var(--safe-bottom));
}

.view.active { display: flex; flex-direction: column; }

/* ===== RECORD VIEW ===== */
.record-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 24px;
}

.record-status {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 500;
}

.record-timer {
  font-size: 48px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  color: var(--text-dim);
  transition: color 0.3s;
}

.record-timer.active { color: var(--red); }

/* Big mic button */
.mic-btn {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--red);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.3s;
  box-shadow: 0 0 0 0 var(--red-glow);
}

.mic-btn:hover { transform: scale(1.05); }
.mic-btn:active { transform: scale(0.95); }

.mic-btn.recording {
  background: var(--red-dark);
  box-shadow: 0 0 0 16px rgba(220,38,38,0.15), 0 0 40px var(--red-glow);
}

.mic-pulse {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--red);
  opacity: 0;
  pointer-events: none;
}

.mic-btn.recording .mic-pulse {
  animation: pulse-ring 1.5s ease-out infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Upload */
.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.divider-text {
  color: var(--text-dim);
  font-size: 13px;
}

.upload-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.upload-btn:hover { border-color: var(--red); color: var(--text); }

/* Recording controls */
.record-controls {
  display: flex;
  gap: 24px;
}

.ctrl-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.ctrl-btn:hover { background: var(--bg-elevated); }
.ctrl-stop { border-color: var(--red); color: var(--red); }
.ctrl-stop:hover { background: rgba(220,38,38,0.1); }

/* Live transcript */
.live-transcript {
  width: 100%;
  max-width: 480px;
  margin-top: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.live-transcript-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.live-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  background: var(--red);
  padding: 2px 6px;
  border-radius: 4px;
  animation: live-blink 1.5s ease-in-out infinite;
}

@keyframes live-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.live-hint {
  font-size: 11px;
  color: var(--text-dim);
}

.live-transcript-text {
  padding: 10px 12px;
  max-height: 180px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

.live-transcript-text p {
  margin-bottom: 6px;
}

.live-placeholder {
  color: var(--text-dim);
  font-style: italic;
}

.live-interim {
  padding: 0 12px 10px;
  font-size: 14px;
  color: var(--text-dim);
  opacity: 0.6;
  font-style: italic;
  min-height: 20px;
}

/* ===== MEETING DETAIL VIEW ===== */
.meeting-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.meeting-title-text {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meeting-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-sm {
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-sm:hover { background: var(--bg-elevated); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,0.1); }

/* Processing bar */
.processing-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  flex: 1;
  padding: 12px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}

.tab:hover { color: var(--text-muted); }
.tab.active { color: var(--red); border-bottom-color: var(--red); }

.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

.placeholder-text {
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  padding: 32px 16px;
}

/* Topics */
.topics-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.topic-tag {
  padding: 4px 12px;
  background: rgba(220,38,38,0.1);
  border: 1px solid rgba(220,38,38,0.2);
  border-radius: 20px;
  font-size: 12px;
  color: var(--red-light);
}

/* Transcript */
.transcript-scroll {
  max-height: calc(100vh - 280px);
  overflow-y: auto;
}

.transcript-segment {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.transcript-segment:last-child { border-bottom: none; }

.seg-time {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.seg-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Action items */
.action-item {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.action-check {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 2px;
}

.action-body { flex: 1; }

.action-task {
  font-size: 14px;
  color: var(--text);
}

.action-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Decisions */
.decision-item {
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

/* ===== HISTORY VIEW ===== */
.history-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.search-bar input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

.search-bar input::placeholder { color: var(--text-dim); }
.search-bar svg { color: var(--text-dim); flex-shrink: 0; }

.meetings-list {
  padding: 8px 16px;
  flex: 1;
  overflow-y: auto;
}

.meeting-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.meeting-card:hover { border-color: var(--red); }

.meeting-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(220,38,38,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.meeting-card-body { flex: 1; min-width: 0; }

.meeting-card-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meeting-card-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.meeting-card-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}

.status-transcribed { background: rgba(34,197,94,0.15); color: var(--success); }
.status-summarized { background: rgba(220,38,38,0.15); color: var(--red-light); }
.status-created { background: rgba(234,179,8,0.15); color: var(--warning); }
.status-transcribing, .status-summarizing { background: rgba(168,85,247,0.15); color: #c084fc; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.2s;
}

.nav-btn:hover { color: var(--text-muted); }
.nav-btn.active { color: var(--red); }

/* ===== IDLE LOCK ===== */
.idle-lock {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.idle-lock-content {
  text-align: center;
  padding: 32px;
}

.idle-lock-content p {
  color: var(--text-muted);
  margin: 16px 0 24px;
  font-size: 15px;
}

.idle-lock-content .btn-primary-full {
  max-width: 200px;
  margin: 0 auto;
}

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
  .mic-btn { width: 140px; height: 140px; }
  .record-timer { font-size: 56px; }
  .tab-content { padding: 24px; }
  .meetings-list { padding: 12px 24px; }
}

@media (min-width: 1024px) {
  .bottom-nav { max-width: 480px; margin: 0 auto; }
  #app-screen { max-width: 600px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
