/**
 * Shared Match/Fixture Card Styles
 * Used across home, team, and league pages for consistent formatting
 */

/* Match/Fixture Card Container */
.match-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.875rem;
  transition: transform 0.2s, border-color 0.2s;
  cursor: pointer;
}

.match-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-1px);
}

.match-card.live {
  border-color: var(--accent-dim);
  background: linear-gradient(to right, var(--bg-secondary), var(--bg-tertiary));
}

/* Match Card Header (optional - for date/competition) */
.match-card-header {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Match Card Main Content */
.match-card-main {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.875rem;
  align-items: start;
  margin-bottom: 0.5rem;
}

/* Team Sections */
.match-card-team {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 1.875rem;
  justify-content: center;
}

.match-card-team.home {
  text-align: right;
}

.match-card-team.away {
  text-align: left;
}

.match-card-team-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.match-card-team-name.highlight {
  color: var(--accent);
  font-weight: 700;
}

.match-card-team-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.match-card-team-link:hover {
  color: var(--accent);
}

/* Team Star Buttons */
.team-star-btn {
  background: none;
  border: none;
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0.125rem 0.25rem;
  color: var(--yellow);
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 0.25rem;
  vertical-align: middle;
}

.team-star-btn:hover {
  transform: scale(1.2);
  filter: brightness(1.3);
}

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

.match-card-team.home .team-star-btn {
  order: 1;
}

.match-card-team.away .team-star-btn {
  order: -1;
}

/* Score Area */
.match-card-score-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  flex-shrink: 0;
  min-width: 60px;
  min-height: 1.875rem;
}

/* Live Badge */
.match-card-live-badge {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--live-pulse);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.125rem;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live-pulse);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.9);
  }
}

.match-card-score {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1ch;
  line-height: 1.4;
  white-space: nowrap;
}

.match-card-score.kickoff-time {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: normal;
}


.match-card-status {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.match-card-status.live {
  color: var(--accent);
}

/* Match Card Footer (optional - for competition/time) */
.match-card-footer {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: center;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

/* Goal Scorers */
.match-card-scorers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  margin-top: 0.5rem;
}

.match-card-scorers-home {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.match-card-scorers-away {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.match-card-scorer {
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.3;
}

.match-card-scorer::before {
  content: '⚽';
  margin-right: 0.25rem;
  font-size: 0.75rem;
}

.match-card-scorers-home .match-card-scorer::before {
  margin-right: 0;
  margin-left: 0.25rem;
  order: 2;
}

.match-card-scorers-home .match-card-scorer {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-start;
}

/* Footer */
footer {
  margin-top: auto;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
}

.footer-links {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.75rem;
  transition: color 0.2s;
  white-space: nowrap;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-copyright {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.footer-copyright::before {
  content: '•';
  margin-right: 1rem;
  color: var(--text-tertiary);
}

/* Unified Header Styles */
.unified-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

@supports (padding: max(0px)) {
  .unified-header {
    padding-left: max(0, env(safe-area-inset-left));
    padding-right: max(0, env(safe-area-inset-right));
  }
}

/* Header Bar */
.header-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  min-height: 44px;
}

/* Home Link */
.home-link {
  font-size: 1.5rem;
  text-decoration: none;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  transition: transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.home-link:hover {
  transform: scale(1.1);
}

/* Search Bar Compact */
.search-bar-compact {
  flex: 1;
  display: flex;
  align-items: center;
  max-width: 400px;
  min-width: 180px;
  position: relative;
}

.search-input-container {
  width: 100%;
  background: var(--bg-tertiary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0 2.5rem 0 0.75rem;
  position: relative;
  gap: 0.5rem;
}

.search-input-container .search-icon {
  font-size: 1rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .search-bar-compact {
    max-width: 280px;
    min-width: 150px;
  }
}

@media (max-width: 480px) {
  .search-bar-compact {
    max-width: 200px;
    min-width: 120px;
  }

  .search-input-container {
    padding: 0 2rem 0 0.5rem;
  }
}

.header-search-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.9375rem;
  padding: 0.5rem 0;
  outline: none;
}

.header-search-input::placeholder {
  color: var(--text-tertiary);
}

.search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
  display: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s;
}

.search-clear.visible {
  display: block;
}

.search-clear:hover {
  color: var(--text-primary);
}

/* Search Autocomplete Dropdown */
.search-autocomplete {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 1000;
}

.search-autocomplete.show {
  display: block;
}

.search-autocomplete::-webkit-scrollbar {
  width: 8px;
}

.search-autocomplete::-webkit-scrollbar-track {
  background: transparent;
}

.search-autocomplete::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.search-autocomplete::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s;
  cursor: pointer;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: var(--bg-secondary);
}

.autocomplete-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 4px;
}

.autocomplete-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.autocomplete-name {
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Page Title in Header */
.page-title-container {
  display: none;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.page-title-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.page-title-badge {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}

.page-title-text {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.page-star-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--yellow);
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.page-star-btn:hover {
  transform: scale(1.2);
  filter: brightness(1.3);
}

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

@media (max-width: 768px) {
  .page-title-text {
    font-size: 0.9375rem;
  }

  .page-title-badge {
    width: 20px;
    height: 20px;
  }
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Status Indicator */
.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  flex-shrink: 0;
}

.status-dot.live {
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.offline {
  background: var(--live-pulse);
}

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

@media (max-width: 480px) {
  .status span:not(.status-dot) {
    display: none;
  }
}

/* Favorites Bar in Header */
.favorites-bar-header {
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  padding: 0.5rem 1rem;
  display: none;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.favorites-bar-header.show {
  display: block;
}

.favorites-bar-header::-webkit-scrollbar {
  height: 4px;
}

.favorites-bar-header::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.favorites-bar-header::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.favorites-bar-header::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

.favorites-chips-inline {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
  min-height: 28px;
}

.favorites-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.favorites-chip:hover {
  background: var(--bg-primary);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 255, 136, 0.15);
}

.favorites-chip:active {
  transform: translateY(0);
}

.favorites-chip img {
  width: 14px;
  height: 14px;
  object-fit: contain;
  flex-shrink: 0;
}

.favorites-separator {
  height: 16px;
  width: 1px;
  background: var(--border);
  margin: 0 0.25rem;
  flex-shrink: 0;
}

/* Page-specific Header (for team/league/match pages) */
.page-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.page-header h1 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-header .star-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.375rem;
  color: var(--yellow);
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.page-header .star-btn:hover {
  transform: scale(1.2);
  filter: brightness(1.3);
}

.page-header .star-btn:active {
  transform: scale(0.9);
}

/* Month Navigation (for paginated fixtures) */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.month-nav-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-width: 80px;
}

.month-nav-btn:hover:not(:disabled) {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--bg-primary);
}

.month-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.month-display {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  flex: 1;
}

/* Fixtures List */
.fixtures-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.5rem;
}

.fixture-date-header {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  padding: 1rem 0 0.5rem;
  margin-top: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.fixture-date-header:first-child {
  margin-top: 0;
  padding-top: 0.5rem;
}

/* Form Indicators (for standings tables) */
.standings-table td.form-cell,
.standings-table th.form-cell {
  text-align: center;
  min-width: 100px;
}

.form-badge {
  display: inline-block;
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 3px;
  font-size: 0.625rem;
  font-weight: 700;
  margin: 0 1px;
}

.form-win {
  background: #22c55e;
  color: white;
}

.form-draw {
  background: #eab308;
  color: white;
}

.form-loss {
  background: #ef4444;
  color: white;
}

.form-empty {
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

/* Light mode adjustments */
@media (prefers-color-scheme: light) {
  .form-win {
    background: #16a34a;
  }

  .form-draw {
    background: #ca8a04;
  }

  .form-loss {
    background: #dc2626;
  }
}

/* Standings Table Mobile Wrapper */
.standings-table-wrapper {
  position: relative;
  margin: 0.75rem 0;
}

.standings-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}

/* Mobile optimizations for standings table */
@media (max-width: 768px) {
  /* Hide W/D/L columns on mobile - form shows this info */
  .standings-table th:nth-child(4),
  .standings-table td:nth-child(4),
  .standings-table th:nth-child(5),
  .standings-table td:nth-child(5),
  .standings-table th:nth-child(6),
  .standings-table td:nth-child(6) {
    display: none;
  }

  /* Make form badges smaller */
  .form-badge {
    width: 16px;
    height: 16px;
    line-height: 16px;
    font-size: 0.5625rem;
    margin: 0;
  }

  .form-cell {
    padding: 0.375rem 0.25rem;
    min-width: 80px;
  }

  /* Smaller font for table */
  .standings-table table {
    font-size: 0.75rem;
  }

  /* Add scroll indicator gradient */
  .standings-table-wrapper::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to left, var(--bg-primary), transparent);
    pointer-events: none;
    opacity: 0.8;
  }
}

@media (max-width: 480px) {
  /* Even smaller badges on very small screens */
  .form-badge {
    width: 14px;
    height: 14px;
    line-height: 14px;
    font-size: 0.5rem;
  }

  .form-cell {
    min-width: 70px;
  }

  /* Reduce table padding */
  .standings-table th,
  .standings-table td {
    padding: 0.375rem 0.25rem;
  }

  /* Smaller team name column */
  .standings-table td.team-name-cell,
  .standings-table th.team-name-cell {
    font-size: 0.6875rem;
  }
}

/* Mobile Touch Target Optimizations */
@media (max-width: 768px) {
  /* Ensure minimum 44px touch targets */
  .team-star-btn,
  .league-star-btn,
  .league-hide-btn,
  .page-star-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Match cards - ensure adequate tap area */
  .match-card {
    min-height: 80px;
    padding: 1rem;
  }

  /* Team links in match cards */
  .match-card-team-name {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Favorites chips - larger tap area */
  .favorites-chip {
    padding: 0.5rem 0.75rem;
    min-height: 36px;
  }

  /* Filter button */
  .filter-button {
    min-width: 44px;
    min-height: 44px;
  }

  /* League header buttons */
  .league-header {
    min-height: 48px;
    padding: 0.75rem 0.5rem;
  }

  /* Tab buttons */
  .tab-btn {
    min-height: 48px;
    padding: 0.75rem 1rem;
  }
}

/* ===========================================
   LIVE STANDINGS STYLES
   =========================================== */

/* Live table indicator header */
.live-table-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(0, 255, 136, 0.1);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

.live-table-header-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.live-table-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent);
  color: #000;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
}

.live-table-header-badge .live-dot {
  width: 6px;
  height: 6px;
  background: #000;
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

/* Row styling for teams currently playing */
.standings-row-live {
  background: rgba(0, 255, 136, 0.08) !important;
  border-left: 3px solid var(--accent);
  position: relative;
}

.standings-row-live td:first-child {
  padding-left: calc(0.5rem - 3px);
}

/* Position change indicators */
.position-indicator {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 4px;
}

.position-up {
  color: var(--accent);
}

.position-down {
  color: #ff6b6b;
}

.position-same {
  color: var(--text-secondary);
}

/* Live badge next to team name */
.team-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--accent);
  color: #000;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 6px;
  text-transform: uppercase;
  vertical-align: middle;
}

.team-live-badge .live-dot {
  width: 5px;
  height: 5px;
  background: #000;
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

/* Live score badge showing current match score */
.team-live-score {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  margin-left: 6px;
  padding: 1px 5px;
  background: rgba(0, 255, 136, 0.15);
  border-radius: 3px;
}

/* Points with asterisk for provisional */
.points-provisional {
  position: relative;
}

.points-provisional::after {
  content: '*';
  color: var(--accent);
  font-size: 0.8em;
  margin-left: 1px;
}

/* Live table footer note */
.live-table-note {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.75rem;
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.live-table-note::before {
  content: '*';
  color: var(--accent);
  font-weight: bold;
}

/* Animation for position changes */
@keyframes position-flash {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(0, 255, 136, 0.2); }
}

.position-changed {
  animation: position-flash 0.5s ease-out;
}

/* Responsive adjustments for live table */
@media (max-width: 600px) {
  .live-table-header {
    padding: 0.375rem 0.5rem;
  }

  .live-table-header-text {
    font-size: 0.7rem;
  }

  .team-live-badge {
    font-size: 0.5rem;
    padding: 1px 3px;
  }

  .position-indicator {
    font-size: 0.6rem;
  }

  .live-table-note {
    font-size: 0.65rem;
  }
}
