/* ============================================================
   Radio Ultra – stylesheet
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f4f5fa;
  --surface:  #ffffff;
  --surface2: #f0f1f8;
  --border:   #e2e4f0;
  --accent:   #7c3aed;
  --accent2:  #9333ea;
  --text:     #1e1e2e;
  --muted:    #6b7280;
  --green:    #16a34a;
  --red:      #dc2626;
  --radius:   12px;
  --player-h: 72px;
}

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}

/* ── HEADER ── */
.site-header {
  background: linear-gradient(135deg, #ffffff 0%, #f5f3ff 100%);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.header-inner { max-width: 1200px; margin: auto; }
.logo-area {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
.logo-icon { font-size: 2rem; }
h1 { font-size: 1.4rem; font-weight: 700; color: var(--accent2); }
.tagline { font-size: .8rem; color: var(--muted); }

.header-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

#search {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 24px;
  padding: 8px 16px;
  font-size: .9rem;
  width: 220px;
  outline: none;
  transition: border-color .2s;
}
#search:focus { border-color: var(--accent); }

.genre-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: .8rem;
  cursor: pointer;
  transition: all .2s;
}
.chip:hover, .chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── STICKY PLAYER ── */
.sticky-player {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--player-h);
  background: linear-gradient(90deg, #ffffff, #f8f7ff);
  border-top: 1px solid var(--border);
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
}
.player-inner {
  max-width: 1200px; margin: auto;
  height: 100%;
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
}
.player-logo {
  width: 44px; height: 44px; flex-shrink: 0; position: relative;
}
.player-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 6px; }

.player-info { flex: 1; min-width: 0; }
.player-name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-meta  { display: block; font-size: .78rem; color: var(--accent2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.player-controls { display: flex; align-items: center; gap: 12px; }
.btn-play-main, .btn-stop {
  width: 40px; height: 40px; border-radius: 50%;
  border: none; cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.btn-play-main { background: var(--accent); color: #fff; }
.btn-stop      { background: var(--surface2); color: var(--muted); }
.btn-play-main:hover, .btn-stop:hover { transform: scale(1.1); }

.btn-wake {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); cursor: pointer;
  background: var(--surface2); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.btn-wake svg { width: 18px; height: 18px; }
.btn-wake:hover { border-color: var(--accent); }
.btn-wake.active { background: rgba(124,58,237,.25); border-color: var(--accent); color: #fff; }

.volume-wrap { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
#volume { accent-color: var(--accent); width: 80px; cursor: pointer; }

/* ── MAIN / GRID ── */
.main-content {
  max-width: 1200px; margin: 24px auto; padding: 0 20px;
  padding-bottom: calc(var(--player-h) + 24px);
}
.station-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* ── STATION CARD ── */
.station-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  cursor: pointer;
  transition: transform .15s, border-color .2s, box-shadow .2s;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.station-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(124,58,237,.15);
}
.station-card.playing {
  border-color: var(--accent2);
  box-shadow: 0 0 0 2px var(--accent), 0 8px 20px rgba(124,58,237,.18);
}
.station-card.offline { opacity: .6; }

.card-logo {
  width: 64px; height: 64px; position: relative; align-self: center;
}
.card-logo img {
  width: 100%; height: 100%; object-fit: contain; border-radius: 8px;
}
.logo-fallback {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  font-weight: 700; font-size: 1.3rem; color: #fff;
}
.status-dot {
  position: absolute; bottom: 0; right: 0;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--surface);
}
.dot-green { background: var(--green); }
.dot-red   { background: var(--red); }

.card-info { flex: 1; }
.card-info h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.genre-tag {
  display: inline-block; font-size: .72rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 10px; color: var(--muted);
}
.meta-text {
  margin-top: 6px; font-size: .78rem; color: var(--accent2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.btn-card-play {
  align-self: flex-end;
  background: var(--accent); color: #fff;
  border: none; border-radius: 50%;
  width: 36px; height: 36px; font-size: .9rem;
  cursor: pointer; transition: background .2s, transform .15s;
}
.btn-card-play:hover { background: var(--accent2); transform: scale(1.1); }

.no-results { text-align: center; color: var(--muted); padding: 40px; }

/* ── FOOTER ── */
.site-footer {
  text-align: center; font-size: .8rem; color: var(--muted);
  padding: 12px 0 calc(var(--player-h) + 16px);
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); }

/* ── ADMIN GLOBAL ── */
.admin-wrap { max-width: 960px; margin: 40px auto; padding: 0 20px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.admin-header h1 { color: var(--accent2); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: 8px; font-size: .9rem; font-weight: 500; cursor: pointer; text-decoration: none; border: none; transition: all .2s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-danger  { background: #7f1d1d; color: #fca5a5; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); }

table.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
table.admin-table th { background: var(--surface2); padding: 12px 16px; text-align: left; font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
table.admin-table td { padding: 12px 16px; border-top: 1px solid var(--border); font-size: .9rem; vertical-align: middle; }
table.admin-table tr:hover td { background: rgba(124,58,237,.07); }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: .95rem; outline: none;
  transition: border-color .2s;
}
.form-control:focus { border-color: var(--accent); }
.form-hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.card-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: .9rem; }
.alert-success { background: rgba(34,197,94,.15); border: 1px solid rgba(34,197,94,.4); color: #86efac; }
.alert-error   { background: rgba(239,68,68,.15);  border: 1px solid rgba(239,68,68,.4);  color: #fca5a5; }

.badge { display: inline-block; border-radius: 20px; padding: 2px 10px; font-size: .75rem; }
.badge-green { background: rgba(34,197,94,.2); color: #86efac; }
.badge-red   { background: rgba(239,68,68,.2);  color: #fca5a5; }
.badge-gray  { background: var(--surface2); color: var(--muted); }

.stream-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
.stream-row .form-control { flex: 1; }
.btn-rm { background: #7f1d1d; color: #fca5a5; border: none; border-radius: 6px; padding: 8px 12px; cursor: pointer; }
.btn-rm:hover { background: var(--red); color: #fff; }
#addStreamBtn { margin-top: 6px; }

/* LOGIN */
.login-wrap { max-width: 360px; margin: 100px auto; padding: 0 20px; }
.login-wrap h1 { color: var(--accent2); margin-bottom: 28px; }

/* Responsive */
@media (max-width: 600px) {
  .station-grid { grid-template-columns: 1fr 1fr; }
  #volume { width: 60px; }
  .genre-filter { display: none; }
}
@media (max-width: 400px) {
  .station-grid { grid-template-columns: 1fr; }
}


/* Chromecast / Google Cast */
.btn-cast {
  display: none;
  width: 42px;
  height: 42px;
  min-width: 42px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: #fff;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.btn-cast:hover {
  background: rgba(255,255,255,.16);
}

google-cast-launcher.btn-cast {
  --connected-color: #fff;
  --disconnected-color: #fff;
}


/* Tvinga Chromecast-knappen att synas */
.btn-cast {
  display: inline-flex !important;
  position: relative;
  font-size: 0;
}

.btn-cast::before {
  content: "📺";
  font-size: 22px;
  line-height: 1;
  display: block;
}


/* Fast Cast-knapp som alltid syns */
.cast-floating {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 99999;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  background: rgba(15,15,26,.92);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(0,0,0,.35);
}

.cast-floating:hover {
  background: rgba(35,35,55,.96);
}


/* CAST FIX FINAL - endast nere i spelaren */
.cast-floating {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

google-cast-launcher.btn-cast {
  display: none !important;
}

#stickyPlayer #btnCast,
.player-controls #btnCast,
button#btnCast.btn-cast {
  display: inline-flex !important;
  position: static !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  transform: none !important;
  width: 42px !important;
  height: 42px !important;
  min-width: 42px !important;
  margin: 0 !important;
  padding: 8px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: rgba(255,255,255,.10) !important;
  color: #fff !important;
  cursor: pointer !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 21px !important;
  line-height: 1 !important;
  box-shadow: none !important;
}

#stickyPlayer #btnCast::before,
.player-controls #btnCast::before,
button#btnCast.btn-cast::before {
  content: none !important;
}

#stickyPlayer #btnCast:hover,
.player-controls #btnCast:hover,
button#btnCast.btn-cast:hover {
  background: rgba(255,255,255,.18) !important;
}


/* Android-app download card */
.android-app-card {
  max-width: 1120px;
  margin: 18px auto 22px;
  padding: 18px;
  display: flex;
  gap: 16px;
  align-items: center;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 22px;
  background:
    radial-gradient(circle at top left, rgba(255,204,51,.22), transparent 34%),
    linear-gradient(135deg, rgba(29,29,45,.96), rgba(16,16,26,.96));
  box-shadow: 0 18px 45px rgba(0,0,0,.28);
}

.android-app-icon {
  width: 64px;
  height: 64px;
  min-width: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  background: rgba(255,255,255,.10);
  font-size: 34px;
}

.android-app-content {
  flex: 1;
}

.android-app-kicker {
  color: #ffcc33;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 4px;
}

.android-app-card h2 {
  margin: 0 0 6px;
  color: #fff;
  font-size: 24px;
  line-height: 1.15;
}

.android-app-card p {
  margin: 0;
  color: rgba(255,255,255,.78);
  line-height: 1.5;
}

.android-app-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.android-app-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  background: #ffcc33;
  color: #171717;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 10px 25px rgba(255,204,51,.24);
}

.android-app-download:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.android-app-note {
  color: rgba(255,255,255,.62);
  font-size: 13px;
}

.android-app-warning {
  margin-top: 10px !important;
  font-size: 13px;
  color: rgba(255,255,255,.58) !important;
}

@media (max-width: 720px) {
  .android-app-card {
    margin: 12px 12px 18px;
    align-items: flex-start;
  }

  .android-app-icon {
    width: 50px;
    height: 50px;
    min-width: 50px;
    font-size: 28px;
    border-radius: 16px;
  }

  .android-app-card h2 {
    font-size: 20px;
  }

  .android-app-download {
    width: 100%;
  }
}
