/* ===========================================================
   CAMEL STREAM — Xtream Web Player
   Palette: deep charcoal house, marquee-bulb amber, curtain red
   =========================================================== */

:root {
  --bg: #121212;
  --bg-elevated: #1a1a1c;
  --bg-card: #202023;
  --bg-card-hover: #28282c;
  --fg: #f2ede4;
  --fg-muted: #9c968c;
  --accent: #e8b93b;
  --accent-dim: #a9822a;
  --live: #b4303f;
  --border: #34302a;
  --radius: 10px;
  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

/* Several elements below (.modal-overlay, .ticket-nav, .breadcrumb,
   .pagination) set their own `display: flex`, which has the same CSS
   specificity as the browser default `[hidden] { display: none }` rule -
   whichever is declared later in the stylesheet wins. This rule forces
   [hidden] to always win, so toggling the `hidden` attribute in JS always
   actually hides the element. */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  min-height: 100vh;
}

#app {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

/* ---------------- Top bar ---------------- */

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

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-mark {
  color: var(--live);
  font-size: 12px;
  animation: pulse 2.4s ease-in-out infinite;
}

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

.brand h1 {
  font-family: var(--font-display);
  letter-spacing: 4px;
  font-size: 28px;
  margin: 0;
  color: var(--accent);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.active-profile {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ---------------- Buttons ---------------- */

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  border-radius: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--fg);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:hover { background: var(--bg-card-hover); }
.btn:active { transform: scale(0.98); }

.btn-ghost {
  background: transparent;
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1206;
}

.btn-accent:hover { background: #f0c65a; }

/* ---------------- Ticket-stub nav ---------------- */
/* Each tab reads like a torn ticket stub: perforated top/bottom edge via
   repeating radial cutouts, with a dashed tear-line before the label. */

.ticket-nav {
  display: flex;
  gap: 14px;
  margin: 26px 0 6px;
  overflow-x: auto;
}

.ticket {
  position: relative;
  flex: 0 0 auto;
  font-family: var(--font-display);
  letter-spacing: 2px;
  font-size: 18px;
  color: var(--fg-muted);
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 10px 22px;
  cursor: pointer;
  -webkit-mask-image:
    radial-gradient(circle 5px at 0 0, transparent 5px, black 5.5px),
    radial-gradient(circle 5px at 100% 0, transparent 5px, black 5.5px),
    radial-gradient(circle 5px at 0 100%, transparent 5px, black 5.5px),
    radial-gradient(circle 5px at 100% 100%, transparent 5px, black 5.5px);
  mask-image:
    radial-gradient(circle 5px at 0 0, transparent 5px, black 5.5px),
    radial-gradient(circle 5px at 100% 0, transparent 5px, black 5.5px),
    radial-gradient(circle 5px at 0 100%, transparent 5px, black 5.5px),
    radial-gradient(circle 5px at 100% 100%, transparent 5px, black 5.5px);
  transition: color 0.15s, border-color 0.15s;
}

.ticket:hover { color: var(--fg); border-color: var(--accent-dim); }

.ticket.active {
  color: #1a1206;
  background: var(--accent);
  border-color: var(--accent);
}

.ticket-reload {
  margin-left: auto;
  font-size: 16px;
}

/* ---------------- Breadcrumb ---------------- */

.breadcrumb {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 18px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.breadcrumb button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ---------------- Empty / loading states ---------------- */

.empty-state, .loading-state {
  text-align: center;
  padding: 100px 20px;
  color: var(--fg-muted);
}

.marquee-line {
  font-family: var(--font-display);
  font-size: 34px;
  letter-spacing: 3px;
  color: var(--accent);
  margin-bottom: 10px;
}

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

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

/* ---------------- Grid ---------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-top: 10px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.12s, background 0.12s, border-color 0.12s;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-3px);
  background: var(--bg-card-hover);
  border-color: var(--accent-dim);
}

.card-thumb {
  width: 100%;
  aspect-ratio: 2 / 3;
  background: var(--bg-elevated) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3C/svg%3E") center/cover;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--border);
  font-size: 28px;
  overflow: hidden;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card.card-channel .card-thumb {
  aspect-ratio: 16 / 9;
}

.card-body {
  padding: 10px 12px;
}

.card-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tag {
  display: inline-block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--live);
  text-transform: uppercase;
}

/* Category cards look a touch different: no thumb art, just a title tile */
.card-category {
  aspect-ratio: unset;
}
.card-category .card-body {
  padding: 26px 16px;
  text-align: center;
}
.card-category .card-name {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 1px;
  -webkit-line-clamp: 3;
}

/* ---------------- Search ---------------- */

.search-bar {
  display: flex;
  gap: 10px;
  margin: 10px 0 6px;
}

.search-bar input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--accent-dim);
}

/* ---------------- Pagination ---------------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 28px;
}

.page-indicator {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
}

/* ---------------- Modals ---------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 8, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}

.modal-player { max-width: 900px; }

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

.modal-header h2 {
  font-family: var(--font-display);
  letter-spacing: 1px;
  font-size: 20px;
  margin: 0;
  color: var(--accent);
}

.modal-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 16px;
  cursor: pointer;
}
.modal-close:hover { color: var(--fg); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

/* Profile list */

.profile-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
}

.profile-list li.active {
  border-color: var(--accent);
}

.profile-list .profile-info {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  flex: 1;
}

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

.profile-list .profile-url {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
}

.profile-list .btn-delete {
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 14px;
}
.profile-list .btn-delete:hover { color: var(--live); }

/* Add profile form */

.add-profile summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 12px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form input, .form select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  text-transform: none;
  letter-spacing: normal;
}

.form input:focus, .form select:focus {
  outline: none;
  border-color: var(--accent-dim);
}

.form-status {
  font-size: 12px;
  color: var(--fg-muted);
  min-height: 16px;
}

/* Player */

.player-body {
  padding: 0;
}

.player-body video {
  width: 100%;
  max-height: 60vh;
  background: #000;
  display: block;
}

.player-hint {
  padding: 12px 20px;
  font-size: 12px;
  color: var(--fg-muted);
  margin: 0;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 560px) {
  .brand h1 { font-size: 22px; }
  .marquee-line { font-size: 24px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
