/* ============================================
   Dreamers Assistant — Mini App
   Акцент: #015c31 (тёмно-зелёный)
   ============================================ */

:root {
  --accent: #015c31;
  --accent-light: #0a8a4a;
  --accent-dark: #003d20;
  --bg: #17212b;
  --bg-card: #1f2b38;
  --bg-hover: #2a3a4a;
  --text: #ffffff;
  --text-muted: #8b9bb0;
  --border: #2a3a4a;
  --success: #4fd1c5;
  --warning: #f6ad55;
  --danger: #fc8181;

  /* Учёт безопасной зоны на iPhone */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Roboto", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: calc(70px + var(--safe-bottom));
}

/* ============================================
   ВЕРХНЯЯ ПАНЕЛЬ
   ============================================ */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-card);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.app-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}

.app-user {
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================
   КОНТЕНТ
   ============================================ */

.app-content {
  padding: 16px;
}

.page {
  display: none;
  animation: fadeIn 0.2s ease;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.page h2 {
  font-size: 20px;
  margin-bottom: 14px;
  color: var(--text);
}

.page h3 {
  font-size: 16px;
  margin: 16px 0 10px;
  color: var(--text);
}

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

/* ============================================
   ПЛЕЙСХОЛДЕРЫ (страницы в разработке)
   ============================================ */

.placeholder-card {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 30px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.placeholder-emoji {
  font-size: 40px;
  margin-bottom: 10px;
}

/* ============================================
   ВКЛАДКИ (Опрос / История)
   ============================================ */

.tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 8px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn.active {
  background: var(--accent);
  color: var(--text);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ============================================
   ПОЛЯ ОПРОСА
   ============================================ */

.field {
  margin-bottom: 18px;
}

.field-label {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
}

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.options button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.options button.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text);
}

.options button:active {
  transform: scale(0.97);
}

/* ============================================
   КНОПКА ОТПРАВКИ
   ============================================ */

.submit-btn {
  width: 100%;
  background: var(--accent);
  color: var(--text);
  border: none;
  padding: 14px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s;
}

.submit-btn:disabled {
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: not-allowed;
}

.submit-btn:not(:disabled):active {
  background: var(--accent-dark);
}

#submitResult {
  margin-top: 16px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-card);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--text);
}

#submitResult:empty {
  display: none;
}

/* ============================================
   КОЛЬЦО RECOVERY SCORE
   ============================================ */

.score-ring-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 10px auto 12px;
}

.score-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--bg-card);
  stroke-width: 8;
}

.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 0.6s ease, stroke 0.3s ease;
}

.score-ring-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
}

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

/* ============================================
   ГРАФИК
   ============================================ */

#chart {
  width: 100%;
  height: 180px;
  background: var(--bg-card);
  border-radius: 10px;
  margin-bottom: 8px;
}

.legend {
  display: flex;
  justify-content: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* ============================================
   ИСТОРИЯ
   ============================================ */

.history-row {
  background: var(--bg-card);
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text);
}

.history-row b {
  color: var(--accent-light);
}

/* ============================================
   НИЖНЯЯ НАВИГАЦИЯ
   ============================================ */

.app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px 0 calc(6px + var(--safe-bottom));
  z-index: 100;
}

.nav-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  transition: color 0.15s;
  font-family: inherit;
}

.nav-emoji {
  font-size: 20px;
  line-height: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: 500;
}

.nav-btn.active {
  color: var(--accent-light);
}

.nav-btn:active {
  transform: scale(0.95);
}

/* ============================================
   СКРОЛЛБАР
   ============================================ */

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}