@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

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

svg {
  max-width: 100%;
  height: auto;
}

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #222240;
  --bg-input: #16162a;
  --border: #2a2a4a;
  --border-focus: #7c3aed;
  --text-primary: #f0f0f5;
  --text-secondary: #9090a8;
  --text-muted: #606078;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-light: rgba(124, 58, 237, 0.15);
  --green: #10b981;
  --green-light: rgba(16, 185, 129, 0.15);
  --red: #ef4444;
  --red-light: rgba(239, 68, 68, 0.15);
  --yellow: #f59e0b;
  --yellow-light: rgba(245, 158, 11, 0.15);
  --blue: #3b82f6;
  --blue-light: rgba(59, 130, 246, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  padding-bottom: 80px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-success {
  background: var(--green);
  color: white;
}

.btn-danger {
  background: var(--red);
  color: white;
}

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

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-group input,
.input-group select {
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  transition: border-color 0.2s;
  width: 100%;
}

.input-group input:focus,
.input-group select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
}

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

input[type="datetime-local"],
input[type="date"],
input[type="time"] {
  color-scheme: dark;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 1;
  filter: brightness(10);
  transition: opacity 0.2s;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
  filter: brightness(10) drop-shadow(0 0 4px var(--accent));
}

input[type="color"] {
  -webkit-appearance: none;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  padding: 4px !important;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.2s ease;
}

.card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-light);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-upcoming { background: var(--blue-light); color: var(--blue); }
.badge-live { background: var(--yellow-light); color: var(--yellow); }
.badge-completed { background: var(--green-light); color: var(--green); }
.badge-won { background: var(--green-light); color: var(--green); }
.badge-lost { background: var(--red-light); color: var(--red); }
.badge-pending { background: var(--yellow-light); color: var(--yellow); }

.game-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-input);
  color: var(--text-secondary);
}

.user-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

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

.logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
}

.logout-btn:hover {
  background: var(--red-light);
  color: var(--red);
  border-color: var(--red);
}

.page-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 800;
}

.navbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 8px 0;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

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

.match-detail-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.player-select-btn {
  width: 100%;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.player-select-btn:hover {
  border-color: var(--accent);
}

.player-select-btn.selected {
  border-width: 2px;
  border-style: solid;
  background: rgba(255,255,255,0.06);
}

.admin-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.admin-section h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

.admin-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.admin-form .full-width {
  grid-column: 1 / -1;
}

.match-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.match-list-info { flex: 1; }
.match-list-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bets-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

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

.stat-value {
  font-size: 20px;
  font-weight: 800;
}

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
}

/* MIS APUESTAS STYLES */
.filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
}

.filter-tab {
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.filter-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.bet-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  bottom: 80px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  z-index: 2000;
}

.toast-success { background: var(--green); color: white; }
.toast-error { background: var(--red); color: white; }

/* EMPTY STATE */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
  stroke: var(--text-muted);
}

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

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

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

@media (max-width: 600px) {
  .admin-form { grid-template-columns: 1fr; }
  .match-list-item { flex-direction: column; align-items: flex-start; gap: 12px; }
  .match-list-actions { width: 100%; }
}

/* ==========================================================================
   NEW LAYOUT SYSTEM (top-nav / bottom-nav / container)
   ========================================================================== */

.top-nav {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}

.top-nav-content {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 800;
  font-size: 16px;
}

.logo:hover {
  text-decoration: none;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(124,58,237,0.3), rgba(255,0,128,0.2));
  border: 1px solid rgba(124,58,237,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
  width: auto;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 16px;
}

.main-content {
  padding-top: 20px;
  padding-bottom: 100px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.back-link svg {
  width: 18px;
  height: 18px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 8px 0 12px;
  z-index: 100;
}

.bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
  text-decoration: none;
}

.bottom-nav .nav-item:hover {
  text-decoration: none;
  color: var(--text-secondary);
}

.bottom-nav .nav-item svg {
  width: 22px;
  height: 22px;
}

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

.loading {
  display: flex;
  justify-content: center;
  padding: 40px 20px;
}

/* ==========================================================================
   COMPONENT STYLES (match cards, bet items, filters, etc.)
   ========================================================================== */

.match-card {
  cursor: pointer;
}

.match-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.match-title span:first-child {
  font-size: 13px;
  color: var(--text-secondary);
}

.match-players {
  display: flex;
  align-items: center;
  gap: 12px;
}

.match-player {
  flex: 1;
  text-align: center;
}

.match-player .name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.match-vs {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Bet form (match detail) */
.bet-form {
  margin-top: 20px;
}

.bet-summary {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 14px;
}

.paypal-section {
  margin-top: 16px;
}

/* Filter buttons */
.bets-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-btn {
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Bet items (my bets list) */
.bet-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

.bet-item:hover {
  border-color: var(--accent);
}

.bet-info {
  flex: 1;
}

.bet-match {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.bet-detail {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.bet-detail strong {
  color: var(--text-primary);
}

.bet-amount {
  text-align: right;
  flex-shrink: 0;
  margin-left: 12px;
}

.bet-amount .amount {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}

.potential {
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  margin-top: 4px;
}

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

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Admin match list additions */
.match-name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}

.match-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.result-select {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.result-select select {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
}

/* ==========================================================================
   AUTH / LOGIN PAGE STYLES (SAFARI & MOBILE OPTIMIZED)
   ========================================================================== */

.auth-container {
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: var(--bg-primary);
  background-image: radial-gradient(circle at 50% 0%, rgba(124, 58, 237, 0.25) 0%, transparent 70%);
  box-sizing: border-box;
}

.auth-box {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-bottom: 24px;
  width: 100%;
}

.auth-logo-badge {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px auto;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.3), rgba(255, 0, 128, 0.2));
  border: 1px solid rgba(124, 58, 237, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a855f7;
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.3);
}

.auth-logo h1 {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #ffffff;
  text-align: center;
  margin: 0;
  line-height: 1.2;
}

.auth-subtitle {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-top: 4px;
  text-align: center;
}

.auth-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
}

#auth-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 20px;
  text-align: center;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Safari-safe Flex Input with Icon */
.input-group .input-icon-wrapper {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  padding: 0 14px !important;
  width: 100% !important;
  box-sizing: border-box !important;
  transition: border-color 0.2s, box-shadow 0.2s !important;
}

.input-group .input-icon-wrapper:focus-within {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-light) !important;
}

.input-group .input-icon-wrapper .input-icon {
  position: static !important;
  flex-shrink: 0 !important;
  margin-right: 10px !important;
  color: var(--text-muted) !important;
  display: block !important;
}

.input-group .input-icon-wrapper:focus-within .input-icon {
  color: var(--accent) !important;
}

.input-group .input-icon-wrapper input {
  flex: 1 !important;
  width: 100% !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 14px 0 !important;
  font-size: 16px !important; /* 16px prevents iOS Safari auto-zoom */
  color: var(--text-primary) !important;
}

.auth-btn-wrapper {
  margin-top: 8px;
}

#auth-btn {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-appearance: none;
}

#auth-btn:active {
  transform: scale(0.98);
}

.auth-toggle {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-toggle a {
  color: var(--accent);
  font-weight: 700;
  margin-left: 6px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 16px;
  transition: color 0.2s ease;
}

.back-link:hover {
  color: var(--accent);
}

.back-link svg {
  width: 18px !important;
  height: 18px !important;
  max-width: 18px !important;
  max-height: 18px !important;
  flex-shrink: 0;
}

.nav-item svg {
  width: 22px !important;
  height: 22px !important;
  max-width: 22px !important;
  max-height: 22px !important;
  flex-shrink: 0;
}


