:root {
    --bg-base: #121212;
    --bg-surface: #1e1e1e;
    --bg-surface-hover: #2c2c2c;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #1db954;
    --accent-hover: #1ed760;
    --border: #333333;
    --radius: 8px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    overflow: hidden; /* App takes full screen */
}

.app-container {
    display: grid;
    grid-template-areas: 
        "sidebar main details"
        "player player player";
    grid-template-columns: 240px 1fr 300px;
    grid-template-rows: 1fr 90px;
    height: 100vh;
}

/* Base styles for hiding details panel when empty */
.app-container.no-details {
    grid-template-columns: 240px 1fr 0px;
}

.sidebar {
    grid-area: sidebar;
    background-color: var(--bg-base);
    border-right: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    min-height: 0;
}

.logo h1 {
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 30px;
}

nav ul {
    list-style: none;
}

nav li {
    padding: 10px;
    cursor: pointer;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: background 0.2s, color 0.2s;
}

nav li:hover, nav li.active {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

.main-content {
    grid-area: main;
    background: linear-gradient(to bottom, #1f1f1f, var(--bg-base));
    padding: 30px;
    overflow-y: auto;
    min-height: 0;
}

header h2 {
    font-size: 2rem;
    margin-bottom: 20px;
}

.header-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input, .lang-select {
    padding: 10px 15px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--bg-surface);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s;
}

.search-input {
    flex: 1;
    min-width: 200px;
}

.search-input:focus, .lang-select:focus {
    border-color: var(--accent);
    background-color: var(--bg-surface-hover);
}

.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.podcast-card {
    background-color: var(--bg-surface);
    padding: 15px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}

.podcast-card:hover {
    background-color: var(--bg-surface-hover);
}

.podcast-card img {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius);
    margin-bottom: 15px;
    object-fit: cover;
}

.podcast-card h3 {
    font-size: 1rem;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.podcast-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hidden {
    display: none !important;
}

.btn {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn.primary {
    background-color: var(--accent);
    color: #000;
    border: none;
    font-weight: 600;
}

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

#back-to-podcasts {
    margin-bottom: 20px;
}

.episode-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.episode-item:hover {
    background-color: var(--bg-surface);
}

.episode-item.active {
    background-color: var(--bg-surface-hover);
    border-left: 3px solid var(--accent);
    padding-left: 12px; /* Adjusted for border */
}

.episode-info h4 {
    font-size: 1rem;
    margin-bottom: 5px;
}

.episode-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.details-panel {
    grid-area: details;
    background-color: var(--bg-base);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 15px 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

.tab-btn.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

.panel-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.tab-content {
    display: none;
    flex-direction: column;
    gap: 15px;
    height: 100%;
    min-height: 0;
}

.tab-content.active {
    display: flex;
}

.chapters-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 5px;
}

#transcript-text, #chapters-list {
    overflow-y: auto;
    flex: 1;
    padding-right: 5px;
}



.transcript-segment {
    margin-bottom: 12px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    transition: background 0.2s, color 0.2s;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.transcript-segment:hover {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

.transcript-segment.active {
    background-color: var(--bg-surface-hover);
    color: var(--accent);
    font-weight: 500;
}

.segment-time-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 65px;
    padding-top: 2px;
}

.segment-play-icon {
    font-size: 0.6rem;
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    transform: translateX(-4px);
}

.transcript-segment:hover .segment-play-icon, .transcript-segment.active .segment-play-icon {
    opacity: 1;
    transform: translateX(0);
}

.segment-time {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--accent);
    opacity: 0.8;
}

.segment-text {
    line-height: 1.5;
}

.clickable-timestamp {
    color: var(--accent);
    cursor: pointer;
    font-family: monospace;
    padding: 2px 4px;
    border-radius: 4px;
    background-color: rgba(29, 185, 84, 0.1);
    transition: background 0.2s;
}

.clickable-timestamp:hover {
    background-color: var(--accent);
    color: #000;
}

.raw-transcript-container {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
    font-size: 0.95rem;
}

.player {
    grid-area: player;
    background-color: #181818;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
}

.player-info {
    display: flex;
    align-items: center;
    width: 30%;
}

.player-info img {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    margin-right: 15px;
}

.player-text {
    overflow: hidden;
}

.player-title {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.player-controls {
    width: 40%;
    display: flex;
    justify-content: center;
}

audio {
    width: 100%;
    height: 40px;
}

@media (max-width: 768px) {
    .app-container {
        grid-template-areas: 
            "main"
            "player";
        grid-template-columns: 1fr;
    }
    .sidebar, .details-panel {
        display: none;
    }
}

/* Animación de carga para botones */
.loading-pulse {
    animation: pulse 1.5s infinite;
    pointer-events: none;
    opacity: 0.8;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); background-color: var(--accent-hover); }
    100% { transform: scale(1); }
}
