/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #ff6600;
  --primary-light: #ffd9b3;
  --secondary-color: #4caf50;
  --background: #f5f5f5;
  --surface: #ffffff;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --border: #e0e0e0;
  --border-light: #f0f0f0;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-heavy: 0 8px 24px rgba(0, 0, 0, 0.12);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --radius: 12px;
  --radius-small: 6px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== LAYOUT ===== */
.mobile-container {
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  min-height: 100vh;
  position: relative;
  padding-bottom: 70px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* ===== HEADER ===== */
.header {
  background: var(--surface);
  padding: 16px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  background-color: rgba(255, 255, 255, 0.95);
}

.header h1 {
  color: var(--primary-color);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.header-logo {
  width: 28px;
  height: 28px;
  background: var(--primary-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  font-weight: bold;
}

/* ===== DATE NAVIGATION ===== */
.date-nav {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
}

.date-nav.show {
  display: flex;
}

.date-nav button {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
}

.date-nav button:hover {
  background: var(--background);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.date-nav button:active {
  transform: scale(0.95);
}

.date-nav .today {
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-small);
  transition: var(--transition);
}

.date-nav .today:hover {
  background: var(--background);
}

.date-nav .today .chevron {
  font-size: 10px;
  transition: transform 0.3s ease;
}

.date-nav .today.expanded .chevron {
  transform: rotate(180deg);
}

/* ===== CALENDAR POPUP ===== */
.calendar-popup {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-heavy);
  z-index: 1000;
  width: 340px;
  max-width: calc(100vw - 32px);
  display: none;
  animation: slideDown 0.2s ease-out;
}

.calendar-popup.show {
  display: block;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.calendar-header button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: var(--transition);
}

.calendar-header button:hover {
  background: var(--background);
  color: var(--primary-color);
}

.calendar-header span {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 12px;
}

.calendar-day {
  text-align: center;
  padding: 10px 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
}

.calendar-day.header {
  font-weight: 600;
  color: var(--text-tertiary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.calendar-day.date {
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.calendar-day.date:hover {
  background: var(--background);
  transform: scale(1.05);
}

.calendar-day.date:active {
  transform: scale(0.95);
}

.calendar-day.today {
  background: var(--primary-color);
  color: white;
  font-weight: 700;
}

.calendar-day.selected {
  background: var(--primary-light);
  color: var(--primary-color);
  font-weight: 700;
}

.calendar-day.other-month {
  color: #ccc;
  opacity: 0.5;
}

/* ===== FILTER TABS ===== */
.filter-tabs {
  display: none;
  background: var(--surface);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.filter-tabs::-webkit-scrollbar {
  display: none;
}

.filter-tabs.show {
  display: flex;
}

.filter-tabs button {
  background: none;
  border: none;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 20px;
  transition: var(--transition);
}

.filter-tabs button:hover {
  background: var(--background);
}

.filter-tabs button.active {
  background: var(--primary-color);
  color: white;
  font-weight: 600;
}

/* ===== LEAGUE SECTION ===== */
.league-section {
  margin: 8px 0;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.league-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  border-bottom: 1px solid transparent;
}

.league-header:hover {
  background: var(--background);
}

.league-header.expanded {
  border-bottom-color: var(--border);
}

.league-icon {
  font-size: 18px;
  margin-right: 12px;
  color: var(--primary-color);
}

.league-name {
  font-weight: 700;
  font-size: 14px;
  flex: 1;
  color: var(--text-primary);
}

.league-header .count {
  background: var(--primary-color);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  margin-right: 12px;
  min-width: 28px;
  text-align: center;
}

.league-header .arrow {
  font-size: 12px;
  color: var(--text-tertiary);
  transition: transform 0.25s ease;
}

.league-header.expanded .arrow {
  transform: rotate(180deg);
}

/* ===== MATCHES ===== */
.league-matches {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.league-matches.expanded {
  max-height: 5000px;
}

.match-item {
  display: flex;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition);
  cursor: pointer;
  gap: 12px;
  position: relative;
}

.match-item:last-child {
  border-bottom: none;
}

.match-item:hover {
  background: var(--background);
}

.match-item:active {
  background: var(--border-light);
}

.match-time {
  font-size: 13px;
  font-weight: 600;
  min-width: 52px;
  text-align: center;
  line-height: 1.3;
  padding: 4px 0;
  border-radius: 4px;
  background: var(--background);
}

.match-time.live {
  color: var(--primary-color);
  background: rgba(255, 102, 0, 0.1);
  font-weight: 700;
}

.match-time.finished {
  color: var(--text-tertiary);
  background: var(--background);
}

.match-teams {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.team-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.team-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--background);
  padding: 2px;
}

.team-name {
  font-size: 14px;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-score {
  min-width: 48px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.score {
  font-weight: 800;
  font-size: 17px;
  color: var(--text-primary);
  line-height: 1;
}

.score.empty {
  color: var(--text-tertiary);
  font-size: 15px;
  font-weight: 600;
}

.score.hidden {
  display: none;
}

.match-status {
  position: absolute;
  top: 12px;
  right: 16px;
}

.match-status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.match-status-badge.scheduled {
  background: var(--background);
  color: var(--text-tertiary);
}

.match-status-badge.live {
  background: var(--primary-color);
  color: white;
  animation: pulse 1.5s infinite;
}

.match-status-badge.finished {
  background: var(--secondary-color);
  color: white;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(255, 102, 0, 0.4);
  }
  50% {
    opacity: 0.9;
    box-shadow: 0 0 0 4px rgba(255, 102, 0, 0);
  }
}

/* ===== EMPTY STATES ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-state-text {
  font-size: 14px;
  max-width: 300px;
  margin: 0 auto 20px;
}

.empty-state-action {
  display: inline-block;
  padding: 10px 20px;
  background: var(--primary-color);
  color: white;
  border-radius: var(--radius-small);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: var(--transition);
}

.empty-state-action:hover {
  background: #e65c00;
  transform: translateY(-2px);
}

/* ===== LOADING STATES ===== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--background);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  color: var(--text-tertiary);
  font-size: 15px;
  font-weight: 500;
}

/* ===== BOTTOM NAVIGATION ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  width: 100%;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  z-index: 99;
  backdrop-filter: blur(10px);
  background-color: rgba(255, 255, 255, 0.98);
}

.nav-item {
  text-align: center;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  flex: 1;
  padding: 8px 0;
  border-radius: 8px;
  transition: var(--transition);
  position: relative;
}

.nav-item:hover {
  background: var(--background);
}

.nav-item.active {
  color: var(--primary-color);
}

.nav-item.active .nav-icon {
  transform: translateY(-2px);
}

.nav-item.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--primary-color);
  border-radius: 2px;
}

.nav-icon {
  font-size: 22px;
  margin-bottom: 4px;
  display: block;
  transition: var(--transition);
}

/* ===== STANDINGS ===== */
.standings-container {
  padding: 16px;
}

.standings-header {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.standings-table {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.standings-row {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  transition: var(--transition);
}

.standings-row:last-child {
  border-bottom: none;
}

.standings-row:hover {
  background: var(--background);
}

.standings-rank {
  width: 32px;
  text-align: center;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 15px;
}

.standings-rank.top-4 {
  color: var(--primary-color);
}

.standings-rank.relegation {
  color: #ff4757;
}

.standings-team {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.standings-team-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.standings-team-name {
  font-weight: 500;
}

.standings-stats {
  display: flex;
  gap: 16px;
  margin-left: auto;
}

.standings-stat {
  width: 24px;
  text-align: center;
  font-weight: 500;
  color: var(--text-secondary);
}

.standings-pts {
  width: 40px;
  text-align: right;
  font-weight: 800;
  color: var(--text-primary);
  font-size: 15px;
}

/* ===== LEAGUES VIEW ===== */
.leagues-container {
  padding: 16px;
}

.league-card {
  display: flex;
  align-items: center;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: var(--transition);
}

.league-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.league-card:active {
  transform: translateY(0);
}

.league-card-icon {
  width: 40px;
  height: 40px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--primary-color);
  margin-right: 16px;
  flex-shrink: 0;
}

.league-card-info {
  flex: 1;
}

.league-card-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.league-card-country {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ===== REFRESH CONTROL ===== */
.refresh-control {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.refresh-control.show {
  opacity: 1;
  pointer-events: all;
}

.refresh-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--background);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ===== TOAST NOTIFICATION ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  box-shadow: var(--shadow-heavy);
  transition: transform 0.3s ease;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: #ff4757;
}

.toast.success {
  background: var(--secondary-color);
}

.toast.warning {
  background: #ffa502;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 480px) {
  .mobile-container {
    border-radius: 0;
  }

  .calendar-popup {
    width: calc(100vw - 32px);
  }

  .team-name {
    font-size: 13px;
  }

  .score {
    font-size: 16px;
  }
}

/* ===== UTILITY CLASSES ===== */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}