/* ============================================
   RADIO DIRECTORY — Design System
   ============================================ */

/* Google Fonts loaded in HTML:
   DM Sans (500;700) + Inter (400;500) */

/* ---------- TOKENS ---------- */
:root {
    /* Palette — Signal Coral */
    --color-accent: #E8553A;
    --color-accent-hover: #D04428;
    --color-accent-soft: rgba(232, 85, 58, 0.08);
    --color-accent-muted: rgba(232, 85, 58, 0.15);

    /* Surfaces */
    --color-bg: #FAFAFA;
    --color-surface: #FFFFFF;
    --color-surface-hover: #F5F5F5;
    --color-surface-active: #EEEEEE;

    /* Borders */
    --color-border: #E0E0E0;
    --color-border-light: #F0F0F0;

    /* Text */
    --color-text: #1A1A1A;
    --color-text-secondary: #757575;
    --color-text-tertiary: #9E9E9E;

    /* Feedback */
    --color-success: #2E7D32;
    --color-live: #E8553A;

    /* Typography */
    --font-heading: 'DM Sans', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Spacing (8pt grid) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;

    /* Layout */
    --sidebar-width: 248px;
    --header-height: 56px;
    --player-height: 72px;
    --radius: 2px;
    --radius-pill: 100px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-player: 0 -1px 8px rgba(0, 0, 0, 0.06);

    /* Transitions */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;
}

/* ---------- RESET ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--color-text);
    background: var(--color-bg);
    overflow: hidden;
    line-height: 1.5;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
    cursor: pointer;
}

ul,
ol {
    list-style: none;
}

img {
    display: block;
    max-width: 100%;
}

/* Screen-reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.hidden {
    display: none !important;
}

/* ---------- APP SHELL ---------- */
.app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border-light);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
    transition: transform var(--duration-slow) var(--ease-out);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-4);
    border-bottom: 1px solid var(--color-border-light);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-heading);
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--color-text);
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: var(--color-accent);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.875rem;
}

.logo-img {
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    object-fit: cover;
}

.nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) var(--space-3);
}

.nav-section {
    margin-bottom: var(--space-5);
}

.nav-title {
    font-family: var(--font-heading);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-tertiary);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-1);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    color: var(--color-text-secondary);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-link:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.nav-link:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

.nav-link[aria-selected="true"] {
    background: var(--color-accent-soft);
    color: var(--color-accent);
    font-weight: 700;
}

.nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: var(--space-4);
    border-top: 1px solid var(--color-border-light);
    margin-top: auto;
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 0;
    margin-bottom: var(--space-3);
    padding: 0 var(--space-3);
}

.footer-link {
    display: flex;
    align-items: center;
    color: var(--color-text-tertiary);
    font-size: 0.6875rem;
    font-weight: 500;
    transition: color var(--duration-fast) var(--ease-out);
}

.footer-link:not(:last-child)::after {
    content: "•";
    margin: 0 8px;
    color: var(--color-border);
    font-size: 0.5rem;
    pointer-events: none;
}

.footer-link:hover {
    color: var(--color-text-secondary);
}

.footer-text {
    font-size: 0.625rem;
    color: var(--color-text-tertiary);
    line-height: 1.5;
    padding: 0 var(--space-3);
    opacity: 0.8;
}

/* ---------- MAIN ---------- */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ---------- HEADER ---------- */
.header {
    height: var(--header-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    padding: 0 var(--space-5);
    gap: var(--space-4);
    flex-shrink: 0;
}

.menu-toggle {
    display: none;
    width: 36px;
    height: 36px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-text);
    transition: background var(--duration-fast);
}

.menu-toggle:hover {
    background: var(--color-surface-hover);
}

.menu-toggle:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

.search {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-tertiary);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: var(--space-2) var(--space-4) var(--space-2) 36px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: 0.8125rem;
    background: var(--color-bg);
    color: var(--color-text);
    transition: all var(--duration-fast) var(--ease-out);
}

.search-input::placeholder {
    color: var(--color-text-tertiary);
}

.search-input:focus {
    outline: none;
    border-color: var(--color-accent);
    background: var(--color-surface);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}

/* ---------- CONTENT ---------- */
.content {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.content-header {
    padding: var(--space-5);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border-light);
}

.content-title {
    font-family: var(--font-heading);
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-1);
    color: var(--color-text);
}

.content-subtitle {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
}

/* ---------- RADIO LIST ---------- */
.radio-list {
    background: var(--color-surface);
}

.list-header {
    display: grid;
    grid-template-columns: 40px 1fr 120px 180px 56px;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-5);
    font-family: var(--font-heading);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-tertiary);
    border-bottom: 1px solid var(--color-border-light);
    position: sticky;
    top: 0;
    background: var(--color-surface);
    z-index: 10;
}

.radio-item {
    display: grid;
    grid-template-columns: 40px 1fr 120px 180px 56px;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-2) var(--space-5);
    border-bottom: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out);
}

.radio-item:hover {
    background: var(--color-surface-hover);
}

.radio-item:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

.radio-item[aria-current="true"] {
    background: var(--color-accent-soft);
}

.item-number {
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-tertiary);
    font-variant-numeric: tabular-nums;
}

.item-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.item-cover {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    background: var(--color-surface-hover);
}

.item-cover .item-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-cover .item-cover-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.item-details {
    min-width: 0;
    flex: 1;
}

.item-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.8125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.item-desc {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 1px;
}

.item-genre,
.item-location {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-genre {
    font-weight: 500;
}

.item-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--duration-fast);
}

.radio-item:hover .item-actions {
    opacity: 1;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: all var(--duration-fast);
}

.btn-icon:hover {
    background: var(--color-surface-active);
    color: var(--color-text);
}

.btn-icon:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

/* ---------- PLAYER ---------- */
.player {
    height: var(--player-height);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-player);
    display: grid;
    grid-template-columns: 260px 1fr 160px;
    align-items: center;
    padding: 0 var(--space-5);
    gap: var(--space-4);
    flex-shrink: 0;
    z-index: 50;
}

.player-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
    overflow: hidden;
}

.player-cover {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    background: var(--color-surface-hover);
}

.player-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-details {
    min-width: 0;
    flex: 1;
}

.player-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.8125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.player-meta {
    font-size: 0.6875rem;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 1px;
}

.player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
}

.player-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: all var(--duration-fast) var(--ease-out);
}

.player-btn:hover {
    color: var(--color-text);
    transform: scale(1.1);
}

.player-btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.player-btn:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none;
}

.player-btn-primary {
    width: 36px;
    height: 36px;
    background: var(--color-accent);
    color: white;
}

.player-btn-primary:hover:not(:disabled) {
    background: var(--color-accent-hover);
    transform: scale(1.08);
}

.player-volume {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    justify-self: end;
}

.volume-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-tertiary);
    cursor: pointer;
    transition: color var(--duration-fast);
    flex-shrink: 0;
}

.volume-btn:hover {
    color: var(--color-text);
}

.volume-slider {
    width: 100px;
    height: 4px;
    border-radius: 2px;
    background: var(--color-border);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    outline: none;
    --fill: 70%;
    background: linear-gradient(to right, var(--color-accent) var(--fill), var(--color-border) var(--fill));
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-accent);
    border: none;
    transition: transform var(--duration-fast);
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-accent);
    border: none;
}

.volume-slider::-moz-range-track {
    background: transparent;
}

.volume-slider:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* ---------- EMPTY STATE ---------- */
.empty {
    padding: var(--space-8) var(--space-5);
    text-align: center;
    color: var(--color-text-secondary);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    opacity: 0.4;
}

.empty h3 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text);
    margin-bottom: var(--space-2);
}

.empty p {
    font-size: 0.8125rem;
}

/* ---------- MOBILE OVERLAY ---------- */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-normal) var(--ease-out);
}

.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-tertiary);
}

/* ---------- PAGINATION ---------- */
.pagination-footer {
    display: flex;
    justify-content: center;
    padding: var(--space-8) var(--space-5);
    margin-top: var(--space-4);
}

.btn-load-more {
    padding: var(--space-3) var(--space-10);
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-pill);
    color: var(--color-text);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    box-shadow: var(--shadow-sm);
}

.btn-load-more:hover:not(:disabled) {
    background: var(--color-surface-hover);
    border-color: var(--color-accent);
    color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-load-more:active:not(:disabled) {
    transform: translateY(0);
}

.btn-load-more:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.list-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.list-loader .spin {
    color: var(--color-accent);
}

/* ---------- ANIMATIONS ---------- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 0.8s linear infinite;
}

.radio-item {
    animation: fadeIn var(--duration-normal) var(--ease-out) both;
}

/* Stagger via JS — fallback without */
.radio-item:nth-child(1) {
    animation-delay: 0ms;
}

.radio-item:nth-child(2) {
    animation-delay: 30ms;
}

.radio-item:nth-child(3) {
    animation-delay: 60ms;
}

.radio-item:nth-child(4) {
    animation-delay: 90ms;
}

.radio-item:nth-child(5) {
    animation-delay: 120ms;
}

.radio-item:nth-child(6) {
    animation-delay: 150ms;
}

.radio-item:nth-child(7) {
    animation-delay: 180ms;
}

.radio-item:nth-child(8) {
    animation-delay: 210ms;
}

.radio-item:nth-child(9) {
    animation-delay: 240ms;
}

.radio-item:nth-child(10) {
    animation-delay: 270ms;
}

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
    .list-header {
        grid-template-columns: 40px 1fr 56px;
    }

    .radio-item {
        grid-template-columns: 40px 1fr 56px;
    }

    .item-genre,
    .item-location {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
        z-index: 100;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
    }

    .menu-toggle {
        display: flex;
    }

    .list-header {
        grid-template-columns: 40px 1fr 56px;
    }

    .radio-item {
        grid-template-columns: 40px 1fr 56px;
    }

    .item-genre,
    .item-location {
        display: none;
    }

    .item-actions {
        opacity: 1;
    }

    body {
        overflow-x: hidden;
        overflow-y: auto;
        height: auto;
    }

    .app {
        height: auto;
        min-height: 100dvh;
        display: block;
        padding-bottom: 64px;
        /* Space for fixed player */
    }

    .main {
        display: block;
        height: auto;
        overflow: visible;
    }

    .content {
        overflow: visible;
    }

    .player {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        padding: 0 var(--space-4);
        gap: var(--space-3);
        grid-template-columns: 1fr auto;
        border-top: 1px solid var(--color-border-light);
        background: var(--color-surface);
        z-index: 110;
        box-shadow: var(--shadow-player);
    }

    /* Prevent accidental zoom on mobile */
    .btn-icon,
    .player-btn,
    .nav-link,
    .radio-item,
    .btn-load-more,
    .logo,
    .menu-toggle {
        touch-action: manipulation;
    }

    .search-input,
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px !important;
        /* Prevent iOS zoom-on-focus */
    }

    .player-info {
        min-width: 0;
    }

    .player-cover {
        width: 40px;
        height: 40px;
    }

    .player-volume {
        display: none;
    }

    .player-controls {
        gap: var(--space-2);
    }

    .player-btn {
        width: 28px;
        height: 28px;
    }

    .player-btn-primary {
        width: 32px;
        height: 32px;
    }

    .header {
        padding: 0 var(--space-3);
        gap: var(--space-3);
    }

    .content-header {
        padding: var(--space-4) var(--space-3);
    }

    .content-title {
        font-size: 1.125rem;
    }

    .sidebar-footer {
        padding-bottom: 80px;
        /* Altura do player (64px) + margin de respiro */
    }
}

@media (max-width: 480px) {
    .radio-item {
        grid-template-columns: 1fr;
        padding: var(--space-3) var(--space-4);
        min-height: 56px;
    }

    .item-number {
        display: none;
    }

    .item-actions {
        display: none;
    }

    .list-header {
        display: none;
    }

    .item-info {
        pointer-events: none;
    }

    .radio-item {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.05);
    }
}