/**
 * Streamer page styles
 */

/* Wrapper with sidebar layout */
.streamer-page-wrapper {
    display: flex;
    max-width: 1600px;
    margin: 0 auto;
    gap: 0;
}

/* Full viewport when live - override base.html .container */
.container:has(.streamer-page-wrapper.is-live) {
    max-width: 100%;
    padding: 0;
}

.streamer-page-wrapper.is-live {
    max-width: 100%;
}

/* Sidebar */
.live-sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    height: calc(100vh - 60px);
    position: sticky;
    top: 60px;
    overflow-y: auto;
    flex-shrink: 0;
    transition: width 0.3s ease, min-width 0.3s ease;
}

.live-sidebar.collapsed {
    width: 48px;
    min-width: 48px;
}

.live-sidebar.collapsed .sidebar-title,
.live-sidebar.collapsed .sidebar-count,
.live-sidebar.collapsed .sidebar-wow-filter,
.live-sidebar.collapsed .sidebar-streamers {
    display: none;
}

.live-sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0.75rem 0.5rem;
}

.live-sidebar.collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-count {
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.sidebar-wow-filter {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-left: auto;
}

.sidebar-wow-filter input {
    display: none;
}

.sidebar-wow-filter .wow-icon {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.sidebar-wow-filter input:checked + .wow-icon {
    background: #f59e0b;
    color: #000;
}

.sidebar-streamers {
    padding: 0.5rem 0;
}

.sidebar-streamer {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem;
    text-decoration: none;
    transition: background 0.15s ease;
}

.sidebar-streamer:hover {
    background: var(--bg-tertiary);
}

.sidebar-thumb {
    width: 40px;
    height: 23px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.sidebar-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.sidebar-name {
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-game {
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-viewers {
    color: #ef4444;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.sidebar-viewers::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #ef4444;
    border-radius: 50%;
}

/* Main content area */
.streamer-page {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    min-width: 0;
}

.streamer-page.full-width {
    max-width: 1400px;
}

/* Full viewport when live */
.is-live .streamer-page {
    max-width: 100%;
    padding: 1rem 2rem;
}

/* Chat matches player height when live */
.is-live .twitch-embed-container.with-chat {
    align-items: stretch;
}

.is-live .twitch-chat-wrapper {
    display: flex;
    flex-direction: column;
}

.is-live .twitch-chat {
    flex: 1;
    min-height: unset;
    max-height: unset;
    height: 100%;
}

/* Header */
.streamer-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.back-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.streamer-header h1 {
    color: var(--text-primary);
    margin: 0;
    font-size: 1.8rem;
}

.live-indicator {
    background: #ef4444;
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Twitch Embed */
.twitch-embed-container {
    margin-bottom: 2rem;
}

.twitch-embed-container.with-chat {
    display: flex;
    gap: 1rem;
}

.twitch-player-wrapper {
    flex: 1;
    min-width: 0;
}

.twitch-embed {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background: #000;
    border-radius: 10px;
    overflow: hidden;
}

.twitch-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.stream-details {
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 10px 10px;
}

/* Twitch Chat */
.twitch-chat-wrapper {
    width: 340px;
    min-width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: width 0.3s ease, min-width 0.3s ease;
}

.twitch-chat-wrapper.collapsed {
    width: 48px;
    min-width: 48px;
}

.twitch-chat-wrapper.collapsed .chat-title,
.twitch-chat-wrapper.collapsed .twitch-chat {
    display: none;
}

.twitch-chat-wrapper.collapsed .chat-header {
    justify-content: center;
    padding: 0.75rem 0.5rem;
}

.twitch-chat-wrapper.collapsed .chat-toggle {
    transform: rotate(180deg);
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.chat-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.chat-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-toggle:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.twitch-chat {
    flex: 1;
    min-height: 400px;
    height: calc(56.25vw * 0.6); /* Match player height roughly */
    max-height: 600px;
}

.twitch-chat iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.stream-details.offline {
    text-align: center;
    color: var(--text-secondary);
}

.stream-title {
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

.stream-game {
    color: #9147ff;
    margin: 0;
    font-weight: 500;
}

.twitch-link {
    display: inline-block;
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    background: #9147ff;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.twitch-link:hover {
    background: #772ce8;
}

/* Clips Section */
.clips-section {
    margin-top: 2rem;
}

.clips-section h2 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.clip-count {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 1rem;
}

.clips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.clip-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.clip-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border-color: #9147ff;
}

.clip-thumbnail {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.clip-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.clip-card:hover .clip-thumbnail img {
    transform: scale(1.05);
}

.clip-thumbnail .no-thumbnail {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.clip-thumbnail .duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.clip-thumbnail .views {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.clip-info {
    padding: 0.75rem 1rem 1rem;
}

.clip-info h3 {
    font-size: 0.95rem;
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
}

.clip-info h3 a {
    color: var(--text-primary);
    text-decoration: none;
}

.clip-info h3 a:hover {
    color: #9147ff;
}

.favorite-star, .muted-icon {
    margin-right: 0.25rem;
}

.clip-meta {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin: 0 0 0.5rem 0;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.tag {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.no-clips {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: 10px;
}

/* Error State */
.error-message {
    text-align: center;
    padding: 4rem 2rem;
}

.error-message h2 {
    color: #ef4444;
    margin-bottom: 1rem;
}

.error-message p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.btn-back {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.btn-back:hover {
    background: var(--bg-tertiary);
    border-color: #9147ff;
}

/* Responsive */
@media (max-width: 1100px) {
    .live-sidebar {
        width: 200px;
        min-width: 200px;
    }

    .sidebar-thumb {
        width: 32px;
        height: 18px;
    }

    .sidebar-name {
        font-size: 0.8rem;
    }

    .sidebar-game {
        font-size: 0.7rem;
    }
}

@media (max-width: 900px) {
    .live-sidebar {
        display: none;
    }

    .streamer-page {
        max-width: 100%;
        padding: 1rem;
    }
}

@media (max-width: 1200px) {
    .twitch-chat-wrapper {
        width: 300px;
        min-width: 260px;
    }
}

@media (max-width: 1000px) {
    .twitch-embed-container.with-chat {
        flex-direction: column;
    }

    .twitch-chat-wrapper {
        width: 100%;
        min-width: 100%;
    }

    .twitch-chat-wrapper.collapsed {
        width: 100%;
        min-width: 100%;
        height: 48px;
    }

    .twitch-chat-wrapper.collapsed .chat-header {
        justify-content: flex-start;
        padding: 0.75rem 1rem;
    }

    .twitch-chat {
        min-height: 350px;
        max-height: 450px;
    }
}

@media (max-width: 768px) {
    .streamer-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .streamer-header h1 {
        font-size: 1.4rem;
    }

    .clips-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .twitch-embed {
        border-radius: 0;
    }

    .stream-details {
        border-radius: 0;
    }

    .twitch-chat-wrapper {
        border-radius: 0;
    }

    .twitch-chat {
        min-height: 300px;
        max-height: 400px;
    }
}

@media (max-width: 480px) {
    .streamer-header h1 {
        font-size: 1.25rem;
    }

    .live-indicator {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }

    .stream-title {
        font-size: 0.9rem;
    }

    .stream-game {
        font-size: 0.8rem;
    }

    .stream-viewers {
        font-size: 0.75rem;
    }

    .clips-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .clip-card .clip-info {
        padding: 0.5rem;
    }

    .clip-card .clip-info h3 {
        font-size: 0.8rem;
        line-height: 1.25;
    }

    .clip-card .clip-meta {
        font-size: 0.7rem;
    }

    .twitch-chat {
        min-height: 250px;
        max-height: 350px;
    }
}
