﻿/* --- 1. USTAWIENIA GLOBALNE (Dla każdej strony) --- */
:root { --agro-green: #2c6e49; }

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    height: 100%;
    overflow-y: overlay;
    width: 100vw;
    overflow-x: hidden;
}

body {
    height: 100%;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
    width: 100vw;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

main { flex: 1 0 auto; }

.bg-agro { 
    background-color: var(--agro-green) !important; 
    padding: 10px 0 !important; /* Zwiększa wysokość belki o 60px z góry i z dołu */
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-height: auto; /* Pozwala belce rosnąć wraz z tekstem */
}

.card-agro { transition: transform 0.2s; border: none; border-radius: 12px; overflow: hidden; height: 100%; }
.card-agro:hover { transform: translateY(-5px); }
.img-container { height: 150px; overflow: hidden; background: #f8f9fa; }
.img-container img { width: 100%; height: 100%; object-fit: cover; }

.navbar {
border-radius: 0 !important;
    width: 100vw !important;
    left: 0;
    right: 0;
}
.search-section { padding: 40px 0; }

/* --- 3. MOJE KONTO (Sidebar) --- */
.sidebar-link { border: none; padding: 12px 20px; border-radius: 8px; margin-bottom: 5px; color: #444; text-decoration: none; display: flex; align-items: center; transition: 0.3s; }
.sidebar-link:hover { background: #e9ecef; color: var(--agro-green); }
.sidebar-link.active { background: var(--agro-green); color: white; }
.sidebar-link i { font-size: 1.2rem; width: 30px; }

/* --- 4. CZAT (STYL VINTED - ZMODYFIKOWANY) --- */

/* Zakładki nad czatem (Wiadomości / Powiadomienia) */
.vinted-tabs {
    background: #fff;
    padding: 0 10px;
    border-radius: 12px 12px 0 0; /* Zaokrąglenie tylko góry */
    border: 1px solid #dee2e6;
    border-bottom: none;
}

.vinted-tab {
    padding: 15px 20px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    font-size: 0.95rem;
    flex: 1;
    text-align: center;
    transition: color 0.2s;
}

.vinted-tab.active {
    color: #000;
    border-bottom: 3px solid var(--agro-green);
    font-weight: 700;
}

/* Główny kontener czatu */
.chat-container { 
    height: 600px; 
    background: #fff; 
    border-radius: 0 0 12px 12px; /* Zaokrąglenie tylko dołu, bo góra ma zakładki */
    overflow: hidden; 
    display: flex; 
    border: 1px solid #dee2e6;
    border-top: 1px solid #f0f0f0;
}

.chat-list { 
    width: 35%; 
    height: 100%; 
    overflow-y: auto; 
    background: #fff; 
    border-right: 1px solid #dee2e6; 
}

/* Styl pojedynczego elementu na liście rozmów */
.vinted-chat-item {
    transition: background-color 0.2s;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0 !important;
}

.vinted-chat-item:hover {
    background-color: #f8f9fa !important;
}

.chat-window { 
    width: 65%; 
    height: 100%; 
    display: flex; 
    flex-direction: column; 
    background: #fff;
}

.chat-messages { 
    flex-grow: 1; 
    overflow-y: auto; 
    padding: 15px; 
    background: #fff; /* Białe tło wewnątrz czatu jak na Vinted */
}

/* Dymki wiadomości */
.msg-bubble { 
    max-width: 85%; 
    padding: 10px 14px; 
    border-radius: 18px; 
    margin-bottom: 8px; 
    font-size: 0.95rem; 
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.msg-sent { 
    background: #dcf8c6; /* Jasnozielony dla wysłanych */
    margin-left: auto; 
    border-bottom-right-radius: 4px; 
}

.msg-received { 
    background: #f1f0f0; /* Szary dla odebranych */
    margin-right: auto; 
    border-bottom-left-radius: 4px; 
}

.msg-time { 
    font-size: 0.65rem; 
    opacity: 0.6; 
    margin-left: 8px;
    vertical-align: bottom;
}

.active-user { 
    background-color: #f0f2f5 !important; 
    border-left: 4px solid var(--agro-green) !important; 
}

/* Pomocnicza klasa do ukrywania na mobile */
.mobile-hide { display: block; }

/* --- 5. MOBILE TAB BAR (Ukryty na komputerze) --- */
.mobile-tab-bar { display: none; }

/* --- 6. STYLE MOBILNE (Tylko poniżej 768px) --- */
@media (max-width: 767px) {
    body { padding-bottom: 80px !important; }
    footer { display: none !important; }
    #sidebar { display: none; } /* Ukrywamy boczny panel na mobile */

    .mobile-tab-bar {
        position: fixed; bottom: 0; left: 0; right: 0; height: 65px;
        background: #fff; display: flex; justify-content: space-around;
        align-items: center; box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 1050; border-top: 1px solid #eee;
    }

    .mobile-tab-bar a {
        text-decoration: none; color: #666; display: flex;
        flex-direction: column; align-items: center; font-size: 0.7rem;
        flex: 1; position: relative;
    }

    .mobile-tab-bar a i { font-size: 1.5rem; margin-bottom: 2px; transition: transform 0.2s; }
    .mobile-tab-bar a.active { color: var(--agro-green); }
    .mobile-tab-bar a.active i { transform: scale(1.1); }

    .tab-center { position: relative; top: -15px; }
    .add-icon {
        width: 50px; height: 50px; background: var(--agro-green); color: white;
        border-radius: 50%; display: flex; align-items: center; justify-content: center;
        box-shadow: 0 4px 10px rgba(44, 110, 73, 0.4); border: 4px solid #fff;
    }
    .add-icon i { font-size: 1.8rem !important; margin-bottom: 0 !important; }

    /* --- POPRAWKI DO CZATU NA MOBILE --- */
    .container.my-4.my-md-5 { margin-top: 0 !important; padding-top: 10px; margin-bottom: 0 !important; }
    
    /* Zakładki na pełną szerokość */
    .vinted-tabs {
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: none;
        margin-left: -12px; /* Kompensacja paddingu kontenera Bootstrap */
        margin-right: -12px;
        padding-bottom: 0;
    }
    
    .chat-container { 
        /* Wysokość: cały ekran minus header(ok. 60px) minus navbar(ok. 65px) minus zakładki */
        height: calc(100vh - 180px); 
        flex-direction: column; 
        border: none;
        border-radius: 0;
    }

    /* Ukrywanie elementów w zależności od widoku (lista vs rozmowa) */
    .chat-list.mobile-hide, .chat-window.mobile-hide { display: none !important; }
    
    .chat-list, .chat-window { width: 100% !important; }
    
    /* Gdy otwarte jest okno czatu, chcemy by było na cały ekran */
    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100% !important;
        z-index: 2000; /* Przykrywa wszystko łącznie z navbarami */
        padding-bottom: 0;
    }

    /* Formularz wpisywania na dole w oknie czatu */
    .chat-window form {
        padding-bottom: 10px;
    }
}
/* --- POPRAWKI DLA KOMPUTERA (DESKTOP) --- */
@media (min-width: 768px) {

    /* 1. Proporcje: Węższa lista osób, szerszy czat */
    .chat-list { 
        width: 25% !important; 
        background: #fff;
    }
    
    .chat-window { 
        width: 75% !important; 
        background: #fff;
    }



    /* Nagłówek czatu (tam gdzie jest imię rozmówcy) */
    .chat-window .border-bottom {
        height: 60px;
        background-color: #fff;
        display: flex;
        align-items: center;
        padding-left: 20px;
        border-bottom: 1px solid #dee2e6 !important;
        position: relative; /* Zapobiega nachodzeniu na inne elementy */
        z-index: 1;
    }

    /* 3. Zakładki (Wiadomości/Powiadomienia) */
    .vinted-tabs {
        height: 60px;
        display: flex;
        align-items: center;
        background-color: #f8f9fa;
        border-bottom: 1px solid #dee2e6;
        padding: 0;
    }
    
    .vinted-tab {
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1;
        font-size: 0.85rem; /* Mniejsza czcionka, żeby się mieściło w wąskim panelu */
        background: #f8f9fa;
        border-bottom: 3px solid transparent;
        transition: 0.2s;
    }
    
    .vinted-tab.active {
        background: #fff;
        border-bottom: 3px solid var(--agro-green);
        color: var(--agro-green);
        font-weight: bold;
    }

    /* 4. Scrollbary (Cienkie i estetyczne) */
    .chat-list::-webkit-scrollbar,
    .chat-messages::-webkit-scrollbar {
        width: 6px;
    }
    .chat-list::-webkit-scrollbar-thumb,
    .chat-messages::-webkit-scrollbar-thumb {
        background: #ddd;
        border-radius: 10px;
    }

    /* 5. Lista rozmów i dymki */
    .vinted-chat-item {
        padding: 12px !important;
        border-bottom: 1px solid #f5f5f5 !important;
    }

    .active-user {
        background-color: #f0f7f2 !important; 
        border-left: 4px solid var(--agro-green) !important;
    }

    .chat-messages {
        background-color: #fff;
        padding: 25px;
    }

    .msg-bubble {
        max-width: 70%; /* Szersze dymki w szerszym oknie */
        box-shadow: 0 1px 2px rgba(0,0,0,0.08);
        margin-bottom: 12px;
    }

    /* Formularz na dole */
    .chat-window form {
        padding: 15px 25px;
        background: #fff;
        border-top: 1px solid #eee;
    }

    #messageText {
        border-radius: 20px;
        padding: 10px 20px;
        background: #f1f3f4;
        border: 1px solid transparent;
    }
}
/* --- 2. KOMPONENTY GLOBALNE --- */

.btn-agro { background-color: var(--agro-green); color: white; border: none; }
.btn-agro:hover { background-color: #1e4a32; color: white; }
.form-container { background: white; border-radius: 15px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); padding: 30px; }
.main-card { border: none; border-radius: 12px; overflow: hidden; background: white; }

.price-text { color: var(--agro-green); font-size: 2rem; font-weight: 800; }

.section-header {
    color: var(--agro-green);
    border-bottom: 3px solid var(--agro-green);
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-weight: bold;
}

/* Promocje — ramki kart */
.card-promoted-highlight { border: 2px solid #f0b429 !important; box-shadow: 0 4px 20px rgba(240,180,41,0.35) !important; }
.card-promoted-urgent    { border: 2px solid #e53e3e !important; box-shadow: 0 4px 20px rgba(229,62,62,0.25) !important; }
.card-promoted-pin       { border: 2px solid #805ad5 !important; box-shadow: 0 4px 20px rgba(128,90,213,0.25) !important; }

/* Promocje — badge na zdjęciu */
.promo-badge {
    position: absolute; top: 10px; left: 10px; z-index: 6;
    font-size: 0.72rem; font-weight: 700; padding: 3px 8px;
    border-radius: 6px; letter-spacing: 0.03em; text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}
.promo-badge-highlight { background: #f0b429; color: #5a3e00; }
.promo-badge-pin       { background: #805ad5; color: #fff; }
.promo-badge-urgent    { background: #e53e3e; color: #fff; }
.promo-badge-refresh   { background: #3182ce; color: #fff; }

/* Konto — komponenty */
.account-wrapper { margin-top: 15px !important; }
.mobile-menu-link {
    display: flex; align-items: center; padding: 18px 15px; background: white;
    border-bottom: 1px solid #f0f0f0; color: #333; text-decoration: none;
    font-size: 1rem; transition: background 0.2s;
}
.mobile-menu-link:hover { background: #f9f9f9; color: var(--agro-green); }
.avatar-preview {
    width: 100px; height: 100px; border-radius: 50%; object-fit: cover;
    border: 3px solid #fff; box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* Promocje — wybór opcji */
.promo-option { transition: 0.15s; }
.promo-option:hover { background: #fffbf0; border-color: #f0b429 !important; }
.promo-option.selected { background: #fffbf0; border-color: #f0b429 !important; border-width: 2px !important; }

/* ===== Custom Category Dropdown ===== */
.cat-dropdown { position: relative; width: 100%; }
.cat-dropdown-toggle {
    display: flex; align-items: center; justify-content: space-between;
    background: #fff; cursor: pointer; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.cat-dropdown-toggle:focus { outline: none; box-shadow: 0 0 0 0.2rem rgba(25,135,84,.25); }
.cat-chevron { flex-shrink: 0; margin-left: 6px; transition: transform .2s; }
.cat-dropdown.open .cat-chevron { transform: rotate(180deg); }
.cat-dropdown-menu {
    display: none; position: absolute; top: calc(100% + 4px); left: 0;
    width: 100%; min-width: 220px; background: #fff;
    border: 1px solid #dee2e6; border-radius: 0.375rem;
    box-shadow: 0 4px 16px rgba(0,0,0,.12); z-index: 1050;
    max-height: 340px; overflow-y: auto;
}
.cat-dropdown.open .cat-dropdown-menu { display: block; }
.cat-item {
    padding: 8px 12px; cursor: pointer; display: flex;
    align-items: center; justify-content: space-between;
    font-size: 0.92rem; color: #212529; user-select: none;
}
.cat-item:hover { background: #f0f9f4; color: #198754; }
.cat-item-active { background: #d1e7dd; color: #0f5132; font-weight: 600; }
.cat-expand-btn {
    background: none; border: none; padding: 2px 4px; cursor: pointer;
    color: #6c757d; line-height: 1; flex-shrink: 0;
    border-radius: 4px; transition: background .15s;
}
.cat-expand-btn:hover { background: #dee2e6; color: #198754; }
.cat-expand-btn i { transition: transform .2s; font-size: 0.8rem; }
.cat-expand-btn.expanded i { transform: rotate(90deg); }
.cat-subcats { display: none; background: #f8f9fa; }
.cat-subcats.open { display: block; }
.cat-subitem { padding-left: 28px; font-size: 0.88rem; color: #495057; border-left: 3px solid #c3e6cb; }
.cat-subitem:hover { background: #e8f5e9; color: #198754; }