/* ========================================================================== */
/* 1. RESET I USTAWIENIA GLOBALNE                                             */
/* ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.hidden { 
    display: none; 
}

#pageScale { 
    flex: 1; 
}

:root {
    --preloader-bg-color: var(--white);
    --puzzle-base-color: #eeeeee; 
    --puzzle-pulse-dark: #bbbbbb; 
    --puzzle-pulse-light: #f5f5f5; 
}

/* ========================================================================== */
/* 2. TYPOGRAFIA                                                              */
/* ========================================================================== */

h1 { 
    font-size: 22px; 
    margin-top: 10px; 
    margin-bottom: 5px; 
    color: var(--base-1); 
    line-height: 1.3; 
}

h2 { 
    margin-top: 20px; 
    margin-bottom: 15px; 
    color: var(--base-1); 
    font-size: 18px; 
}

h3 { 
    color: var(--base-1); 
    font-size: 17px; 
}

/* ========================================================================== */
/* 3. BAZA I GŁÓWNY UKŁAD (LAYOUT)                                            */
/* ========================================================================== */

body {
    font-family: 'Lato', sans-serif;
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

body::before {
    content: "";
    position: fixed;
    inset: 0; 
    background: url('../img/puzzle-background.png') center / 8% repeat;
    opacity: 0.12;
    z-index: -1;
}

/* Skalowanie + Centrowanie (Stage) */
html.dashboard,
body.dashboard {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.stage {
    width: 1920px;
    height: 1080px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform-origin: top left;
    position: absolute;
    top: 0;
    left: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: geometricPrecision;
}

/* Efekt rozmycia (Glassmorphism) - Wspólne style */
.main-header,
.main-footer,
.cookie-banner {
    background: var(--white-opacity);
    backdrop-filter: var(--header-blur);
    -webkit-backdrop-filter: var(--header-blur);
}

/* ========================================================================== */
/* 4. KONTENERY I SEKCJE                                                      */
/* ========================================================================== */

.container {
    background: var(--white-opacity);
    padding: 1.5vw;
    border-radius: 1.5vw;
    width: 95%;
    max-width: 1800px;
    text-align: center;
    box-shadow: var(--shadow-dark);
    margin: auto;
    flex: none;
    height: auto;
}

/* Konkretne modyfikacje kontenerów */
.manage-page .container,
.contact-page .container,
.login-page .container,
.dashboard .container {
    max-width: 1000px;
    margin-bottom: auto;
    margin-top: 2vh;
}

.manage-page .container {
    position: relative;
    padding-bottom: 35px;
}

.edit-page .container,
.add-page .container,
.reset-page .container,
.results-page .container {
    max-width: 1300px;
    margin-top: 20px;
    margin-bottom: auto;
}

.dashboard .container {
    height: 400px;
}

.index-page .container {
    margin-bottom: 2vh;
}

/* Ogólne sekcje wewnątrz kontenerów */
.section { 
    padding: 1.5vw;
    border-radius: 1.5vw;
    margin-top: 10px; 
}
.section-start { background-color: var(--color-4); }
.section-game  { background-color: var(--color-5); }

/* ========================================================================== */
/* 5. NAGŁÓWEK I NAWIGACJA (HEADER)                                           */
/* ========================================================================== */

.main-header {
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: var(--header-border);
    box-shadow: var(--header-shadow);
    transition: transform 0.4s ease, opacity 0.3s ease;
    will-change: transform, opacity;
}

.main-header.header-hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.header-inner {
    max-width: 1800px;
    width: 95%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    height: 60px;
    justify-content: space-between;
}

.header-left, 
.header-nav, 
.header-languages,
.nav-group {
    display: flex;
    align-items: center;
    gap: 30px;
}

.header-languages { gap: 8px; }

.header-logo {
    display: flex;
    align-items: center;
    height: 60px;
    flex-shrink: 0;
}

.header-logo img {
    height: 36px !important;
    width: auto !important;
    max-width: 100% !important;
}

.logo-compact { display: none; }

/* Linki nawigacyjne */
.nav-link, 
.nav-link button {
    all: unset;
    text-decoration: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--base-1);
    cursor: pointer;
    position: relative;
    display: inline-block;
    transition: color 0.3s ease;
}

.nav-link:hover, 
.nav-link button:hover {
    color: var(--color-2);
}

.nav-link::after, 
.nav-link button::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -5px;
    left: 0;
    background-color: var(--color-2);
    transition: width 0.3s ease;
}

.nav-link:hover::after, 
.nav-link button:hover::after {
    width: 100%;
}

.header-languages a {
    text-decoration: none;
    color: var(--color-10);
    font-size: 13px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.header-languages a:hover,
.header-languages .lang-active {
    background: var(--color-2);
    color: var(--white) !important;
}

/* Menu ogólne i mobilne */
.menu {
    display: flex;
    flex-direction: column;
    gap: 15px; 
    margin: 20px auto;
    max-width: 400px;
}

.menu-toggle {
    display: none; 
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    margin: 5px 0;
    background-color: var(--base-1); 
    border-radius: 2px;
    transition: all 0.3s ease;
}

.menu-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 6px); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -6px); }

.logout-form { display: inline; }

/* ========================================================================== */
/* 6. STOPKA (FOOTER)                                                          */
/* ========================================================================== */

.main-footer {
    width: 100%;
    margin-top: auto;
    border-top: var(--header-border);
    box-shadow: 0 -2px 15px rgba(0,0,0,0.05);
}

.footer-inner {
    max-width: 1800px;
    width: 95%;
    margin: 0 auto;
    text-align: center;
    min-height: 50px;
    padding: 15px 0;
}

.main-footer p,
.main-footer .footer-sep {
    display: inline-block;
    vertical-align: middle;
    margin: 0 4px;
}

.main-footer p {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-10);
    white-space: nowrap; /* Zapobiega łamaniu tekstu na dwie linie */
}

.footer-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-10);
    text-decoration: none;
    transition: color 0.2s ease;
    white-space: nowrap; /* Zapobiega łamaniu linku na dwie linie */
}

.footer-link:hover {
    color: var(--color-2);
}

.footer-sep, .sep {
    color: var(--color-10);
}

/* ========================================================================== */
/* 7. KOMPONENTY GLOBALNE (PRZYCISKI, ALERTY, BANERY)                         */
/* ========================================================================== */

/* --- Przyciski wspólne --- */
.btn, 
.btn-sm {
    display: block;
    cursor: pointer;
    border: none;
    color: var(--white);
    font-family: inherit;
    text-align: center;
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

:where(.btn, .btn-sm):disabled {
    background: var(--color-4) !important;
    cursor: not-allowed;
    transform: none !important;
    opacity: 0.6; 
}

/* Główny przycisk */
.btn {
    margin: 15px auto 0;
    padding: 12px;
    font-size: 20px;
    border-radius: 8px;
    background: var(--color-2);
    min-width: 250px;
}
.btn:hover { background: var(--base-2); }

/* Mały przycisk */
.btn-sm {
    display: inline-block;
    width: auto;
    padding: 6px 14px;
    font-size: 14px;
    border-radius: 6px;
    background: var(--color-2); 
}
.btn-sm:hover { background: var(--base-2); }

/* Kolory przycisków */
.btn-save { background: var(--color-7); }
.btn-save:hover { background: var(--color-7-1); }

.btn-send { background: var(--color-8); }
.btn-send:hover { background: var(--color-8-1); }

.btn-back { background: var(--color-10); }
.btn-back:hover { background: var(--color-10-1); }

.btn-base { background: var(--color-6); margin-bottom: 15px; }
.btn-base:hover { background: var(--base-3); }

.btn-back-med {
    background: var(--color-10);
    min-width: 150px;
}
.btn-back-med:hover { background: var(--color-10-1); }

/* Przycisk Reset Chart */
#resetChartBtn {
    display: inline-block;
    cursor: pointer;
    border: none;
    color: var(--white);
    font-family: inherit;
    text-align: center;
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
    padding: 6px 14px;
    font-size: 14px;
    border-radius: 6px;
    margin: 10px;
    font-weight: bold;
    background: var(--base-1);
    opacity: 0.85;
}
#resetChartBtn:hover {
    background: var(--color-1);
    opacity: 1;
    transform: scale(var(--scale));
}
#resetChartBtn:disabled {
    background: var(--color-4) !important;
    cursor: not-allowed;
    transform: none !important;
    opacity: 0.6; 
}

/* --- Alerty --- */
.alert {
    max-width: 600px;
    margin: 20px auto;
    padding: 15px 20px;
    border-radius: 6px;
    font-size: 15px;
    line-height: 1.4;
    box-shadow: var(--shadow-light);
}

.alert-error {
    background-color: var(--color-9);
    border: 1px solid var(--color-9);
    color: var(--color-7);
}

.alert-error strong {
    display: block;
    margin-bottom: 5px;
    font-size: 16px;
}

/* --- Banery --- */
@keyframes slideDown {
    from { transform: translate(-50%, -20px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

.lang-banner {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    width: calc(100% - 40px);
    max-width: 900px;
    animation: slideDown 0.4s ease-out;
}

.lang-banner-inner {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--color-4);
    backdrop-filter: blur(15px);
    border-radius: 16px;
    padding: 20px 25px;
    box-shadow: var(--shadow-light);
}

.cookie-banner {
    position: fixed;
    bottom: 20px; 
    left: 50%;
    transform: translate(-50%, 150%);
    width: calc(100% - 40px);
    max-width: 900px;
    border-radius: 16px;
    padding: 20px 25px;
    box-shadow: var(--shadow-dark);
    z-index: 10000;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    transition: transform 0.4s ease-out;
}

.cookie-banner.show {
    transform: translate(-50%, 0);
}

.cookie-content {
    flex: 1 1 60%;
    min-width: 300px;
    text-align: left;
}

.cookie-content h3 { 
    margin: 0 0 10px 0; 
    font-size: 18px; 
    color: var(--color-1); 
}

.cookie-content p { 
    margin: 0; 
    font-size: 14px; 
    color: var(--base-1); 
    line-height: 1.5; 
}

.cookie-content a { 
    color: var(--color-2); 
    text-decoration: none; 
    font-weight: 600;
    transition: color 0.2s ease;
}

.cookie-content a:hover {
    color: var(--base-2);
}

.cookie-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 10px;
}

.btn-cookie {
    padding: 10px 18px;
    border: none;
    border-radius: 8px; 
    cursor: pointer;
    font-weight: bold;
    font-family: inherit;
    font-size: 15px;
    color: var(--white);
    transition: background 0.2s ease, transform 0.2s ease;
}

.btn-accept { background: var(--color-2); }
.btn-accept:hover { background: var(--base-2); }

.btn-reject { background: var(--color-10); }
.btn-reject:hover { background: var(--color-10-1); }

/* ========================================================================== */
/* 8. WIDOKI I ELEMENTY SPECYFICZNE                                           */
/* ========================================================================== */

/* --- Tytuły i nagłówki stron --- */
.title-container,
.title-container-index {
    display: flex;
    justify-content: center;
    background: var(--white);
    box-shadow: var(--shadow-light);
}

.title-container {
    margin-top: 40px;
    padding: 20px 50px;
    border-radius: 20px;
}

.title-container-index {
    align-items: center;
    position: relative;
    margin: 1.4vw auto;
    padding: 1vw 4vw;
    border-radius: 1.04vw;
    width: 95%;
    max-width: 1800px;
    min-height: clamp(80px, 8vw, 150px);
}

.results-page .title-container-results {
    align-items: center;
    position: relative;
    margin: 10px auto 0 auto;
    padding: 1vw 4vw;
    border-radius: 1.04vw;
    width: 80%;
    max-width: 1200px;
    min-height: clamp(40px, 4vw, 75px);
}

.title-dash,
.title-index {
    font-weight: 700;
    color: var(--color-1);
    text-align: center;
    line-height: 1.1;
}

.title-dash {
    font-size: 4.7em;
    letter-spacing: 3px;
    padding: 15px 50px;
}

.title-with-images {
    width: 1650px; 
}

.title-index {
    font-size: clamp(16px, 4.5vw, 59px);
    letter-spacing: 0.15vw;
    margin: 0 !important;
    max-width: 60%;
}

.title-results {
    font-size: clamp(20px, 2.5vw, 40px);
    letter-spacing: 0.15vw;
    margin: 0 !important;
}

.title-container-index .image-item {
    position: absolute;
    display: flex;
    align-items: center;
}

.title-container-index .image-item:first-of-type { left: 2.6vw; }
.title-container-index .image-item:last-of-type  { right: 2.6vw; }

.title-container-index .image-item img {
    width: clamp(60px, 6.25vw, 120px);
    height: auto; 
    aspect-ratio: 1 / 1; 
    object-fit: contain;
}

.image-item img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    border-radius: 10px;
    background: var(--white);
}

/* --- Zegar / Timer --- */
.timer, 
.timer-mini, 
#timerContainerDash {
    background: linear-gradient(135deg, var(--base-3), var(--color-6-1));
    color: var(--color-11);
    font-weight: bold;
    text-align: center;
    box-shadow: var(--shadow-light);
}

.timer {
    font-size: clamp(30px, 7vw, 64px);
    margin: 20px 0;
    padding: 12px;
    border-radius: 8px;
}

.timer-mini {
    font-size: 12px;
    margin: 0;
    padding: 4px;
    border-radius: 2px;
}

#clock2 {
    display: flex;
    justify-content: center; 
    align-items: center;
    width: 100%;
    background: transparent;  
    margin-top: 0 !important; 
    padding: 0 !important; 
}

#timerContainerDash {
    font-size: 390px;  
    width: 1650px;        
    padding: 30px 50px;
    border-radius: 20px;
    box-shadow: var(--shadow-dark); 
}

/* --- Panel Administratora --- */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin: 30px auto;
    padding: 0 10px;
    max-width: 1000px;
}

.admin-card {
    background: var(--white);
    border-radius: 12px;
    padding: 25px 15px;
    text-decoration: none;
    color: var(--base-1);
    box-shadow: var(--shadow-light);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    border: 2px solid transparent;
}

.admin-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-dark);
    border-color: var(--color-2);
}

.admin-icon {
    font-size: 36px;
    line-height: 1;
    display: block;
}

.admin-text {
    font-size: 16px;
    font-weight: 700;
    text-align: center;
}

.admin-actions {
    margin-top: 40px;
    border-top: 2px solid var(--color-4);
    padding-top: 25px;
    display: flex;
    justify-content: center;
}

.admin-actions .btn {
    margin: 0;
    max-width: 300px;
}

.logged-in-info {
    position: absolute;
    bottom: 15px;
    right: 25px;
    font-size: 13px;
    color: var(--base-1);
    opacity: 0.7; 
}

/* --- Polityka Prywatności i Kontakt --- */
.privacy-content {
    text-align: left;
    line-height: 1.6;
    font-size: 16px;
    color: var(--base-1);
    margin-top: 30px;
    padding: 0 10px;
}

.privacy-content h2 {
    margin-top: 35px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--color-4);
    padding-bottom: 8px;
    font-size: 19px;
    color: var(--color-1);
}

.privacy-content p,
.privacy-content ul {
    margin-bottom: 15px;
}

.privacy-content ul {
    padding-left: 20px;
}

.privacy-content li {
    margin-bottom: 8px;
}

.privacy-content strong {
    color: var(--color-1);
}

.privacy-content em {
    font-size: 14.5px;
    color: var(--base-3);
}

.contact-logo {
    margin-bottom: 20px;
}

.contact-page .container img {
    width: 100%;
    max-width: 300px;
    height: auto;
    object-fit: contain;
}

/* --- Błąd 404 --- */
.error-404-container {
    text-align: center;
    padding: 40px 10px;
}

.error-code {
    font-size: clamp(80px, 8vw, 120px);
    font-weight: 700;
    color: var(--color-2);
    margin: 0;
    line-height: 1;
    text-shadow: var(--shadow-light);
}

.error-title {
    margin-top: 15px;
    font-size: clamp(24px, 3vw, 32px);
    color: var(--color-1);
}

.error-desc {
    margin: 20px auto 35px;
    max-width: 600px;
    font-size: 16px;
    color: var(--base-1);
    line-height: 1.5;
}

.error-actions {
    max-width: 400px;
    margin: 0 auto;
}

/* ========================================================================== */
/* 9. PRELOADER I ANIMACJE                                                    */
/* ========================================================================== */

body.loaded .hero-content {
    animation: fadeInUp 1s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
    animation-delay: 0.2s;
}

/* Globalny Preloader */
#preloader {
    position: fixed;
    inset: 0;
    background-color: var(--preloader-bg-color); 
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    visibility: visible;
}

#preloader.hidden {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.6s ease-out, visibility 0.6s ease-out;
}

/* Specyficzny preloader dla event-details-page */
.event-details-page .category-active-container {
    position: relative;
    min-height: 400px; 
}

.event-details-page #preloader {
    position: absolute; 
    align-items: flex-start;
    padding-top: 120px; 
    z-index: 50;
}

.preloader-text {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 1.1rem;
    color: #888888;
    animation: pulseText 1.5s ease-in-out infinite;
    text-align: center;
    padding: 0 20px;
    will-change: opacity, transform; 
}

.preloader-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px; 
}

/* --- STYLIZACJA PUZZLI W PRELOADERZE --- */
.puzzle-anim-container {
    display: flex;
    gap: 15px; 
}

.puzzle-piece {
    position: relative;
    width: 32px;  
    height: 32px;
    background-color: var(--puzzle-base-color);
    border-radius: 5px;
    animation: puzzlePulseLighter 1.8s infinite ease-in-out;
}

/* Krawędzie i wypustki */
.edge {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: block;
}

.edge.top { top: -6px; left: calc(50% - 6px); }
.edge.bottom { bottom: -6px; left: calc(50% - 6px); }
.edge.left { left: -6px; top: calc(50% - 6px); }
.edge.right { right: -6px; top: calc(50% - 6px); }

.edge.nub {
    background-color: var(--puzzle-pulse-light);
    animation: puzzlePulseAfterLighter 1.8s infinite ease-in-out;
}

.edge.hole {
    background-color: var(--white);
    animation: none !important; 
}

/* Animacje puzzli */
@keyframes puzzlePulseLighter {
    0%, 100% {
        transform: scale(0.9);
        background-color: var(--puzzle-pulse-light);
    }
    50% {
        transform: scale(1);
        background-color: var(--puzzle-pulse-dark);
    }
}

@keyframes puzzlePulseAfterLighter {
    0%, 100% { background-color: var(--puzzle-pulse-light); }
    50% { background-color: var(--puzzle-pulse-dark); }
}

/* Opóźnienia fali */
.puzzle-piece.p1, .puzzle-piece.p1 .edge.nub { animation-delay: 0.0s; }
.puzzle-piece.p2, .puzzle-piece.p2 .edge.nub { animation-delay: 0.2s; }
.puzzle-piece.p3, .puzzle-piece.p3 .edge.nub { animation-delay: 0.4s; }
.puzzle-piece.p4, .puzzle-piece.p4 .edge.nub { animation-delay: 0.6s; }