/* ==========================================================================
   1. FUNDAMENTY, IMPORTY I ZMIENNE (ROOT)
   Tutaj definiujesz czcionki oraz główną paletę kolorów dla obu motywów.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
    /* --- JASNY MOTYW (Pustynny Brzask) --- */
    --card-bg: rgba(255, 255, 255, 0.3);
    --card-blur: blur(25px);
    --text-main: #401F18;
    --text-muted: #73321A;
    
    --primary: #D97652;        /* Kolor główny (Terakota) */
    --primary-hover: #BF5E3B;
    --top-color: #F2AB91;      /* Akcent dla top produktów */
    --top-bg: rgba(242, 171, 145, 0.4);
    
    --price-color: #10B981;    /* Zielony dla ceny */
    --edit-color: #3B82F6;     /* Niebieski edycji */
    --delete-color: #EF4444;   /* Czerwony usuwania */
    
    --border-main: rgba(255, 255, 255, 0.5);
    --border-light: rgba(255, 255, 255, 0.2);
    --input-bg: rgba(255, 255, 255, 0.6);
    
    --shadow-sm: 0 8px 32px 0 rgba(115, 50, 26, 0.1);
    --shadow-md: 0 8px 32px 0 rgba(115, 50, 26, 0.15);
    --shadow-lg: 0 10px 40px 0 rgba(115, 50, 26, 0.2);
    --radius-md: 12px;
    --radius-lg: 20px;
}

html.dark-mode {
    /* --- CIEMNY MOTYW (Arktyczna Noc & Piasek) --- */
    --card-bg: rgba(33, 46, 81, 0.6);
    --text-main: #d7d4b4;
    --text-muted: #cac5a2;
    
    --primary: #466a89;        /* Stalowy błękit */
    --primary-hover: #b5cad1;
    
    --border-main: rgba(181, 202, 209, 0.2);
    --border-light: rgba(181, 202, 209, 0.1);   
    
    --input-bg: rgba(33, 46, 81, 0.7);
    --top-bg: rgba(70, 106, 137, 0.3);
    
    --shadow-sm: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 8px 32px 0 rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 10px 40px 0 rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   2. STYLE GLOBALNE I BODY
   Ustawienia tła strony i główne parametry tekstu.
   ========================================================================== */
body {
    font-family: 'Poppins', sans-serif;
    color: var(--text-main);
    margin: 0; 
    padding: 20px 0; /* Padding tylko góra/dół, boki kontroluje .container */
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    transition: background 0.5s, color 0.3s;
    background: linear-gradient(135deg, #F2AB91 0%, #D97652 30%, #73321A 100%);
    background-attachment: fixed;
}

html.dark-mode body {
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #425759 100%);
    background-attachment: fixed;
}

/* Uniwersalny efekt szklanego panelu (Glassmorphism) */
.panel, .main-menu, .card, .top3-showcase, .total-info, .login-panel {
    backdrop-filter: var(--card-blur);
    -webkit-backdrop-filter: var(--card-blur);
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-main); 
}

/* Poprawka dla chipów, aby nie miały domyślnej ramki, gdy nadajemy własną */
.chip {
    border: 2px solid transparent; 
    transition: all 0.3s ease;
}

/* ==========================================================================
   3. LOGO I NAGŁÓWEK (HEADER)
   Sekcja odpowiadająca za logo na górze strony.
   ========================================================================== */
.main-header {
    width: 100%; 
    max-width: 1200px;
    margin: 0 auto 20px auto; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 0 10px;
    box-sizing: border-box;
}

.logo-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.main-logo {
    height: 100px;
    width: auto;
    display: block;
}

/* ==========================================================================
   4. MENU NAWIGACYJNE I PRZYCISKI (NAV)
   Style dla przycisków kategorii i paska nawigacji.
   ========================================================================== */
.main-menu { 
    width: 100%; 
    display: flex; 
    gap: 10px; 
    margin-bottom: 35px; 
    flex-wrap: wrap; 
    align-items: center;
    padding: 12px 20px; 
    border-radius: 20px;
    box-sizing: border-box; 
}

.nav-btn, .chip {
    padding: 8px 15px; 
    border: none; 
    background: transparent; 
    color: var(--text-muted); 
    border-radius: 12px;
    cursor: pointer; 
    font-weight: 600; 
    font-size: 0.95rem; 
    text-decoration: none;
    transition: all 0.2s; 
    display: flex; 
    align-items: center; 
    gap: 8px;
}

.nav-btn:hover, .chip:hover { 
    color: var(--text-main); 
    background: rgba(128, 128, 128, 0.1); 
}

.nav-btn.active, .chip.active { 
    background: var(--primary); 
    color: white !important; 
    box-shadow: var(--shadow-sm); 
}

/* Sekcja profilu wewnątrz menu */
.nav-profile-section { 
    margin-left: auto; 
    display: flex; 
    align-items: center; 
    gap: 15px; 
    flex-wrap: wrap; 
}

.nav-username { 
    color: var(--primary); 
    font-weight: 700; 
    text-decoration: none; 
    transition: color 0.2s; 
}

.logout-btn { 
    color: var(--delete-color) !important; 
    margin: 0; 
}

/* ==========================================================================
   5. KARTY MARZEŃ I GABLOTKA TOP 3
   Wygląd przedmiotów na liście oraz w specjalnej gablotce.
   ========================================================================== */
.top3-showcase { 
    padding: 30px 20px; 
    margin: 0 auto 40px auto; 
    width: 100%; 
    box-sizing: border-box;
}

/* SZTYWNY podział gablotki na 3 kolumny obok siebie (żadnego flexa i przewijania) */
.top3-grid { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 25px; 
}

#dream-container { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
    gap: 25px; 
    width: 100%; 
    max-width: 1200px; 
}

/* --- Karta przedmiotu --- */
.card { 
    overflow: hidden; 
    position: relative; 
    transition: all 0.3s; 
    display: flex; 
    flex-direction: column;
}

.card:hover { 
    transform: translateY(-5px); 
    box-shadow: var(--shadow-lg); 
}

.top-card { 
    width: 100% !important; 
    flex: 0 0 auto; 
}

/* --- Nowe Menu Pod Trzema Kropkami (Zastąpiło stary rozjeżdżający się Action-Btns) --- */
.card-options-wrapper {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
}

.options-trigger-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: rgba(33, 46, 81, 0.75) !important;
    color: white;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.options-trigger-btn:hover {
    background: var(--primary) !important;
    transform: scale(1.05);
}

.card-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 36px;
    background: var(--card-bg);
    backdrop-filter: var(--card-blur);
    -webkit-backdrop-filter: var(--card-blur);
    border: 1px solid var(--border-main);
    border-radius: var(--radius-md);
    min-width: 150px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.card-dropdown-menu.show {
    display: flex;
    flex-direction: column;
}

.card-dropdown-menu button {
    width: 100%;
    padding: 10px 14px;
    background: transparent !important;
    border: none;
    border-radius: 0 !important;
    color: var(--text-main);
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin: 0 !important;
}

.card-dropdown-menu button:hover {
    background: rgba(255, 255, 255, 0.15) !important;
}

html.dark-mode .card-dropdown-menu button:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

/* --- Zdjęcie i zawartość karty --- */
.card img { 
    width: 100%; 
    height: 200px; 
    object-fit: cover; 
    background: var(--border-light);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.card-content { 
    padding: 20px; 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
}

.card h3 { 
    margin: 0 0 5px 0; 
    font-size: 1.2rem; 
}

/* --- Opis przedmiotu --- */
.card-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1; 
}

/* --- Cena i przycisk dolny --- */
.price-tag { 
    margin-top: auto; 
    margin-bottom: 15px; 
    color: var(--price-color); 
    font-weight: 700; 
    font-size: 1.3rem; 
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

/* ==========================================================================
   6. FORMULARZE, PANELE I STEROWANIE
   Style dla inputów, textarea oraz paneli sterowania listą.
   ========================================================================== */
.panel { 
    padding: 30px; 
    border-radius: var(--radius-lg); 
    margin: 0 auto 20px auto; 
    max-width: 800px; 
    width: 100%; 
    box-sizing: border-box; 
}

input, textarea, select { 
    width: 100%; 
    padding: 14px; 
    margin: 8px 0 16px 0; 
    border: 1px solid var(--border-main); 
    background: var(--input-bg); 
    border-radius: var(--radius-md); 
    box-sizing: border-box; 
    color: var(--text-main); 
    font-size: 0.95rem; 
    font-family: 'Poppins', sans-serif; 
}

input:focus, textarea:focus, select:focus { 
    outline: none; 
    border-color: var(--primary); 
}

.main-btn { 
    width: 100%; 
    padding: 14px; 
    background: var(--primary); 
    color: white; 
    border: none; 
    border-radius: var(--radius-md); 
    cursor: pointer; 
    font-weight: 600; 
    transition: all 0.2s; 
    font-size: 1rem; 
    text-align: center; 
    display: block; 
    box-sizing: border-box; 
    text-decoration: none; 
}

.main-btn:hover { 
    background: var(--primary-hover); 
    transform: translateY(-1px); 
}

.container { 
    width: 95%; 
    max-width: 1200px; 
    margin: 0 auto; 
    box-sizing: border-box;
}

.list-controls { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    width: 100%; 
    max-width: 1200px; 
    margin-bottom: 25px; 
    flex-wrap: wrap; 
    gap: 15px; 
}

.nav-scroll { 
    display: flex; 
    gap: 10px; 
    flex-wrap: wrap; 
}

.total-info { 
    padding: 10px 20px; 
    border-radius: var(--radius-md); 
    font-weight: 600; 
}

.sortable-ghost { opacity: 0.4; }

input:invalid {
    border-color: var(--delete-color);
    background: rgba(239, 68, 68, 0.05);
}

.text-link {
    color: var(--primary); 
    text-decoration: underline; 
    cursor: pointer; 
    font-weight: 600; 
    transition: color 0.2s ease; 
}

.text-link:hover {
    color: var(--primary-hover); 
    text-decoration: none; 
}

/* ==========================================================================
   7. STRONA LOGOWANIA (AUTH)
   Specyficzne style dla formularzy logowania i rejestracji.
   ========================================================================== */
.login-panel {
    max-width: 450px;
    width: 90%;
    margin: 50px auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg) !important;
}

.login-panel-header {
    background-color: #15656d;
    padding: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid var(--border-main);
}

.login-panel-logo { height: 100px; width: auto; }

.login-panel-content { padding: 30px; }

.hidden { display: none !important; }

.input-group {
    margin-bottom: 20px; 
    position: relative;
    width: 100%;
}

.pass-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    margin-top: 7px;
}

.pass-wrapper input {
    width: 100%;
    padding-right: 45px !important; 
    margin: 0 !important; 
}

.toggle-password {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%); 
    cursor: pointer;
    font-size: 1.2rem;
    user-select: none;
    z-index: 10;
    line-height: 1;
    display: none; 
}

/* ==========================================================================
   8. RESPONSYWNOŚĆ (MEDIA QUERIES)
   Poprawki wyglądu dla urządzeń mobilnych i tabletów.
   ========================================================================== */
@media (max-width: 768px) {
    .main-logo { height: 45px; }
    
    .main-menu { 
        padding: 15px; 
        border-radius: 15px; 
        flex-direction: column; 
        gap: 15px;
    }
    
    .nav-profile-section { 
        margin-left: 0; 
        width: 100%; 
        justify-content: center; 
        border-top: 1px solid var(--border-light); 
        padding-top: 15px; 
    }
    
    .nav-scroll { 
        flex-wrap: wrap;
        justify-content: center;
        padding-bottom: 0;
    }
    
    .top3-showcase { padding: 15px 10px; }
    
    /* Gwarancja 3 wąskich kolumn w Gablotce na telefonie bez możliwości scrolla bocznego */
    .top3-grid { 
        display: grid !important; 
        grid-template-columns: repeat(3, 1fr) !important; 
        gap: 8px !important; 
    }
    
    #dream-container { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    
    .card img { height: 110px; }
    .card h3 { font-size: 0.8rem; margin-bottom: 5px; }
    .card-description { display: none; } 
    
    .price-tag { font-size: 0.95rem; margin-bottom: 10px; padding-top: 5px; }

    /* POPRAWKA MOBILNA: Rozciąganie menu rozwijanego na całą szerokość karty */
    .card-options-wrapper {
        position: static;
    }

    .options-trigger-btn {
        position: absolute;
        top: 10px;
        right: 10px;
    }

    .card-dropdown-menu {
        right: 8px !important;
        left: 8px !important;
        top: 46px !important;
        min-width: 0 !important;
        width: auto !important;
    }
}

/* ==========================================================================
   9. MODALE - WSPÓLNE STYLE DLA TŁA (OVERLAY)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none; 
    justify-content: center;
    align-items: center;
    z-index: 1000; 
}

#custom-confirm {
    z-index: 9999; 
}

@keyframes modalAppear {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-content {
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    position: relative;
    animation: modalAppear 0.3s ease-out;
}

.close-modal {
    position: absolute;
    top: 15px; right: 15px;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    color: var(--text-muted);
}

.modal-img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    background: rgba(0,0,0,0.1);
}

.modal-info-grid {
    display: grid;
    gap: 15px;
    margin-top: 20px;
}

.modal-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
}

.modal-confirm-content {
    max-width: 400px;
    width: 90%;
    text-align: center;
    padding: 30px;
    animation: modalAppear 0.3s ease-out;
}

.modal-confirm-content h3 {
    margin-top: 0;
    color: var(--primary);
}

.modal-confirm-content p {
    margin-bottom: 25px;
    color: var(--text-muted);
}

.modal-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.theme-btn { display: none !important; }

/* ==========================================================================
   10. PRZYCISK POWROTU NA GÓRĘ STRONY (SCROLL-TO-TOP)
   ========================================================================== */
.scroll-to-top-btn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 45px;
    height: 45px;
    background: rgba(33, 46, 81, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-main);
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    display: none; 
    align-items: center;
    justify-content: center;
    z-index: 999;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
}

.scroll-to-top-btn:hover {
    background: var(--primary);
    transform: translateY(-3px);
}

html.dark-mode .scroll-to-top-btn {
    color: var(--text-main);
    background: rgba(33, 46, 81, 0.85);
}

@media (max-width: 768px) {
    .scroll-to-top-btn {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
    }
}