/* ================================
   CBS AKADEMİ - STYLES
   Apple Frosted Glass Design System
   Sade, zarif, 3D abartısı olmayan canlı cam tasarımı
   Dengeli grafit/antrasit tonları (ne zifiri kara, ne lacivert)
   ================================ */

:root {
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.72);
    --text-muted: rgba(255, 255, 255, 0.45);

    /* #222222 Koyu Nötr Gri Yüzeyler */
    --glass-surface: #222222;
    --glass-surface-card: #222222;
    --glass-surface-hover: rgba(255, 255, 255, 0.08);

    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-border-bright: rgba(255, 255, 255, 0.22);
    --glass-border-highlight: rgba(255, 255, 255, 0.35);

    /* Sade cam yansıma dokunuşu */
    --glass-sheen: inset 0 1px 1px 0 rgba(255, 255, 255, 0.10);

    --font-family-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
}

/* ================================
   Açık Tema (Light Mode) Tanımları
   ================================ */
[data-theme="light"] {
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;

    --glass-surface: #e6e6e6;
    --glass-surface-card: #ffffff;
    --glass-surface-hover: #f1f5f9;

    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-border-bright: rgba(0, 0, 0, 0.14);
    --glass-border-highlight: rgba(0, 0, 0, 0.22);
}

[data-theme="light"] body {
    background: #e6e6e6;
    color: #0f172a;
}

[data-theme="light"] .academy-header__title {
    color: #0f172a;
}

[data-theme="light"] .theme-toggle-btn {
    background: transparent;
    border: none;
    color: #000000;
}

[data-theme="light"] .theme-toggle-btn:hover {
    background: transparent;
    border: none;
    color: #000000;
    opacity: 0.75;
}

[data-theme="light"] .theme-toggle-btn .sun-icon {
    display: none;
}

[data-theme="light"] .theme-toggle-btn .moon-icon {
    display: block;
}

[data-theme="light"] .video-meta-title {
    color: #0f172a;
}

[data-theme="light"] .video-meta-desc {
    color: #475569;
}

[data-theme="light"] .cinema-player-wrapper {
    border: none;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .playlist-sidebar {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.09);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .playlist-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .search-box input {
    background: #f1f5f9;
    border: 1px solid rgba(0, 0, 0, 0.09);
    color: #0f172a;
}

[data-theme="light"] .search-box input:focus {
    background: #ffffff;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

[data-theme="light"] .search-box input::placeholder {
    color: #94a3b8;
}

[data-theme="light"] .search-icon {
    color: #000000;
}

[data-theme="light"] .search-clear {
    color: #000000;
}

[data-theme="light"] .search-clear:hover {
    color: #000000;
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .playlist-item:hover {
    background: #f1f5f9;
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .playlist-item.active {
    background: #ecfdf5;
    border: 1px solid rgba(16, 185, 129, 0.35);
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.12);
}

[data-theme="light"] .item-title {
    color: #1e293b;
}

[data-theme="light"] .playlist-item.active .item-title {
    color: #065f46;
}

[data-theme="light"] .item-status {
    color: #047857;
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.35);
}

[data-theme="light"] .item-hint {
    color: #64748b;
}

[data-theme="light"] .item-thumb-wrapper {
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.32);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family-main);
    color: var(--text-primary);
    background: #222222;
    min-height: 100vh;
    height: 100vh;
    overflow-y: hidden;
    overflow-x: hidden;
    width: 100%;
    -webkit-font-smoothing: antialiased;
}

/* Custom Liquid Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.32);
}

/* Main Application Shell */
.academy-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 16px 20px 20px 20px;
    max-width: 1600px;
    width: 100%;
    min-width: 0;
    margin: 0 auto;
    gap: 14px;
    overflow-x: hidden;
}

/* Header - Kutusuz Sade Başlık Alanı */
.academy-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 2px 2px 2px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    flex-shrink: 0;
}

.academy-header__brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.academy-header__title {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.01em;
}

.academy-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.theme-toggle-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle-btn:hover {
    background: transparent;
    border: none;
    transform: scale(1.08);
    opacity: 0.8;
}

.theme-toggle-btn:active {
    transform: scale(0.92);
}

.theme-toggle-btn .sun-icon {
    display: block;
}

.theme-toggle-btn .moon-icon {
    display: none;
}

/* Split-View Workspace */
.academy-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 16px;
    flex: 1;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* Left Stage: Player + Info */
.stage-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    overflow-y: auto;
    padding-right: 4px;
}

.cinema-player-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background: #000000;
    border-radius: 14px;
    overflow: hidden;
    border: none;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    flex-shrink: 0;
}

.cinema-player-wrapper .main-video,
.cinema-player-wrapper .plyr {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 14px;
}

/* Video Başlık ve Açıklama Alanı (Kutusuz / Sade Metin) */
.video-meta-card {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-radius: 0;
    padding: 6px 2px 0 2px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: none;
}

.video-meta-title {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.video-meta-desc {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13.5px;
    line-height: 1.55;
}

/* Right Sidebar: Oynatma Listesi (#222222) */
.playlist-sidebar {
    background: #222222;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.playlist-header {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
}

.playlist-header__search-row {
    display: flex;
    align-items: center;
    gap: 10px;
}


.search-box {
    position: relative;
    width: 100%;
    min-width: 0;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #ffffff;
    pointer-events: none;
}

.search-box input {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 8px 32px 8px 36px;
    color: #ffffff;
    font-size: 12.5px;
    font-family: inherit;
    outline: none;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: all 0.2s ease;
}

.search-box input:focus {
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.10);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    font-size: 13px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s ease, color 0.15s ease;
}

.search-clear:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.10);
}

/* Playlist Scroll Container */
.playlist-scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-color: rgba(255, 255, 255, 0.11) transparent;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.playlist-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.11);
}

.playlist-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.22);
}

[data-theme="light"] .playlist-scroll-container {
    scrollbar-color: rgba(0, 0, 0, 0.28) transparent;
}

[data-theme="light"] .playlist-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.28);
}

[data-theme="light"] .playlist-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.42);
}

/* Playlist Item - Sade ve Temiz Cam Kartı */
.playlist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 12px;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.playlist-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Aktif Kart: Zarif Frosted Glass Vurgusu (Aşırı 3D olmayan) */
.playlist-item.active {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.30);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.item-thumb-wrapper {
    position: relative;
    width: 88px;
    height: 50px;
    border-radius: 0;
    overflow: hidden;
    background: #000000;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.item-thumb {
    border-radius: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.item-duration-badge {
    position: absolute;
    bottom: 3px;
    right: 3px;
    background: rgba(0, 0, 0, 0.80);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #ffffff;
    font-size: 10px;
    font-weight: 500;
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.item-playing-overlay {
    border-radius: 0;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.playlist-item.active .item-playing-overlay {
    border-radius: 0;
    display: flex;
}

.playing-icon-pulse {
    width: 18px;
    height: 18px;
    fill: #ffffff;
    animation: pulse-grow 1.6s ease-in-out infinite;
}

@keyframes pulse-grow {
    0%, 100% { transform: scale(0.94); opacity: 0.9; }
    50% { transform: scale(1.10); opacity: 1; }
}

.item-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.item-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.item-title {
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    min-width: 0;
    flex: 1;
    word-break: break-word;
}

.item-status {
    font-size: 9.5px;
    font-weight: 600;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.30);
    padding: 1px 7px;
    border-radius: 999px;
    display: none;
    flex-shrink: 0;
}

.playlist-item.active .item-status {
    display: inline-block;
}

.playlist-item.active .item-title {
    color: #ffffff;
    font-weight: 600;
}

.item-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Empty search result */
.empty-search-state {
    padding: 30px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ================================
   Responsive Breakpoints & Mobile Optimization
   ================================ */

/* Tablet Manzara (961px - 1200px): İki sütunlu orantılı alan */
@media (min-width: 961px) and (max-width: 1200px) {
    .academy-app {
        padding: 12px 16px 16px 16px;
        gap: 12px;
    }

    .academy-workspace {
        grid-template-columns: 1fr clamp(290px, 30vw, 360px);
        gap: 12px;
    }

    .playlist-item {
        padding: 8px 10px;
        gap: 10px;
    }

    .item-thumb-wrapper {
        width: 80px;
        height: 46px;
    }
}

/* Tablet Portre & Standart Mobil (≤960px) */
@media (max-width: 960px) {
    body {
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
        min-height: 100vh;
        width: 100%;
    }

    .academy-app {
        height: auto;
        min-height: 100vh;
        overflow-y: visible;
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;
        padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
        gap: 12px;
    }

    /* Modal kapat butonuyla çakışmayı önleyen güvenli sağ boşluk */
    .academy-header {
        padding-right: 2px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .academy-workspace {
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        max-width: 100%;
        min-width: 0;
        height: auto;
        overflow: visible;
        gap: 14px;
    }

    .stage-section {
        height: auto;
        overflow: visible;
        padding-right: 0;
        gap: 10px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .cinema-player-wrapper {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .video-meta-card,
    .video-meta-title,
    .video-meta-desc {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    /* iOS Safari otomatik zoom'unu önlemek için 16px font */
    .search-box input {
        font-size: 16px;
        padding: 8px 34px 8px 36px;
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }

    /* Mobilde çift scroll kargaşasını önle: oynatma listesi sayfanın doğal akışında kaysın */
    .playlist-sidebar {
        height: auto;
        min-height: 0;
        overflow: visible;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .playlist-scroll-container {
        overflow-y: visible;
        height: auto;
        max-height: none;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .playlist-item {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

/* Mobilde (≤767px) kapat butonu kart içine girdiği için güvenli sağ boşluk */
@media (max-width: 767px) {
    .academy-header {
        padding-right: calc(env(safe-area-inset-right, 0px) + 50px);
    }
}

/* Standart ve Kompakt Akıllı Telefonlar (≤640px) */
@media (max-width: 640px) {
    .academy-app {
        padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
        gap: 10px;
    }

    .academy-header {
        padding: 2px calc(env(safe-area-inset-right, 0px) + 50px) 2px 2px;
    }

    .academy-header__title {
        font-size: 15px;
    }

    .cinema-player-wrapper {
        border-radius: 10px;
    }

    .video-meta-card {
        padding: 4px 2px 0 2px;
        gap: 4px;
    }

    .video-meta-title {
        font-size: 15.5px;
        line-height: 1.35;
    }

    .video-meta-desc {
        font-size: 12.5px;
        line-height: 1.5;
    }

    .playlist-header {
        padding: 10px 10px;
    }

    .search-box input {
        padding: 8px 34px 8px 34px;
        font-size: 15px;
    }


    .playlist-scroll-container {
        padding: 6px;
        gap: 4px;
    }

    .playlist-item {
        padding: 8px 10px;
        gap: 10px;
        border-radius: 10px;
        min-height: 52px;
    }

    .item-thumb-wrapper {
        width: 78px;
        height: 46px;
        border-radius: 0;
    }

    .item-duration-badge {
        font-size: 9px;
        padding: 1px 4px;
    }

    .item-title {
        font-size: 13px;
    }

    .item-hint {
        font-size: 11px;
    }
}

/* Çok Küçük Ekranlar (320px - 380px: iPhone SE, küçük Android cihazlar) */
@media (max-width: 380px) {
    .academy-app {
        padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
        gap: 8px;
    }

    .academy-header {
        padding-right: calc(env(safe-area-inset-right, 0px) + 46px);
    }

    .academy-header__title {
        font-size: 13.5px;
    }

    .playlist-header__search-row {
        gap: 6px;
    }


    .playlist-item {
        padding: 7px 8px;
        gap: 8px;
    }

    .item-thumb-wrapper {
        width: 68px;
        height: 40px;
    }

    .item-title {
        font-size: 12px;
    }

    .item-hint {
        display: none;
    }
}

/* Yatay Telefonlar (Mobile Landscape: max-height: 520px ve orientation: landscape) */
@media (max-height: 520px) and (orientation: landscape) {
    body {
        height: 100vh;
        overflow: hidden;
    }

    .academy-app {
        height: 100vh;
        min-height: 100vh;
        padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
        gap: 4px;
        overflow: hidden;
    }

    .academy-header {
        padding: 0 calc(env(safe-area-inset-right, 0px) + 50px) 0 2px;
    }

    .academy-header__title {
        font-size: 13.5px;
    }

    .academy-workspace {
        display: grid;
        grid-template-columns: 1.22fr 1fr;
        gap: 8px;
        height: calc(100vh - 34px);
        overflow: hidden;
    }

    .stage-section {
        height: 100%;
        overflow-y: auto;
        gap: 4px;
        padding-right: 2px;
    }

    .video-meta-title {
        font-size: 13px;
    }

    .video-meta-desc {
        font-size: 11px;
        line-height: 1.4;
    }

    .playlist-sidebar {
        height: 100%;
        overflow: hidden;
    }

    .playlist-scroll-container {
        height: calc(100% - 46px);
        overflow-y: auto;
        padding: 4px 6px;
        gap: 4px;
    }

    .playlist-item {
        padding: 5px 8px;
        gap: 8px;
        min-height: 44px;
    }

    .item-thumb-wrapper {
        width: 64px;
        height: 36px;
    }

    .item-title {
        font-size: 11.5px;
        -webkit-line-clamp: 1;
    }

    .item-hint {
        font-size: 10.5px;
    }
}
