/**
 * Spotify Podcast Grid - Frontend Styles
 * Version: 1.0.0
 */

/* ==========================================================================
   Container & Base Styles
   ========================================================================== */

.spg-container {
    margin: 2rem 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}

.spg-error,
.spg-message {
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.spg-error {
    background-color: #fee;
    color: #c00;
    border: 1px solid #fcc;
}

.spg-message {
    background-color: #e8f4f8;
    color: #0073aa;
    border: 1px solid #b5d9ea;
}

/* ==========================================================================
   Grid Layout
   ========================================================================== */

.spg-grid {
    display: grid;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.spg-grid-cols-1 {
    grid-template-columns: 1fr;
}

.spg-grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.spg-grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.spg-grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.spg-grid-cols-5 {
    grid-template-columns: repeat(5, 1fr);
}

.spg-grid-cols-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* Responsive grid */
@media (max-width: 1200px) {
    .spg-grid-cols-5,
    .spg-grid-cols-6 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 992px) {
    .spg-grid-cols-4,
    .spg-grid-cols-5,
    .spg-grid-cols-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .spg-grid-cols-3,
    .spg-grid-cols-4,
    .spg-grid-cols-5,
    .spg-grid-cols-6 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .spg-grid {
        gap: 1.5rem;
    }
}

@media (max-width: 480px) {
    .spg-grid-cols-2,
    .spg-grid-cols-3,
    .spg-grid-cols-4,
    .spg-grid-cols-5,
    .spg-grid-cols-6 {
        grid-template-columns: 1fr;
    }
    
    .spg-grid {
        gap: 1rem;
    }
}

/* ==========================================================================
   Episode Card (Grid Layout)
   ========================================================================== */

.spg-episode-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.spg-episode-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.spg-episode-player {
    width: 100%;
    background: #000;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    line-height: 0;
}

.spg-episode-player iframe {
    display: block;
    width: 100%;
    border: none;
}

.spg-episode-image {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* 1:1 aspect ratio */
    background: #f0f0f0;
    overflow: hidden;
}

.spg-episode-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.spg-episode-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-size: 4rem;
}

.spg-video-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(30, 215, 96, 0.95);
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.spg-video-badge svg {
    width: 14px;
    height: 14px;
}

.spg-episode-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-grow: 1;
}

.spg-episode-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
}

.spg-episode-title a {
    color: #1a1a1a;
    text-decoration: none;
    transition: color 0.2s ease;
}

.spg-episode-title a:hover {
    color: #1db954;
}

.spg-episode-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.875rem;
    color: #666;
}

.spg-meta-date,
.spg-meta-duration {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.spg-episode-description {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #555;
    flex-grow: 1;
}

.spg-player-container {
    margin-top: auto;
}

.spg-video-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: #ff0000;
    color: #fff;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.2s ease;
    cursor: pointer;
    width: 100%;
    text-align: center;
}

.spg-video-link:hover {
    background: #cc0000;
    transform: scale(1.02);
    color: #fff;
}

.spg-video-link svg {
    flex-shrink: 0;
}

.spg-play-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: #1db954;
    color: #fff;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s ease, transform 0.2s ease;
    cursor: pointer;
    width: 100%;
}

.spg-play-toggle:hover {
    background: #1ed760;
    transform: scale(1.02);
}

.spg-play-toggle.spg-active {
    background: #ff6b6b;
}

.spg-play-toggle.spg-active:hover {
    background: #ff5252;
}

.spg-play-toggle svg {
    flex-shrink: 0;
}

.spg-player-embed {
    margin-top: 1rem;
}

.spg-player-embed iframe {
    border-radius: 12px;
}

.spg-spotify-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    color: #666;
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s ease;
    margin-top: 0.5rem;
}

.spg-spotify-link:hover {
    color: #1db954;
}

.spg-spotify-link svg {
    flex-shrink: 0;
}

.spg-listen-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: #1db954;
    color: #fff;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s ease, transform 0.2s ease;
    margin-top: auto;
}

.spg-listen-button:hover {
    background: #1ed760;
    transform: scale(1.02);
    color: #fff;
}

.spg-listen-button svg {
    flex-shrink: 0;
}

/* ==========================================================================
   List Layout
   ========================================================================== */

.spg-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.spg-episode-list-item {
    display: flex;
    gap: 1.5rem;
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
    align-items: flex-start;
}

.spg-episode-list-item:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.spg-episode-list-player {
    position: relative;
    flex-shrink: 0;
    width: 280px;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    line-height: 0;
}

.spg-episode-list-player iframe {
    display: block;
    width: 100%;
    border: none;
}

.spg-episode-list-image {
    position: relative;
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0f0;
}

.spg-episode-list-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.spg-video-badge-small {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(30, 215, 96, 0.95);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.spg-episode-list-content {
    flex-grow: 1;
    min-width: 0; /* Allow text truncation */
}

.spg-episode-list-item .spg-episode-title {
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}

.spg-episode-list-item .spg-episode-meta {
    margin-bottom: 0.75rem;
}

.spg-episode-list-item .spg-episode-description {
    font-size: 0.95rem;
}

.spg-episode-list-action {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.spg-play-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: #1db954;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.spg-play-button:hover {
    background: #1ed760;
    transform: scale(1.1);
}

.spg-play-button.spg-active {
    background: #ff6b6b;
}

.spg-play-button.spg-active:hover {
    background: #ff5252;
}

.spg-play-button svg {
    margin-left: 2px; /* Visual centering */
}

.spg-spotify-link-small {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: #666;
    text-decoration: none;
    transition: color 0.2s ease, transform 0.2s ease;
}

.spg-spotify-link-small:hover {
    color: #1db954;
    transform: scale(1.1);
}

.spg-player-container-list {
    margin-top: 0.5rem;
}

/* Mobile list layout */
@media (max-width: 768px) {
    .spg-episode-list-item {
        flex-direction: column;
        gap: 1rem;
    }
    
    .spg-episode-list-player {
        width: 100%;
    }
    
    .spg-episode-list-action {
        align-self: flex-start;
    }
}

@media (max-width: 480px) {
    .spg-episode-list-item {
        padding: 1rem;
    }
}

/* ==========================================================================
   Loading & Empty States
   ========================================================================== */

.spg-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    font-size: 1.1rem;
    color: #666;
}

.spg-loading::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #1db954;
    border-radius: 50%;
    animation: spg-spin 1s linear infinite;
    margin-right: 0.75rem;
}

@keyframes spg-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.spg-episode-card:focus-within,
.spg-episode-list-item:focus-within {
    outline: 2px solid #1db954;
    outline-offset: 2px;
}

/* Skip to content for screen readers */
.spg-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ==========================================================================
   Dark Mode Support (Optional)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .spg-episode-card,
    .spg-episode-list-item {
        background: #1a1a1a;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .spg-episode-card:hover,
    .spg-episode-list-item:hover {
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    }
    
    .spg-episode-title a {
        color: #fff;
    }
    
    .spg-episode-description {
        color: #ccc;
    }
    
    .spg-episode-meta {
        color: #999;
    }
    
    .spg-episode-placeholder {
        background: linear-gradient(135deg, #444 0%, #666 100%);
    }
}
