/* Общие стили */
:root {
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #252525;
  --text-primary: #f0f0f0;
  --text-secondary: #b0b0b0;
  --accent: #4caf50;
  --accent-hover: #45a049;
  --error: #f44336;
  --border-radius: 12px;
  --spacing: 1rem;
  --font-main: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Header */
header {
  background-color: var(--bg-secondary);
  padding: var(--spacing);
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
}

/* Поиск */
.search-container {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

#search-input {
  padding: 0.6rem 1rem;
  font-size: 1rem;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid #444;
  border-radius: var(--border-radius);
  width: 220px;
  outline: none;
  transition: border-color 0.2s;
}

#search-input:focus {
  border-color: var(--accent);
}

#search-input::placeholder {
  color: var(--text-secondary);
}

#search-button {
  background-color: var(--accent);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 600;
  transition: background-color 0.2s;
}

#search-button:hover {
  background-color: var(--accent-hover);
}

/* Вкладки */
nav {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

nav button {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid #444;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.2s;
}

nav button:hover {
  background-color: #2c2c2c;
}

nav button.active {
  background-color: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Основной контент */
main {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing);
}

#channel-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
  justify-content: center;
}

.channel-item {
  background-color: var(--bg-secondary);
  padding: 1rem;
  border-radius: var(--border-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.channel-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.channel-item img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 0.75rem;
  background-color: var(--bg-tertiary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.channel-item h3 {
  margin: 0.5rem 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}

.channel-item p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0;
  min-height: 1.2em;
}

.channel-item button.play {
  background-color: var(--accent);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  cursor: pointer;
  margin-top: 0.75rem;
  border-radius: var(--border-radius);
  font-weight: 600;
  width: 100%;
  transition: background-color 0.2s;
}

.channel-item button.play:hover {
  background-color: var(--accent-hover);
}

.channel-item button.favorite {
  background-color: #ff9800;
  color: white;
  border: none;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  margin-top: 0.5rem;
  border-radius: var(--border-radius);
  font-size: 0.85rem;
  font-weight: 600;
  width: 100%;
  transition: background-color 0.2s;
}

.channel-item button.favorite:hover {
  background-color: #f57c00;
}

.channel-item button.favorite.in-favorite {
  background-color: #4caf50;
}

.channel-item button.favorite.in-favorite:hover {
  background-color: #45a049;
}

/* Плеер */
#player {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

#player.hidden {
  display: none;
}

#player-title {
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
  text-align: center;
  max-width: 90%;
}

#player-container {
  width: 100%;
  max-width: 1000px;
  aspect-ratio: 16 / 9;
  background-color: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

#player-container video,
#player-container audio {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#error-message {
  color: var(--error);
  background-color: rgba(0, 0, 0, 0.7);
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  text-align: center;
  max-width: 90%;
  font-size: 1.1rem;
}

#close-player {
  background-color: var(--bg-tertiary);
  color: white;
  border: none;
  padding: 0.6rem 1.5rem;
  margin-top: 1.25rem;
  cursor: pointer;
  border-radius: var(--border-radius);
  font-size: 1.1rem;
  font-weight: 600;
  transition: background-color 0.2s;
}

#close-player:hover {
  background-color: #333;
}

.hidden {
  display: none !important;
}

/* Адаптивность */
@media (max-width: 600px) {
  :root {
    --spacing: 0.75rem;
  }

  h1 {
    font-size: 1.4rem;
  }

  #channel-list {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
  }

  .channel-item img {
    width: 60px;
    height: 60px;
  }

  .channel-item h3 {
    font-size: 0.95rem;
  }

  .channel-item button.favorite,
  .channel-item button.play {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }

  #search-input,
  #search-button {
    width: 100%;
    max-width: 280px;
  }

  .search-container {
    flex-direction: column;
    align-items: center;
  }

  #player-container {
    height: 45vh;
    aspect-ratio: auto;
  }

  #player-title {
    font-size: 1.3rem;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  #channel-list {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .channel-item button.favorite,
  .channel-item button.play {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }
}

@media (min-width: 1024px) {
  #channel-list {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  .channel-item button.favorite,
  .channel-item button.play {
    padding: 0.5rem 1.2rem;
    font-size: 1rem;
  }
}

/* Для больших экранов (Smart TV, 4K) */
@media (min-width: 1400px) {
  #channel-list {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }

  .channel-item img {
    width: 100px;
    height: 100px;
  }

  .channel-item h3 {
    font-size: 1.2rem;
  }

  nav button,
  #search-button,
  #search-input {
    font-size: 1.1rem;
    padding: 0.7rem 1.4rem;
  }

  #player-container {
    max-width: 1200px;
  }

  .channel-item button.favorite,
  .channel-item button.play {
    padding: 0.6rem 1.4rem;
    font-size: 1.1rem;
  }
}
