/* ===================================================
   THEME VARIABLES
   =================================================== */

/* Light Theme (day mode) */
:root {
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --card-hover-bg: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --border-radius: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
  --accent-purple: #8b5cf6;
  --accent-purple-light: rgba(99, 102, 241, 0.1);
  --accent-purple-text: #6366f1;
  --score-color: #d97706;
}

/* Dark Theme (night mode) */
@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    --bg-color: #0e0f17;
    --card-bg: #14161f;
    --card-hover-bg: #1c1f2e;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    --border-color: #1e2130;
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
    --accent-purple-light: rgba(129, 140, 248, 0.12);
    --accent-purple-text: #a5b4fc;
    --score-color: #fbbf24;
  }
}

/* Telegram explicit dark class */
body.tg-dark {
  --primary-color: #818cf8;
  --primary-hover: #6366f1;
  --bg-color: #0e0f17;
  --card-bg: #14161f;
  --card-hover-bg: #1c1f2e;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --border-color: #1e2130;
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
  --accent-purple-light: rgba(129, 140, 248, 0.12);
  --accent-purple-text: #a5b4fc;
  --score-color: #fbbf24;
}

/* Telegram explicit light class */
body.tg-light {
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --card-hover-bg: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
  --accent-purple-light: rgba(99, 102, 241, 0.1);
  --accent-purple-text: #6366f1;
  --score-color: #d97706;
}

/* ===================================================
   BASE RESET - Prevent zooming & unwanted touch scrolling
   =================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  touch-action: manipulation; /* Prevents double-tap zoom & pinch zoom */
}

html {
  height: 100%;
  touch-action: manipulation;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
  min-height: 100vh;
  touch-action: manipulation;
}

/* Prevent zoom on input focus on iOS by setting font-size to 16px minimum */
input, select, textarea, button {
  font-size: 16px !important;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ===================================================
   APP CONTAINER LAYOUT
   =================================================== */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  background-color: var(--bg-color);
  overflow: hidden;
}

/* Desktop Centered Container */
@media (min-width: 600px) {
  body {
    background-color: #0a0a0f;
    display: flex;
    justify-content: center;
  }

  body.tg-light {
    background-color: #dde3ee;
  }

  .app-container {
    max-width: 520px;
    box-shadow: var(--shadow-lg);
  }
}

/* Mobile Layout */
@media (max-width: 599px) {
  .app-container {
    width: 100vw;
  }
}

/* ===================================================
   FIXED TOP HEADER - Exactly 100px Top Offset in Telegram
   =================================================== */
.top-header {
  height: 52px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--card-bg);
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}

/* Push header exactly 100px down in Telegram so it clears Telegram top controls */
body.in-telegram .top-header {
  margin-top: 100px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.drawer-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background-color 0.15s;
}

.drawer-toggle-btn:hover {
  background-color: var(--card-hover-bg);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 1rem;
}

.brand-title {
  color: var(--text-main);
}

.brand-sub {
  font-size: 0.7rem;
  background-color: var(--accent-purple-light);
  color: var(--accent-purple-text);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
}

.user-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===================================================
   SCROLLABLE CONTENT AREA
   =================================================== */
.content-area {
  flex: 1;
  padding: 12px 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: manipulation; /* Allow both vertical scrolling and horizontal child panning */
}

/* ===================================================
   SVG Icon Utilities
   =================================================== */
.icon-svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
