/* DuoMind Tracker 4.0 - Telegram Theme Integration */

:root {
  --rt-primary: #107229;
  --rt-primary-light: #1a9e3a;
  --rt-danger: #ef4444;
  --rt-warning: #f59e0b;
  --rt-success: #10b981;
}

* {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #050a08;
  color: var(--tg-theme-text-color, #ffffff);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background:
    radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.7) 0%, transparent 100%),
    radial-gradient(1px 1px at 25% 35%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 40% 10%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 45%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 20%, rgba(255,255,255,0.7) 0%, transparent 100%),
    radial-gradient(1px 1px at 85% 55%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 15% 60%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 80%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 70%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 65% 85%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 40%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 95% 75%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 5% 90%, rgba(16, 114, 41, 0.8) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 45% 5%, rgba(16, 114, 41, 0.6) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 90% 65%, rgba(16, 114, 41, 0.7) 0%, transparent 100%),
    radial-gradient(ellipse 300px 200px at 50% 0%, rgba(16, 114, 41, 0.06) 0%, transparent 70%);
  background-color: #050a08;
}

/* Page transitions */
.page {
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
  background: rgba(16, 22, 18, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid rgba(16, 114, 41, 0.15);
}

/* ===== LOGO & PROFILE ===== */

.logo-container {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.logo-container img {
  width: 48px;
  height: 48px;
}

.profile-header {
  margin-bottom: 16px;
  cursor: pointer;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(16, 22, 18, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 12px;
  border: 1.5px solid rgba(16, 114, 41, 0.25);
  transition: transform 0.1s;
}
.profile-row:active { transform: scale(0.98); }
.profile-info { flex: 1; }

/* Avatars */
.profile-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--rt-primary);
}
.profile-avatar-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--rt-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}
.profile-avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--rt-primary);
  margin: 0 auto;
  display: block;
}
.profile-avatar-large-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--rt-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 32px;
  margin: 0 auto;
}

/* Non-blocking API warning banner */
.api-warning {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--rt-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
  font-size: 12px;
}
.api-warning button {
  background: none;
  border: none;
  color: var(--rt-warning);
  text-decoration: underline;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  width: auto;
}

/* Profile page */
.profile-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.profile-stat-row:last-child { border-bottom: none; }

/* ===== TOGGLE SWITCH ===== */

.toggle-btn {
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--tg-theme-hint-color, #555);
  border: none;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-btn.active {
  background: var(--rt-primary);
}

.toggle-btn::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
}

.toggle-btn.active::after {
  transform: translateX(18px);
}

/* ===== PROGRESS BAR ===== */

.progress-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--tg-theme-hint-color, #333);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--rt-primary);
  transition: width 0.5s ease-out;
}

/* ===== HABIT ITEM ===== */

.habit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.habit-item:last-child {
  border-bottom: none;
}

/* ===== GYM SET BUTTONS ===== */

.set-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid var(--tg-theme-hint-color, #444);
  background: transparent;
  color: var(--tg-theme-text-color, #fff);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.set-btn.done {
  background: var(--rt-primary);
  border-color: var(--rt-primary);
  color: white;
}

/* ===== TIMER ===== */

.timer-display {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 8px;
  min-width: 80px;
}

.timer-display.active {
  color: var(--rt-warning);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ===== NAV TILES ===== */

.nav-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 8px;
  border-radius: 14px;
  background: rgba(16, 22, 18, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(16, 114, 41, 0.25);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}

.nav-tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--rt-primary), var(--rt-primary-light));
  border-radius: 14px 14px 0 0;
}

.nav-tile:active {
  transform: scale(0.95);
  border-color: var(--rt-primary);
  box-shadow: 0 0 12px rgba(16, 114, 41, 0.2);
}

.nav-tile .icon {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

/* ===== FINANCE ===== */

.finance-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.amount-red { color: var(--rt-danger); }
.amount-green { color: var(--rt-success); }

/* ===== INPUTS ===== */

input, select, textarea {
  background: rgba(5, 10, 8, 0.8);
  color: var(--tg-theme-text-color, #fff);
  border: 1px solid rgba(16, 114, 41, 0.2);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--rt-primary);
}

/* ===== TABS ===== */

.tab-bar {
  display: flex;
  gap: 4px;
  background: rgba(16, 22, 18, 0.85);
  border: 1px solid rgba(16, 114, 41, 0.15);
  border-radius: 10px;
  padding: 4px;
}

.tab {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--tg-theme-hint-color, #888);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  background: var(--rt-primary);
  color: white;
}

/* ===== SPINNER ===== */

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--tg-theme-hint-color, #333);
  border-top-color: var(--rt-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== RAPPELS ===== */

.rappel-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* ===== STATS ===== */

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--rt-primary);
}

/* ===== MISC ===== */

.error-msg {
  text-align: center;
  padding: 20px;
  color: var(--rt-danger);
}

.safe-bottom {
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 16px));
}

/* ===== BOTTOM NAV ===== */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 56px;
  background: rgba(5, 10, 8, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(16, 114, 41, 0.2);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 100;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  padding: 6px 0;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 10px;
  cursor: pointer;
  transition: color 0.2s;
}

.bottom-nav-item span:first-child {
  font-size: 20px;
  line-height: 1;
}

.bottom-nav-item.active {
  color: var(--rt-primary);
}

.bottom-nav-item:active {
  transform: scale(0.9);
}
