/* global styles and CSS variables */
:root {
  --font-family: 'Rubik', sans-serif;
  --bg-color: #0a0a0a;
  --text-color: #ffffff;
  --text-muted: #aaaaaa;
  --accent: #4caf50;
  --modal-bg: #1e1e1e;
  --header-height: 55px;
  --footer-collapsed: 60px;
  --safe-area-top: env(safe-area-inset-top, 20px);
  --safe-area-bottom: env(safe-area-inset-bottom, 20px);
  --glow-color: rgba(255, 100, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-tap-highlight-color: transparent; }

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

#dynamic-bg {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1;
    transition: background 0.7s ease-in-out;
    background: radial-gradient(circle at 50% 50%, var(--glow-color), transparent 85%), linear-gradient(135deg, #121212 0%, #000 100%);
}

header {
    background: rgba(20, 20, 20, 0.4);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    position: sticky; top: 0; z-index: 100;
    height: calc(var(--header-height) + var(--safe-area-top));
    padding: var(--safe-area-top) 20px 0 20px;
    width: 100%; display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.header-brand { font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; }
.rainbow-text {
    background: linear-gradient(270deg, #ff00cc, #3333ff, #00ccff, #ff00cc);
    background-size: 300% 300%;
    -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: rainbow-move 6s ease infinite;
}
@keyframes rainbow-move { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

@media (min-width: 768px) {
    header { padding: 25px 40px; }
    .header-brand { font-size: 1.8rem; }
}

.round-btn {
    background: rgba(255,255,255,0.1); border: none;
    width: 38px; height: 38px; border-radius: 50%;
    color: white; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s, color 0.3s, text-shadow 0.3s;
}
.round-btn:active { transform: scale(0.9); }

.layout-wrapper { flex: 1; display: flex; overflow: hidden; position: relative; }

main {
    flex: 1; padding: 10px 20px calc(var(--footer-collapsed) + var(--safe-area-bottom) + 20px) 20px;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center; transition: all 0.3s ease;
    min-height: 0; overflow-y: auto;
}
.player-container {
    flex: 1; display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    text-align: center; width: 100%; max-width: 500px; min-height: 0;
}

.cover-art-wrapper {
    flex: 1; min-height: 0; width: 100%;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 25px;
}
.cover-inner {
    position: relative;
    height: clamp(200px, 40vh, 320px);
    width: clamp(200px, 40vh, 320px);
    max-width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
#player-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 20px;
    filter: drop-shadow(0 15px 30px rgba(0,0,0,0.7));
    transition: opacity 0.4s ease-in-out;
    display: block;
}
.station-logo-overlay {
    position: absolute; bottom: 0px; right: 0px; width: 64px; height: 64px;
    border-radius: 14px; background: #000; border: 2px solid rgba(255,255,255,0.15);
    display: none; filter: drop-shadow(0 4px 15px rgba(0,0,0,0.5));
}

#player-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; line-height: 1.25; text-shadow: 0 2px 10px rgba(0,0,0,0.8); }
#player-artist { font-size: 1.05rem; color: rgba(255,255,255,0.6); margin-bottom: 25px; min-height: 1.2em; }
#player-status {
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px;
    color: #fff; background: rgba(255,255,255,0.1);
    padding: 6px 16px; border-radius: 20px; display: inline-block; margin-bottom: 30px;
}

.controls { display: flex; justify-content: center; align-items: center; gap: 25px; }
.play-btn {
    width: 80px; height: 80px; background: #fff; color: #000;
    border-radius: 50%; border: none; font-size: 2.2rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 30px rgba(255,255,255,0.1); transition: transform 0.2s;
}
.play-btn:active { transform: scale(0.94); }
.secondary-ctrl { width: 50px; height: 50px; font-size: 1.1rem; }

#sidebar-stations {
    width: 350px; background: rgba(10, 10, 10, 0.4);
    backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
    border-left: 1px solid rgba(255,255,255,0.05);
    display: none; flex-direction: column;
}
.sidebar-header {
    padding: 22px; font-size: 1.2rem; font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex; justify-content: space-between; align-items: center;
}

footer#main-footer {
    position: fixed; bottom: 0; left: 0; width: 100%;
    background: rgba(15, 15, 15, 0.85);
    backdrop-filter: blur(35px); -webkit-backdrop-filter: blur(35px);
    border-top: 1px solid rgba(255,255,255,0.08);
    z-index: 150; height: calc(var(--footer-collapsed) + var(--safe-area-bottom));
    transition: height 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    overflow: hidden; display: flex; flex-direction: column;
}
footer#main-footer.expanded { height: 80vh; }
.footer-header {
    height: var(--footer-collapsed); display: flex;
    justify-content: center; align-items: center;
    cursor: pointer; color: white; position: relative;
}
.footer-header span:first-child {
    font-size: 1.05rem; font-weight: 700; letter-spacing: 2px; opacity: 0.8;
}
#footer-arrow { position: absolute; right: 25px; font-size: 0.8rem; opacity: 0.5; }

#footer-list-container {
    visibility: hidden; opacity: 0; transition: opacity 0.3s;
    flex: 1; overflow: hidden; display: flex; flex-direction: column;
}
#main-footer.expanded #footer-list-container {
    visibility: visible; opacity: 1;
}

.footer-content, .sidebar-content {
    flex: 1; overflow-y: auto; padding: 15px;
    scrollbar-width: thin;
}
.footer-link-wrapper, .sidebar-footer {
    padding: 15px 20px calc(25px + var(--safe-area-bottom));
}
.manage-btn {
    width: 100%; padding: 15px;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
    color: white; border-radius: 14px; font-weight: 600; cursor: pointer;
}

.station-item {
    display: flex; align-items: center; padding: 12px 16px;
    background: rgba(255,255,255,0.03); border-radius: 14px;
    margin-bottom: 10px; cursor: pointer; border: 1px solid transparent;
    transition: all 0.2s;
}
.station-item.active {
    background: rgba(76, 175, 80, 0.15); border-color: rgba(76, 175, 80, 0.3);
}
.station-logo { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; margin-right: 15px; }
.station-info { flex: 1; font-weight: 600; font-size: 0.95rem; }

@media (min-width: 768px), (orientation: landscape) and (min-height: 480px) {
    #sidebar-stations { display: flex; }
    footer#main-footer { display: none; }
    main { padding: 40px; }

    .controls { gap: 15px; }
    .play-btn { width: 65px; height: 65px; font-size: 1.8rem; }
    .secondary-ctrl { width: 42px; height: 42px; font-size: 0.9rem; }
}

@media (max-width: 800px) and (orientation: landscape) {
    .cover-art-wrapper { margin-bottom: 10px; }
    header { height: 45px; padding-top: var(--safe-area-top); }
    .play-btn { width: 55px; height: 55px; font-size: 1.4rem; }
    .secondary-ctrl { width: 38px; height: 38px; font-size: 0.9rem; }
    #player-status { margin-bottom: 15px; }
}

.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); backdrop-filter: blur(20px); z-index: 200; align-items: center; justify-content: center; padding: 20px; }
.modal-content { background: #1a1a1a; width: 100%; max-width: 420px; border-radius: 28px; padding: 25px; position: relative; max-height: 90vh; overflow-y: auto; border: 1px solid rgba(255,255,255,0.1); }
.modal-close-btn-x { position: absolute; top: 20px; right: 20px; background: rgba(255,255,255,0.1); color: white; border: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; }

.switch-container { display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.04); padding: 14px; border-radius: 14px; margin-bottom: 12px; }
.tabs { display: flex; margin-bottom: 20px; gap: 10px; }
.tab-content { display: block; }
input[type="text"] { width: 100%; padding: 14px; margin-bottom: 10px; background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.1); color: white; border-radius: 12px; font-family: inherit; }
.modal-btn.save { width: 100%; background: var(--accent); color: white; border: none; padding: 14px; border-radius: 12px; font-weight: bold; cursor: pointer; }