/* WinBets AI — professional Mini App UI */
:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-muted: rgba(59, 130, 246, 0.18);
  --bg: #0a0a0a;
  --bg-elevated: #18181b;
  --bg-overlay: #27272a;
  --border: #27272a;
  --border-focus: #3b82f6;
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #e0f2fe;
  --ring-track: #27272a;
  --ring-fill: #38bdf8;
  --radius: 12px;
  --radius-pill: 9999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  font-family: var(--font);
  background: #0a0a0a;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 10, 10, 0.9);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.app-header-inner {
  max-width: 440px;
  margin: 0 auto;
  padding: 20px 20px;
}

.app-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.app-title-accent {
  color: var(--primary);
  font-weight: 800;
}

/* Main */
.main-content {
  max-width: 440px;
  margin: 0 auto;
  padding: 28px 20px calc(80px + var(--safe-bottom));
}

.page {
  min-height: 200px;
}

/* Predict screen — only three fields + button; no list visible */
.predict-screen {
  margin-bottom: 40px;
}

.predict-intro {
  font-size: 17px;
  color: var(--text-muted);
  margin-bottom: 28px;
  line-height: 1.5;
  font-weight: 500;
}

.predict-form {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Single pill-style control (trigger or input wrap) */
.input-pill {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px 20px;
  min-height: 56px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  color: var(--text);
  font-size: 18px;
  font-family: var(--font);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.input-pill-trigger {
  cursor: pointer;
  text-align: left;
  border: none;
  outline: none;
}

.input-pill-trigger:hover {
  border-color: var(--text-muted);
}

.input-pill:focus-within {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 2px var(--primary-muted);
}

.input-pill-trigger[aria-expanded="true"] {
  border-color: rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 0 2px var(--primary-muted);
}

.input-pill-icon {
  flex-shrink: 0;
  font-size: 22px;
  opacity: 0.9;
}

/* Sport icon badge — app palette (primary border, muted bg) */
.sport-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: var(--primary-muted);
  border: 1px solid rgba(59, 130, 246, 0.5);
  border-radius: 10px;
}

.sport-icon {
  font-size: 20px;
  line-height: 1;
}

.input-pill-text {
  flex: 1;
  min-width: 0;
}

.input-pill-chevron {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border-right: 2.5px solid var(--text-muted);
  border-bottom: 2.5px solid var(--text-muted);
  transform: rotate(45deg);
  margin-bottom: 2px;
  transition: transform 0.2s;
}

.input-pill-trigger[aria-expanded="true"] .input-pill-chevron {
  transform: rotate(-135deg);
  margin-bottom: -2px;
}

.input-pill-input {
  flex: 1;
  min-width: 0;
  padding: 0;
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  font-family: var(--font);
  text-align: left;
}

/* На iOS/Android текст даты рисуется в псевдоэлементе — выравниваем его влево */
.input-pill-input::-webkit-date-and-time-value {
  text-align: left;
}

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

.input-pill-input:focus {
  outline: none;
}

.input-pill-input-full {
  padding-left: 0;
}

/* CTA */
.btn-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 22px 28px;
  min-height: 58px;
  margin-top: 12px;
  background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 19px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
}

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

.btn-cta:hover:not(:disabled) {
  box-shadow: 0 6px 24px rgba(59, 130, 246, 0.5);
}

.btn-cta:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-cta-icon {
  font-size: 24px;
  line-height: 1;
}

.btn-cta-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
  box-shadow: none;
}

.btn-cta-outline:hover {
  background: var(--primary-muted);
  color: var(--text);
}

/* Overlay — completely off-screen when closed (display:none = never painted) */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.overlay.is-open {
  display: flex;
  animation: overlayIn 0.2s ease-out;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  animation: backdropIn 0.25s ease-out;
}

@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay-panel {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 75vh;
  background: #1c1c1e;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  animation: panelSlideUp 0.35s cubic-bezier(0.32, 0.72, 0, 1) forwards;
  display: flex;
  flex-direction: column;
}

.overlay.is-open .overlay-panel {
  transform: translateY(0);
}

@keyframes panelSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

body.overlay-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

.overlay-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.overlay-panel-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.02em;
}

.overlay-panel-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--text-secondary);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  border-radius: 12px;
  transition: background 0.2s, color 0.2s;
}

.overlay-panel-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.overlay-panel-body {
  padding: 12px 0 32px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 65vh;
}

.sport-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px 20px;
  min-height: 56px;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 18px;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.sport-option .sport-icon-badge {
  width: 40px;
  height: 40px;
}

.sport-option .sport-option-label {
  flex: 1;
  min-width: 0;
}

.sport-option:last-child {
  border-bottom: none;
}

.sport-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.sport-option.is-selected {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
  font-weight: 600;
}

/* Result states */
.result-state {
  margin-top: 24px;
}

.result-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 48px 20px;
}

.result-loading-spinner {
  width: 52px;
  height: 52px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.result-loading-text {
  font-size: 17px;
  color: var(--text-secondary);
}

.result-error {
  padding: 24px 22px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  color: #fca5a5;
  font-size: 17px;
  line-height: 1.5;
}

.result-block {
  padding: 24px 16px;
  background: rgba(24, 24, 27, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.predictions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 380px) {
  .predictions-grid {
    grid-template-columns: 1fr;
  }
  .prediction-card {
    max-width: 200px;
    margin: 0 auto;
  }
}

.prediction-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
}

.prediction-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
  line-height: 1.3;
  min-height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.confidence-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.confidence-ring {
  position: relative;
  width: 140px;
  height: 140px;
}

.confidence-ring-sm {
  width: 90px;
  height: 90px;
}

.confidence-ring-sm .confidence-value {
  font-size: 22px;
  font-weight: 800;
}

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

.ring-bg {
  stroke: var(--ring-track);
}

.ring-fill {
  stroke: var(--ring-fill);
  transition: stroke-dashoffset 0.5s cubic-bezier(0.33, 1, 0.68, 1);
}

.confidence-value {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 38px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
}

.prediction-explanation {
  font-size: 12px;
  color: var(--accent);
  line-height: 1.5;
  white-space: pre-wrap;
  margin: 0;
  text-align: left;
}

.result-explanation {
  font-size: 17px;
  color: var(--accent);
  line-height: 1.6;
  white-space: pre-wrap;
  margin: 0;
}

/* Profile & placeholders */
.profile-section,
.page-placeholder section {
  padding: 0;
}

.profile-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.profile-text {
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

.profile-partner-text {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 20px 0;
}

.profile-section .btn-cta-outline {
  display: inline-block;
}

/* History */
.history-section {
  padding: 0;
}

.history-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

.history-empty {
  text-align: center;
  padding: 48px 24px;
}

.history-empty-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}

.history-empty-hint {
  font-size: 15px;
  color: var(--text-muted);
  margin: 0;
}

.history-loading {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-card {
  background: rgba(24, 24, 27, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.history-card-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.history-card-event {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-card-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

.history-card-time {
  font-size: 12px;
  color: var(--text-muted);
}

.history-card-chevron {
  font-size: 24px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 12px;
  transition: transform 0.2s;
}

.history-card-expanded .history-card-chevron {
  transform: rotate(90deg);
}

.history-card-detail {
  display: none;
  padding: 0 18px 18px;
  border-top: 1px solid var(--border);
}

.history-card-expanded .history-card-detail {
  display: block;
  padding-top: 16px;
}

.history-prediction {
  margin-bottom: 16px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.history-prediction:last-child {
  margin-bottom: 0;
  border-bottom: none;
}

.history-pred-outcome {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.history-pred-ring-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
}

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

.history-pred-value {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.history-pred-explanation {
  font-size: 12px;
  color: var(--accent);
  line-height: 1.5;
  margin: 0;
}

/* Support chat — только эта страница: высота задана, скролл в середине, форма внизу */
.page-support {
  display: flex;
  flex-direction: column;
  height: 62vh;
  min-height: 360px;
  max-height: 520px;
}

.support-section {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.support-header {
  flex-shrink: 0;
  margin-bottom: 12px;
}

.support-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--text);
}

.support-hint {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

.support-chat-body {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  margin-bottom: 12px;
}

.support-messages {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 0;
  -webkit-overflow-scrolling: touch;
}

.support-empty {
  font-size: 15px;
  color: var(--text-muted);
  text-align: center;
  padding: 28px 16px;
  margin: 0;
  flex-shrink: 0;
}

.support-msg {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.45;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px 8px;
}

.support-msg-icon {
  font-size: 16px;
  line-height: 1.2;
  flex-shrink: 0;
}

.support-msg-body {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}

.support-msg-time {
  width: 100%;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  padding-left: 0;
}

.support-msg-user {
  align-self: flex-end;
  background: var(--primary-muted);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: var(--text);
}

.support-msg-support {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--accent);
}

.support-error {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 6px 0;
  padding: 0;
  min-height: 18px;
}

.support-error:empty {
  display: none !important;
}

/* Форма ввода — одна строка: поле + кнопка, всегда видна */
.support-form-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 10px;
  margin: 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--border);
}

.support-input {
  flex: 1 1 auto;
  min-width: 80px;
  width: 100%;
  min-height: 48px;
  max-height: 96px;
  padding: 12px 14px;
  margin: 0;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  font-family: var(--font);
  line-height: 1.4;
  resize: none;
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

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

.support-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-muted);
}

.support-form-wrap .btn-cta-sm {
  flex-shrink: 0;
  width: 72px;
  min-height: 48px;
  padding: 12px 0;
  font-size: 15px;
  font-weight: 600;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.placeholder-text {
  font-size: 17px;
  color: var(--text-secondary);
  text-align: center;
  padding: 48px 24px;
  margin: 0;
}

/* Guide */
.guide-section {
  padding: 0 4px 0 0;
}

.guide-title {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 8px 0;
  color: var(--text);
  letter-spacing: -0.02em;
}

.guide-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin: 0 0 28px 0;
  line-height: 1.4;
}

.guide-card {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: 28px 24px;
  margin-bottom: 28px;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.guide-card:last-child {
  margin-bottom: 0;
}

.guide-card-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  line-height: 1;
  background: rgba(59, 130, 246, 0.12);
  border-radius: 12px;
}

.guide-card-content {
  flex: 1;
  min-width: 0;
}

.guide-card-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: var(--text);
  line-height: 1.3;
}

.guide-card-text {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin: 0;
}

.guide-card-text strong {
  color: var(--text);
  font-weight: 600;
}

/* Bottom nav — компактно, чтобы все 5 вкладок помещались на узких экранах */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + var(--safe-bottom));
  padding: 6px 4px var(--safe-bottom) 4px;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  z-index: 40;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  text-decoration: none;
  padding: 4px 2px;
  border-radius: var(--radius);
  flex: 1;
  min-width: 0;
  max-width: 72px;
  transition: color 0.2s;
}

.nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
}

.bottom-nav a:hover,
.bottom-nav a.active {
  color: var(--primary);
}

/* Center button PREDICT — stands out from the rest */
.nav-link-center {
  background: var(--primary);
  color: #fff !important;
  border-radius: 12px;
  padding: 6px 8px;
  max-width: 72px;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
}

.nav-link-center .nav-icon-wrap {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: none;
}

.nav-link-center:hover,
.nav-link-center.active {
  color: #fff !important;
  background: var(--primary-hover);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.5);
}

.nav-link-center .nav-label {
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.nav-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition: background 0.2s, box-shadow 0.2s;
}

.bottom-nav a:not(.nav-link-center).active .nav-icon-wrap {
  background: rgba(56, 189, 248, 0.2);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

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