/* d-brain PWA — mobile-first dark theme */

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --bg-input: #1a1a3e;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b8;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --success: #2ecc71;
  --warning: #f1c40f;
  --error: #e74c3c;
  --border: #2a2a4a;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* ─── Login ─── */

.login-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2rem;
  gap: 1.5rem;
}

.login-view h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.login-view p {
  color: var(--text-secondary);
  text-align: center;
}

/* ─── Header ─── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.5rem;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent);
}

.header .date {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ─── Main content area ─── */

.view {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem 1rem;
  -webkit-overflow-scrolling: touch;
}

.view.hidden {
  display: none;
}

/* ─── Input View ─── */

.input-area {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
}

.input-area textarea {
  flex: 1;
  min-height: 120px;
  max-height: 300px;
  resize: none;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.2s;
}

.input-area textarea:focus {
  border-color: var(--accent);
}

.input-area textarea::placeholder {
  color: var(--text-secondary);
}

.input-buttons {
  display: flex;
  gap: 0.5rem;
}

/* ─── Buttons ─── */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  flex: 1;
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 1.25rem;
  border-radius: 50%;
}

.btn-icon:hover {
  background: var(--border);
}

.btn-icon.recording {
  background: var(--error);
  color: #fff;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.btn-action {
  flex: 1;
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 1rem;
  flex-direction: column;
  gap: 0.25rem;
}

.btn-action:hover {
  background: var(--border);
}

.btn-action .icon {
  font-size: 1.5rem;
}

.btn-action .label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ─── Toast / feedback ─── */

.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: #fff;
  padding: 0.5rem 1.25rem;
  border-radius: 2rem;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 100;
}

.toast.error {
  background: var(--error);
}

.toast.show {
  opacity: 1;
}

/* ─── Status View ─── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.stat-card .number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.daily-content {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 50vh;
  overflow-y: auto;
}

.daily-content h2 {
  font-size: 1rem;
  color: var(--accent);
  margin-top: 0.75rem;
}

.daily-content:empty::after {
  content: 'Нет записей за сегодня';
  color: var(--text-secondary);
  font-style: italic;
}

/* ─── Actions View ─── */

.actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.prompt-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.prompt-row textarea {
  flex: 1;
  min-height: 5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  outline: none;
}

.prompt-row textarea:focus {
  border-color: var(--accent);
}

.prompt-row textarea::placeholder {
  color: var(--text-secondary);
}

.progress-area {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 60px;
}

.progress-area .status {
  color: var(--warning);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.progress-area .report {
  font-size: 0.9rem;
  line-height: 1.6;
}

.progress-area .report:empty::after {
  content: 'Результат появится здесь';
  color: var(--text-secondary);
  font-style: italic;
}

/* ─── Recording indicator ─── */

.recording-bar {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.recording-bar.active {
  display: flex;
}

.recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--error);
  animation: pulse 1s infinite;
}

.recording-bar .timer {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

/* ─── Bottom Nav ─── */

.bottom-nav {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.7rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s;
}

.nav-item .icon {
  font-size: 1.3rem;
}

.nav-item.active {
  color: var(--accent);
}

/* ─── Form input (login) ─── */

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--accent);
}

.form-btn {
  width: 100%;
  padding: 0.85rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.form-btn:hover {
  background: var(--accent-hover);
}

/* ─── Utility ─── */

.text-muted {
  color: var(--text-secondary);
}

.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
