/* ==========================================
   1. ZMIENNE I RESET (SCALONE)
   ========================================== */
:root {
    /* Kolory główne */
    --primary: #fe2c55;
    --primary-hover: #ef2950;
    --accent: #00ff88; 
    --accent-glow: rgba(0, 255, 136, 0.4);
    
    /* Tła i tekst */
    --bg-dark: #0a0b10;
    --card-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #ffffff;
    --text-dim: #94a3b8;

    /* Admin Panel */
    --admin-bg: rgba(15, 23, 42, 0.95);
    --admin-accent: #00ff88;
    --admin-height: 50px;
    --admin-text-muted: #94a3b8;
}

* { 
    box-sizing: border-box;
    margin: 0; 
    padding: 0; 
}
/* Kontener dropdowna */
.admin-dropdown {
    position: relative;
    display: inline-block;
}

/* Ukryta zawartość */
.admin-dropdown-content {
    display: none; /* Domyślnie ukryte */
    position: absolute;
    left: 0;
    top: 100%; /* Pojawia się dokładnie pod przyciskiem */
    background-color: #222;
    min-width: 200px;
    box-shadow: 0px 8px 16px rgba(0,0,0,0.5);
    z-index: 10000001; /* Wyżej niż wszystko inne */
    border: 1px solid #444;
    border-radius: 4px;
}

/* POKAZYWANIE: To jest kluczowe */
.admin-dropdown:hover .admin-dropdown-content {
    display: block !important;
}

/* Linki wewnątrz */
.admin-dropdown-content a {
    color: #fff !important;
    padding: 10px 15px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    border-bottom: 1px solid #333;
}

.admin-dropdown-content a:hover {
    background-color: #3b82f6; /* Niebieski highlight */
}
body {
    width: 100%;
    min-height: 100vh;
    background: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Poppins', sans-serif;
    overflow-x: hidden; /* Blokada przesuwania na boki */
    padding-top: 0; /* Admin bar doda padding dynamicznie klasą */
}

/* Klasa dodawana do body gdy admin jest zalogowany */
body.admin-logged { 
    padding-top: var(--admin-height); 
}

.page-wrapper { 
    display: flex; 
    flex-direction: column;
    width: 100%; 
    max-width: 100%;
    min-height: 100vh;
}

.main-content { 
    width: 100%;
    max-width: 100%;
    flex: 1; /* Wypycha stopkę na dół */
}

/* ==========================================
   2. PASEK NAWIGACJI (AUTH BAR)
   ========================================== */
.auth-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    position: relative; /* Sticky ustawimy w media queries jeśli trzeba */
    z-index: 2000;
}

/* Przycisk Hamburgera (Mobile) */
.hamburger-btn, .mobile-menu-trigger {
    display: none; /* Domyślnie ukryte na PC */
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 2001;
}
.hamburger-btn span, .mobile-menu-trigger span { 
    width: 25px; height: 2px; background: #fff; display: block; 
}

/* Kontener Języka */
.lang-switcher-container { 
    position: relative; 
    display: inline-block; 
}

.lang-current {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 8px 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.3s;
    font-size: 13px;
    font-weight: 600;
}
.lang-current:hover { background: rgba(255,255,255,0.1); }

/* Dropdown Języka */
.lang-dropdown {
    display: none;
    flex-direction: column;
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    background: #1a1a1a;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 8px;
    width: 160px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 2002;
}
.lang-dropdown.show, .lang-dropdown.active { display: flex; }

.lang-dropdown a { 
    display: flex; align-items: center; gap: 10px; 
    padding: 10px 15px; 
    color: #fff; text-decoration: none; 
    transition: 0.2s; border-radius: 6px;
}
.lang-dropdown a:hover { background: rgba(255,255,255,0.05); color: var(--accent); }

/* Prawa strona nagłówka */
.auth-buttons { display: flex; gap: 12px; align-items: center; }

/* Desktop Nav (Home/Gallery) */
.desktop-nav { display: flex; gap: 10px; }
.nav-link, .btn-outline {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    padding: 10px 20px;
    border-radius: 12px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}
.nav-link:hover, .btn-outline:hover, .nav-link.active {
    border-color: var(--accent);
    color: #fff;
    background: rgba(255,255,255,0.05);
}

/* Login Dropdown */
.login-wrapper { position: relative; }
.login-dropdown {
    display: none;
    flex-direction: column;
    gap: 12px;
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(25px);
    padding: 25px;
    border-radius: 18px;
    border: 1px solid var(--glass-border);
    border-top: 2px solid var(--accent);
    width: 280px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    z-index: 3000;
}
.login-dropdown.show { display: flex !important; }

/* ==========================================
   3. GŁÓWNA TREŚĆ (CARD & INPUTS)
   ========================================== */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    margin: 40px auto;
    padding: 30px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
.card-small {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    width: 95%;
    max-width: 850px;
    margin: 40px auto;
    padding: 30px;
    border-radius: 30px;
    text-align: center;
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
.card h1 a { text-decoration: none; color: #fff; }

.input-group {
    position: relative;
    margin: 30px 0;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2px;
    display: flex;
    align-items: center;
}

input[type="text"], input[type="email"], input[type="password"] {
    flex: 1;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: white !important;
    padding: 18px 25px;
    font-size: 16px;
    outline: none !important;
    width: 100%;
}

.btn-action {
    background: linear-gradient(135deg, var(--accent), #00d4ff);
    color: #000;
    border: none;
    padding: 16px;
    border-radius: 14px;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    width: 50%;
	margin: 20px;
    box-shadow: 0 4px 15px var(--accent-glow);
    transition: 0.3s;
}
.btn-action:hover { transform: scale(1.02); filter: brightness(1.1); }

/* Fix autofill (białe tło przeglądarki) */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0px 1000px var(--bg-dark) inset !important;
    -webkit-text-fill-color: white !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* ==========================================
   4. HISTORIA (GRID DESKTOP)
   ========================================== */
.history-box {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

.history-header {
    display: flex; flex-direction: column; align-items: center;
    gap: 15px; margin-bottom: 25px; text-align: center;
}
.history-title { margin: 0; font-size: 1.5rem; color: #fff; }

/* Grid na PC */
#historyList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    min-height: 200px;
    align-content: start;
}

.history-item {
    position: relative;
    aspect-ratio: 9/12; 
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--glass-border);
    transition: 0.3s;
    background: #000;
}
.history-item:hover { border-color: var(--accent); transform: translateY(-5px); }

.history-item img {
    width: 100%; height: 100%; object-fit: cover;
}

.history-info {
    position: absolute; bottom: 8px; left: 8px; right: 8px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    color: var(--accent);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 800;
    text-align: center;
    z-index: 2;
}

/* Preview Wideo w wyniku */
.video-preview-container {
    position: relative; width: 100%; max-width: 400px;
    margin: 20px auto; cursor: pointer; border-radius: 12px;
    overflow: hidden; border: 2px solid #333;
}
.play-overlay {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(37, 244, 238, 0.8);
    color: #000; width: 60px; height: 60px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 24px; z-index: 2; transition: 0.3s;
}
.video-preview-container:hover .play-overlay { transform: translate(-50%, -50%) scale(1.1); background: #25f4ee; }

/* ==========================================
   5. RESPONSYWNOŚĆ I MOBILE (FIXES)
   ========================================== */
@media (max-width: 768px) {
    /* Ukrywanie elementów Desktop */
    .desktop-nav { display: none; }
    .hamburger-btn, .mobile-menu-trigger { display: flex; }
    .welcome-text { display: none; }
    .admin-quick-stats { display: none; } /* Ukrywamy staty admina na telefonie */

    /* Fix Header */
    .auth-bar {
        padding: 10px 15px;
        position: relative;
    }

    /* Fix Login Dropdown (Full width on mobile) */
    .login-wrapper { position: static; }
    .login-dropdown {
        left: 5%; right: 5%; width: 90%;
        top: 70px;
    }

    /* --- PIONOWY TIKTOK SCROLL --- */
    #historyList {
        display: flex !important;
        flex-direction: column !important;
        height: calc(100vh - 120px); /* Dopasowane, żeby nie ucinało dołu */
        overflow-y: scroll !important;
        scroll-snap-type: y mandatory;
        gap: 15px;
        padding-bottom: 50px; /* Miejsce na scroll */
        scrollbar-width: none;
    }
    #historyList::-webkit-scrollbar { display: none; }

    .history-item {
        flex: 0 0 auto;
        width: 100%;
        height: 80vh; /* Prawie cały ekran */
        scroll-snap-align: center;
        border: none;
        background: transparent;
        pointer-events: auto; /* Pozwala klikać w kartę */
    }

    .history-item img, 
    .history-item video {
        width: 100%; height: 100%;
        object-fit: contain; /* Film cały widoczny */
        background: #000;
        border-radius: 12px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    }

    .history-info { bottom: 20px; font-size: 14px; padding: 8px 15px; }

    /* Result Focus */
    .result-focus-container {
        min-height: auto;
        padding: 10px;
    }
    #result-single .video-preview-container {
        width: 100%; aspect-ratio: 9/16;
        border: 2px solid var(--accent);
    }
}

/* ==========================================
   6. ADMIN PANEL (SCALONE I POPRAWIONE)
   ========================================== */
.admin-top-bar {
    position: fixed; top: 0; left: 0;
    width: 100%; height: var(--admin-height);
    background: var(--admin-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10000;
    display: none; /* Pokazuje się tylko gdy body ma klasę .admin-logged */
    align-items: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

body.admin-logged .admin-top-bar { display: flex; }

.admin-bar-content {
    width: 100%; max-width: 1400px;
    margin: 0 auto; padding: 0 20px;
    display: flex; justify-content: space-between; align-items: center;
}

.admin-brand {
    font-weight: 800; color: var(--admin-accent);
    text-decoration: none; text-transform: uppercase;
    font-size: 14px; margin-right: 15px;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}


.admin-links a {
    text-decoration: none; color: var(--admin-text-muted);
    font-size: 13px; font-weight: 500;
    padding: 6px 14px; border-radius: 8px;
    transition: all 0.2s ease; white-space: nowrap;
}
.admin-links a:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }

/* Admin Dropdown */

/* Quick Stats (IP, etc.) */
.admin-quick-stats {
    font-family: 'Courier New', monospace; font-size: 11px; color: #64748b;
    background: rgba(0,0,0,0.3); padding: 4px 10px;
    border-radius: 4px; border: 1px solid rgba(255,255,255,0.05);
    display: flex; align-items: center; margin-left: 10px;
}
.admin-quick-stats::before {
    content: ''; display: inline-block; width: 6px; height: 6px;
    background: var(--admin-accent); border-radius: 50%;
    margin-right: 8px; box-shadow: 0 0 8px var(--admin-accent);
    animation: blink 2s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ==========================================
   7. STOPKA I INNE
   ========================================== */
.main-footer {
    padding: 60px 20px;
    margin-top: 50px;
    background: rgba(10, 11, 16, 0.8);
    border-top: 1px solid var(--glass-border);
    text-align: center;
    color: var(--text-dim);
}

/* Skeleton Loading */
.skeleton-item { 
    aspect-ratio: 9/12; background: #111; 
    border-radius: 16px; animation: pulse 1.5s infinite; 
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Mobile Overlay (Dla menu bocznego jeśli używasz) */
.mobile-overlay {
    display: none; position: fixed;
    top: 0; right: 0; width: 100%; height: 100vh;
    background: #000; z-index: 9999;
}
.mobile-overlay.active { display: flex; }

/* Gwarantujemy, że menu jest schowane domyślnie */
.mobile-nav-overlay {
    position: fixed !important; /* To wyjmuje menu z przepływu strony */
    top: 0;
    right: -100%; /* Całkowicie poza ekranem z prawej */
    width: 280px;
    height: 100vh;
    background: #111827 !important; /* Wymuszamy ciemne tło */
    z-index: 999999; /* Nad wszystkim */
    transition: right 0.3s ease;
    display: block !important; /* Zawsze obecne w DOM, ale przesunięte */
    padding: 60px 20px;
    box-shadow: -5px 0 15px rgba(0,0,0,0.5);
}

/* Kiedy JS doda klasę .open */
.mobile-nav-overlay.open {
    right: 0 !important;
}

/* Naprawa linków (żeby nie były fioletowe/niebieskie) */
.mobile-links a {
    display: block;
    color: white !important;
    text-decoration: none !important;
    padding: 15px;
    font-size: 18px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.close-mobile {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: white;
    font-size: 30px;
}

/* Ukrywamy hamburgera na komputerach */
@media (min-width: 851px) {
    .mobile-menu-trigger { display: none !important; }
}

/* Pokazujemy hamburgera na telefonach */
@media (max-width: 850px) {
    .mobile-menu-trigger {
        display: flex;
        flex-direction: column;
        gap: 4px;
        background: none;
        border: none;
        cursor: pointer;
    }
    .mobile-menu-trigger span {
        width: 22px;
        height: 2px;
        background: white;
    }
    .desktop-nav { display: none !important; }
}
/* ==========================================
   DODATEK: TIKTOK-STYLE MOBILE (FIX)
   ========================================== */

@media (max-width: 768px) {
    /* 1. Resetujemy zachowanie strony głównej */
    .card {
        margin: 0 !important;
        padding: 0 !important;
        background: none !important;
        box-shadow: none !important;
    }

    /* 2. Parser zostaje na górze, ale historia zajmuje resztę */
    .card-small {
        margin: 10px auto !important;
        width: 95% !important;
    }

    .history-box {
        margin-top: 10px !important;
        border: none !important;
    }

    /* 3. Kluczowy fix kontenera historii */
    #historyList {
        display: block !important; /* Wyłączamy grid */
        height: 80vh !important; /* Sztywna wysokość */
        overflow-y: scroll !important;
        scroll-snap-type: y mandatory !important;
        -webkit-overflow-scrolling: touch;
        background: #000;
    }

    /* 4. Każdy element historii - sztywna klatka */
    .history-item-mobile {
        width: 100vw !important;
        height: 80vh !important; /* Tyle samo co #historyList */
        scroll-snap-align: start;
        position: relative;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #000;
        overflow: hidden !important; /* ZABRANIA zdjęciom wychodzić poza klatkę */
    }

    /* 5. FIX DLA ZDJĘĆ I WIDEO - to musi być !important */
    .mobile-media-container {
        width: 100% !important;
        height: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .mobile-media-container img, 
    .mobile-media-container video {
        max-width: 100% !important;
        max-height: 100% !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important; /* Całe zdjęcie widoczne, reszta czarna */
        display: block !important;
    }
}
.back-to-top-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--accent);
    color: #000;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: none; /* Ukryty domyślnie */
    align-items: center;
    justify-content: center;
    z-index: 10001;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 255, 136, 0.4);
    font-weight: bold;
}