/* ===== ClashBot Mini App — Global Styles ===== */

:root {
  --bg: var(--tg-theme-bg-color, #0f0f0f);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #1a1a2e);
  --text: var(--tg-theme-text-color, #ffffff);
  --text-secondary: var(--tg-theme-hint-color, #8e8e93);
  --accent: var(--tg-theme-button-color, #6c5ce7);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #6c5ce7);
  --danger: #e74c3c;
  --success: #2ecc71;
  --warning: #f39c12;
  --info: #3498db;
  --card-bg: var(--tg-theme-secondary-bg-color, rgba(255, 255, 255, 0.05));
  --card-border: rgba(255, 255, 255, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.12);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  padding-bottom: 80px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
.page-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--card-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.page-header h1 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}

.back-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--card-bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: transform var(--transition);
}

.back-btn:active {
  transform: scale(0.9);
}

/* ===== Bottom Navigation ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 8px;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  min-height: 44px;
  min-width: 44px;
}

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

.nav-item:active {
  transform: scale(0.9);
}

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

/* ===== Container ===== */
.container {
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
}

/* ===== Cards ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  transition: transform var(--transition);
  cursor: pointer;
}

.card:active {
  transform: scale(0.98);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  flex: 1;
  margin-right: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ===== Status Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-pending {
  background: rgba(243, 156, 18, 0.15);
  color: var(--warning);
}

.badge-active {
  background: rgba(46, 204, 113, 0.15);
  color: var(--success);
}

.badge-proof {
  background: rgba(52, 152, 219, 0.15);
  color: var(--info);
}

.badge-voting {
  background: rgba(108, 92, 231, 0.15);
  color: var(--accent);
}

.badge-completed {
  background: rgba(142, 142, 147, 0.15);
  color: var(--text-secondary);
}

.badge-cancelled {
  background: rgba(231, 76, 60, 0.15);
  color: var(--danger);
}

.badge-win {
  background: rgba(46, 204, 113, 0.15);
  color: var(--success);
}

.badge-loss {
  background: rgba(231, 76, 60, 0.15);
  color: var(--danger);
}

/* ===== Stats Row ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
}

.stat-value.win { color: var(--success); }
.stat-value.loss { color: var(--danger); }
.stat-value.total { color: var(--accent); }

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* ===== Dispute Meta ===== */
.meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.meta-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.meta-row strong {
  color: var(--text);
  font-weight: 600;
}

/* ===== Countdown ===== */
.countdown {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--warning);
  font-weight: 600;
  margin-top: 8px;
}

.countdown.urgent {
  color: var(--danger);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  width: 100%;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--card-border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-sm {
  padding: 10px 16px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== Section Header ===== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  margin-top: 20px;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
}

.section-link {
  font-size: 13px;
  color: var(--link);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 16px;
}

/* ===== Loading ===== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 12px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--card-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ===== Proof Gallery ===== */
.proof-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.proof-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
}

.proof-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.proof-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.proof-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

/* ===== Voting ===== */
.vote-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.vote-btn {
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

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

.vote-btn.selected {
  border-color: var(--accent);
  background: rgba(108, 92, 231, 0.1);
}

.vote-count {
  display: block;
  font-size: 20px;
  font-weight: 800;
  margin-top: 4px;
}

/* ===== Participants ===== */
.participants {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.participant {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--card-bg);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--card-border);
}

.vs-badge {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  padding: 0 4px;
}

/* ===== Detail Info Block ===== */
.info-block {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.info-block-title {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  margin-bottom: 8px;
}

.info-block-content {
  font-size: 15px;
  line-height: 1.6;
}

/* ===== Timeline ===== */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--card-border);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.timeline-item.completed::before {
  background: var(--success);
}

.timeline-item.current::before {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.2);
}

.timeline-date {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.timeline-text {
  font-size: 14px;
  font-weight: 600;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-secondary);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 200;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeIn 0.3s ease forwards;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.3s; }

/* ===== Profile Header ===== */
.profile-section {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.profile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.profile-info h2 {
  font-size: 18px;
  font-weight: 700;
}

.profile-info p {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 0; height: 0; }

/* ===== Search ===== */
.search-bar {
  padding: 10px 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  width: 100%;
  margin-bottom: 16px;
  outline: none;
  transition: border-color var(--transition);
}

.search-bar:focus {
  border-color: var(--accent);
}

.search-bar::placeholder {
  color: var(--text-secondary);
}

/* ===== History Item ===== */
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform var(--transition);
}

.history-item:active {
  transform: scale(0.98);
}

.history-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.history-icon.win {
  background: rgba(46, 204, 113, 0.15);
}

.history-icon.loss {
  background: rgba(231, 76, 60, 0.15);
}

.history-icon.draw {
  background: rgba(142, 142, 147, 0.15);
}

.history-details {
  flex: 1;
  min-width: 0;
}

.history-details h3 {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-details p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.history-result {
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.history-result.win { color: var(--success); }
.history-result.loss { color: var(--danger); }
.history-result.draw { color: var(--text-secondary); }
