:root {
  --bg-primary: #0e0e10;
  --bg-secondary: #18181b;
  --bg-tertiary: #1f1f23;
  --text-primary: #efeff1;
  --text-secondary: #adadb8;
  --accent: #9147ff;
  --accent-hover: #772ce8;
  --live: #eb0400;
  --online: #00f593;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --radius: 8px;
  --radius-lg: 12px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px 24px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 100;
}

.header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Buttons */
.btn-icon {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
  transition: background 0.2s;
}

.btn-icon:hover {
  background: var(--bg-tertiary);
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 14px;
}

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

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

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

.btn-toggle {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-toggle.active {
  background: var(--online);
  color: var(--bg-primary);
  border-color: var(--online);
}

.btn-add {
  background: var(--accent);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-add:hover {
  background: var(--accent-hover);
}

.btn-remove {
  background: var(--bg-tertiary);
  color: var(--live);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}

.btn-remove:hover {
  opacity: 1;
  background: rgba(235, 4, 0, 0.2);
}

/* Notifications Section */
.notifications-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 20px;
}

.notification-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notification-toggle span {
  font-weight: 500;
}

.status-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.status-text.enabled {
  color: var(--online);
}

.status-text.error {
  color: var(--live);
}

.btn-test {
  margin-top: 12px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #9147ff, #772ce8);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-test:hover {
  background: linear-gradient(135deg, #772ce8, #5c16c5);
  transform: translateY(-1px);
}

.btn-test:active {
  transform: translateY(0);
}

.btn-test:disabled {
  background: var(--text-secondary);
  cursor: not-allowed;
  opacity: 0.5;
}

/* Search Section */
.search-section {
  margin-bottom: 24px;
}

.search-box {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

#search-input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

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

.results-list {
  list-style: none;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 300px;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}

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

.search-result-item:hover {
  background: var(--bg-tertiary);
}

.result-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 12px;
  object-fit: cover;
}

.result-info {
  flex: 1;
}

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

.result-status {
  font-size: 12px;
  color: var(--text-secondary);
}

.result-status.live {
  color: var(--live);
  font-weight: 600;
}

/* Channels Section */
.channels-section h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

#channel-count {
  font-weight: 400;
  color: var(--text-secondary);
}

.channels-grid {
  display: grid;
  gap: 12px;
}

.channel-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid transparent;
}

.channel-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.channel-card.live {
  border-color: var(--live);
  background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(235, 4, 0, 0.1) 100%);
}

.channel-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.channel-info {
  flex: 1;
  min-width: 0;
}

.channel-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  margin-top: 4px;
}

.live-badge {
  background: var(--live);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
  font-size: 14px;
}

/* Modal / Player */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.player-container {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  background: black;
}

.player-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.modal-actions {
  padding: 16px;
  display: flex;
  gap: 10px;
}

.modal-actions .btn-secondary {
  flex: 1;
}

/* Loading State */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (min-width: 600px) {
  .modal {
    align-items: center;
    padding: 20px;
  }

  .modal-content {
    max-width: 800px;
    border-radius: var(--radius-lg);
    animation: fadeIn 0.2s ease-out;
  }

  @keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

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