/* ==========================================
   ZMIENNE I KOLORY
========================================== */
:root { 
    --primary: #1b4d3e; 
    --primary-dark: #0a1f1a;
    --accent: #d4a373; 
    --accent-hover: #c28f5c;
    --navy: #002d62; /* NOWOŚĆ: Głęboki granat */
    --bg: #cfd8dc; 
    --white: #ffffff;
    --text-main: #1a1a1a; 
    --text-muted: #546e7a;
    --fb-blue: #1877F2;
    --shadow: 0 4px 20px rgba(0,0,0,0.12);

    --plyr-color-main: var(--accent);
}

/* ==========================================
   TRYB CIEMNY (DARK MODE)
========================================== */
body.dark-theme {
    --bg: #121212;
    --white: #1a1a1a; 
    --text-main: #f5f5f5;
    --text-muted: #b0b0b0;
    --shadow: 0 8px 30px rgba(0,0,0,0.6);
}

body.dark-theme .navbar, 
body.dark-theme .video-details, 
body.dark-theme .sidebar-section { 
    background: var(--white); 
    border: 1px solid #2a2a2a; 
}

/* FILTRY - CIEMNA ZIELEŃ */
body.dark-theme .filter-btn {
    background: #0c1e17; 
    color: #e0e0e0;
    border: 1px solid #14382d;
}
body.dark-theme .filter-btn:hover {
    background: #112b21;
    border-color: var(--navy); /* Granatowy akcent przy najechaniu */
    color: var(--accent);
}
body.dark-theme .filter-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--accent);
}

/* KAFELKI WIDEO */
body.dark-theme .grid-card {
    background: #0c1e17; 
    border: 1px solid #14382d; 
}
body.dark-theme .grid-thumbnail {
    border-bottom: 1px solid #14382d;
    background-color: #050f0c;
}
body.dark-theme .grid-card:hover {
    background: #112b21;
    border-color: var(--navy); /* Granatowa ramka przy najechaniu */
    /* Granatowa poświata (Glow) */
    box-shadow: 0 10px 30px rgba(0,0,0,0.9), 0 0 15px rgba(0, 45, 98, 0.3);
}

body.dark-theme .search-box input { background-color: #222; border-color: #333; color: white; }
body.dark-theme .sidebar-title { background-color: #151515; border-bottom-color: #2a2a2a; }
body.dark-theme .sidebar-item:hover { background-color: #0c1e17; border-color: #14382d; }
body.dark-theme .site-footer { background: #0a0a0a; border-top-color: var(--primary); }
body.dark-theme .logout-btn { background: #222; color: #fff; border-color: #333; }


/* ==========================================
   RESET I BAZA
========================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text-main); line-height: 1.6; display: flex; flex-direction: column; min-height: 100vh; transition: background 0.3s, color 0.3s; }
.container { max-width: 1650px; margin: 0 auto; padding: 2rem; width: 100%; }

/* ==========================================
   LOGOWANIE
========================================== */
.welcome-page { position: relative; height: 100vh; display: flex; align-items: center; justify-content: center; text-align: center; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: #fff; padding: 20px; }
.welcome-content { max-width: 450px; width: 100%; padding: 40px; background: rgba(255,255,255,0.1); border-radius: 20px; backdrop-filter: blur(15px); border: 1px solid rgba(255,255,255,0.2); box-shadow: 0 15px 35px rgba(0,0,0,0.3); }
.badge { background: var(--accent); padding: 6px 16px; border-radius: 20px; font-size: 0.85rem; margin-bottom: 20px; display: inline-block; font-weight: bold; text-transform: uppercase; color:#fff;}
.welcome-content h1 { font-size: 2.2rem; margin-bottom: 15px; }
.welcome-content p { margin-bottom: 25px; opacity: 0.9; }

.password-container { position: relative; width: 100%; margin-bottom: 15px; }
.password-container input { margin-bottom: 0; padding-right: 70px; }
.toggle-password { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); background: none; border: none; font-weight: 800; font-size: 0.85rem; color: var(--primary); cursor: pointer; text-transform: uppercase; outline: none; transition: 0.2s; }
.toggle-password:hover { color: var(--accent); }

.login-form input { width: 100%; padding: 14px; border-radius: 30px; border: none; outline: none; text-align: center; font-size: 1rem; }
.btn-primary { display: inline-block; background: var(--accent); color: #fff; padding: 15px 40px; border-radius: 30px; text-decoration: none; font-weight: bold; cursor: pointer; transition: 0.3s; width: 100%; border: none;}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-2px); }
.top-left-fb { position: absolute; top: 25px; left: 35px; color: var(--fb-blue); transition: 0.3s; z-index: 10;}
.top-left-fb:hover { filter: brightness(1.1); transform: scale(1.1); }
.login-footer { position: absolute; bottom: 20px; width: 100%; text-align: center; color: rgba(255, 255, 255, 0.5); font-size: 0.85rem; }

.forgot-password { display: inline-block; margin-top: 18px; color: rgba(255, 255, 255, 0.6); font-size: 0.9rem; text-decoration: none; transition: 0.3s; font-weight: 500; cursor: pointer; }
.forgot-password:hover { color: var(--accent); text-decoration: underline; }

/* ==========================================
   NAGŁÓWEK GALERII
========================================== */
.navbar { display: flex; justify-content: space-between; align-items: center; padding: 0.8rem 2rem; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 1000; box-shadow: 0 2px 15px rgba(0,0,0,0.1); gap: 25px; }

.logo { font-size: 1.5rem; font-weight: 900; color: var(--primary); text-decoration: none; display: flex; align-items: center; white-space: nowrap; }
/* GRANATOWY AKCENT: Słowo Wideo */
.logo span { color: var(--navy); font-weight: 800; margin-left: 4px; }

.search-box { flex-grow: 1; max-width: 600px; position: relative; }
.search-box input { width: 100%; padding: 12px 25px 12px 45px; border-radius: 50px; border: 1px solid #dce1e6; outline: none; font-size: 1.05rem; transition: 0.3s; background-color: #f8f9fa; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 15px center; }
/* GRANATOWY AKCENT: Focus wyszukiwarki */
.search-box input:focus { border-color: var(--navy); background-color: var(--white); box-shadow: 0 6px 15px rgba(0, 45, 98, 0.1); transform: translateY(-1px); }

.header-fb { color: var(--fb-blue); display: flex; align-items: center; transition: 0.3s; }
.theme-toggle { background: none; border: none; font-size: 1.4rem; cursor: pointer; padding: 5px; transition: 0.3s; }
.logout-btn { background: #f1f3f5; border: 1px solid #dee2e6; padding: 8px 18px; border-radius: 20px; font-weight: bold; text-decoration: none; color: #333; transition: 0.2s; }

/* ==========================================
   WIDOKI I FILTRY
========================================== */
.view { display: none; animation: fadeIn 0.4s ease; width: 100%; } 
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.gallery-header { text-align: center; margin: 10px 0 30px 0; }
.category-filters { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.filter-btn { background: var(--white); border: 2px solid transparent; color: var(--primary); padding: 10px 22px; border-radius: 50px; cursor: pointer; font-weight: 700; transition: 0.3s; }
.filter-btn.active { background: var(--primary); color: #fff; box-shadow: 0 4px 15px rgba(27, 77, 62, 0.3); }

/* ==========================================
   KAFELKI WIDEO
========================================== */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 2.5rem; }
.grid-card { background: var(--white); border-radius: 20px; overflow: hidden; cursor: pointer; transition: 0.4s; box-shadow: var(--shadow); position: relative; display: flex; flex-direction: column;}
.watched-badge { position: absolute; top: 15px; left: 15px; background: #2ecc71; color: white; width: 28px; height: 28px; border-radius: 50%; display: none; align-items: center; justify-content: center; font-size: 1.1rem; font-weight: bold; z-index: 5; box-shadow: 0 2px 10px rgba(0,0,0,0.2); }
.grid-card.is-watched .watched-badge { display: flex; }
.grid-thumbnail { background-color: #1a1a1a; background-size: cover; background-position: center; height: 190px; display: flex; align-items: center; justify-content: center; position: relative; transition: 0.3s; }
.play-overlay { position: absolute; color: #fff; font-size: 4rem; opacity: 0; transition: 0.3s; z-index: 2; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.5)); }
.grid-card:hover .play-overlay { opacity: 0.9; }
.grid-card:hover { transform: translateY(-10px); }
.grid-info { padding: 20px; flex-grow: 1; display: flex; flex-direction: column; }
.grid-info h3 { font-size: 1.15rem; color: var(--text-main); margin-top: 10px; font-weight: 800; line-height: 1.3; }
.badge-category { display: inline-block; background: var(--accent); color: #fff; padding: 5px 14px; border-radius: 8px; font-size: 0.7rem; text-transform: uppercase; font-weight: 900; align-self: flex-start;}

/* ==========================================
   ODTWARZACZ PLYR I SKALOWANIE
========================================== */
.btn-back { background: none; border: none; color: var(--primary); font-weight: bold; cursor: pointer; margin-bottom: 20px; font-size: 1.1rem; }
.youtube-layout { display: flex; gap: 40px; align-items: flex-start; }
.player-section { flex: 1; min-width: 0; max-width: 100%; }
.main-video-container { width: 100%; margin: 0 auto; transition: max-width 0.15s ease-out; display: flex; justify-content: center;}

.plyr { border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); background: #000; width: 100%; max-height: 75vh; transition: width 0.15s ease-out, height 0.15s ease-out; }
.plyr video { max-height: 75vh; object-fit: contain; }

/* FULLSCREEN */
body.is-fullscreen .plyr, body.is-fullscreen .plyr video, body.is-fullscreen .plyr__video-wrapper {
    max-height: 100vh !important; height: 100vh !important; max-width: 100vw !important; width: 100vw !important; border-radius: 0 !important; object-fit: contain !important;
}

.video-details { background: var(--white); padding: 30px; border-radius: 15px; margin-top: 25px; border: 1px solid rgba(0,0,0,0.08); box-shadow: var(--shadow); }
.video-title-wrapper { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-wrap: wrap; gap: 15px; }
.video-details h1 { font-size: 1.8rem; color: var(--primary-dark); font-weight: 900; margin: 0; }

.watched-toggle { display: flex; align-items: center; justify-content: center; cursor: pointer; background: #f1f3f5; padding: 8px 18px; border-radius: 20px; font-size: 0.95rem; font-weight: bold; color: var(--text-muted); transition: 0.2s; border: 1px solid #dce1e6; user-select: none; }
.watched-toggle:hover { background: #e2e8ea; }
.watched-toggle input { display: none; } 
.watched-toggle.checked-style::before { content: '✓'; margin-right: 6px; font-weight: bold; }
.watched-toggle.checked-style { background: #e8f8f0; color: #2ecc71; border-color: #2ecc71; }

.video-meta { color: var(--text-muted); font-size: 0.9rem; padding-bottom: 15px; border-bottom: 1px solid #eee; margin-bottom: 15px; }

/* ==========================================
   PLAYLISTA I GRANATOWY SCROLLBAR
========================================== */
.sidebar-section { width: 460px; flex-shrink: 0; background: var(--white); border-radius: 15px; border: 1px solid #e0e0e0; box-shadow: var(--shadow); height: calc(100vh - 160px); min-height: 500px; display: flex; flex-direction: column; overflow: hidden; }
.sidebar-title { padding: 18px 20px; background: #f8f9fa; border-bottom: 1px solid #e0e0e0; font-weight: 800; font-size: 1.1rem; color: var(--primary-dark); margin: 0; }

#playerSidebarList { flex: 1; overflow-y: auto; padding: 15px; }
/* GRANATOWY AKCENT: Pasek przewijania */
#playerSidebarList::-webkit-scrollbar { width: 6px; }
#playerSidebarList::-webkit-scrollbar-thumb { background: var(--navy); border-radius: 10px; }
#playerSidebarList::-webkit-scrollbar-thumb:hover { background: var(--primary); }

.sidebar-item { display: flex; gap: 15px; margin-bottom: 12px; cursor: pointer; padding: 10px; border-radius: 10px; transition: 0.2s; }
.sidebar-item:hover { background: #f1f3f5; }
.sidebar-item.is-watched h4 { color: #2ecc71; }
.sidebar-item.is-watched h4::after { content: ' ✓'; }

.sidebar-thumbnail { background-color: #1a1a1a; background-size: cover; background-position: center; width: 140px; height: 80px; flex-shrink: 0; border-radius: 8px; }
.sidebar-info { display: flex; flex-direction: column; justify-content: center; }
.sidebar-info h4 { font-size: 0.95rem; color: var(--text-main); line-height: 1.3; font-weight: 700;}

.site-footer { background: var(--primary-dark); color: #90a4ae; text-align: center; padding: 40px 20px; margin-top: auto; border-top: 5px solid var(--accent); width: 100%; }

/* RESPONSYWNOŚĆ */
html, body { max-width: 100vw; overflow-x: hidden; }
@media (max-width: 1100px) { 
    .youtube-layout { flex-direction: column; } 
    .sidebar-section { width: 100%; height: auto; border: none; box-shadow: none; background: transparent; } 
    #playerSidebarList { overflow-y: visible; padding: 0; }
    .sidebar-title { display: none; }
}
@media (max-width: 850px) {
    .container { padding: 15px; }
    .video-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.5rem; }
    .navbar { flex-direction: column; align-items: stretch; padding: 15px; gap: 15px; width: 100%; box-sizing: border-box; }
    .navbar > div:first-child { width: 100%; justify-content: space-between !important; display: flex; }
    .search-box { width: 100%; max-width: 100%; margin: 0; }
    .navbar > div:last-child { width: 100%; justify-content: space-between !important; display: flex; padding-top: 12px; border-top: 1px solid rgba(0,0,0,0.08); }
    .category-filters { gap: 8px; }
    .filter-btn { padding: 8px 16px; font-size: 0.9rem; }
}
@media (max-width: 400px) { .video-grid { grid-template-columns: 1fr; } }