/* ============================================
   DARK THEME – PROFESSIONAL CAR PORTAL
   ============================================ */

:root {
    --bg-body: #0a0809;
    --bg-surface: #151112;
    --bg-surface-alt: #211b1c;
    --bg-elevated: #1a1516;
    --text-primary: #f5f0f0;
    --text-secondary: #a8a0a0;
    --text-muted: #746c6c;
    --border: #322a2b;
    --border-light: #443a3b;
    --primary: #dc2626;
    --primary-hover: #ef4444;
    --primary-glow: rgba(220, 38, 38, 0.25);
    --accent: #f87171;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.5);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --ease-premium: cubic-bezier(0.22, 1, 0.36, 1);
    --container: 1400px;
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background-color: var(--bg-body);
    /* Subtelna czerwona poświata u góry strony */
    background-image: radial-gradient(1100px 480px at 50% -220px, rgba(220, 38, 38, 0.08), transparent 70%);
    background-repeat: no-repeat;
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    /* Kolumna topbar -> main -> stopka; flex:1 na .page dopycha stopkę
       do dołu okna także na krótkich stronach (np. login). */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main.page {
    flex: 1;
    width: 100%;
}

/* ========== TYPOGRAPHY ========== */
h1, h2, h3, h4 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

/* ========== TOPBAR (NAVIGATION) ========== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(21, 17, 18, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar__container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    font-size: 1.6rem;
    font-weight: 700;
    background: linear-gradient(120deg, #fff 0%, #ef4444 45%, #991b1b 60%, #fff 100%);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    letter-spacing: -0.5px;
    animation: brand-shine 7s linear infinite;
}

@keyframes brand-shine {
    to { background-position: 200% center; }
}

.topbar__nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.topbar__nav a {
    padding: 8px 16px;
    border-radius: 40px;
    font-weight: 500;
    color: var(--text-secondary);
}

.topbar__nav a:hover {
    background: rgba(220, 38, 38, 0.12);
    color: var(--text-primary);
}

/* ========== MAIN LAYOUT ========== */
.page {
    max-width: var(--container);
    margin: 0 auto;
    padding: 40px 24px;
}

/* ========== FORM CARD (FILTERS + LIST) ========== */
.form-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.form-card h1 {
    position: relative;
    font-size: 2rem;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

/* Czerwony akcent pod nagłówkiem karty */
.form-card h1::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 72px;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--primary), transparent);
}

/* ========== FILTER FORM ========== */
/* Podwójna klasa wygrywa specyficznością z ogólną regułą .form (display:flex,
   zdefiniowaną niżej w pliku) - bez tego sekcje filtrów (siatka, lokalizacja,
   przyciski) układały się obok siebie zamiast jedna pod drugą. */
.form.filter-form {
    display: block;
    margin-bottom: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: var(--transition);
}

.form-group textarea {
    min-height: 130px;
    font-family: var(--font);
    resize: vertical;
}

/* Pole telefonu ze stałym prefiksem "+48" - prefiks i input wyglądają jak
   jedno pole (użytkownik wpisuje tylko 9 cyfr; +48 dokleja backend). */
.phone-field {
    display: flex;
    align-items: stretch;
}

.phone-field__prefix {
    display: flex;
    align-items: center;
    padding: 0 14px;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-light);
    border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    user-select: none;
}

.phone-field input {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
}

.filter-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* ========== STACKED FORM (dodaj/edytuj ogłoszenie) ==========
   Wariant formularza z sekcjami jedna pod drugą: siatka pól (.form-row),
   potem elementy pełnej szerokości (mapa, opis, zdjęcia, przycisk).
   Nadpisuje display:flex z ogólnej klasy .form. */
.form.form--stacked {
    display: block;
}

.form--stacked > .form-group {
    margin-bottom: 20px;
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* Wąski wariant dla prostych formularzy (rejestracja, logowanie) - pola
   jedno pod drugim nie rozciągają się na całą szerokość karty,
   a formularz jest wyśrodkowany w karcie. */
.form--narrow {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

/* Wiersz zgody z checkboxem (checkbox celowo poza .form-group, bo tamte
   reguły ustawiają inputom width:100%) */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 4px 0 16px;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-check label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    cursor: pointer;
}

.form-check a {
    color: var(--accent);
    text-decoration: underline;
}

.form-check a:hover {
    color: var(--primary-hover);
}

/* Pomocniczy link pod formularzem (np. "Nie pamiętam hasła") */
.form-link {
    margin-top: 14px;
    font-size: 0.9rem;
}

.form-link a {
    color: var(--text-secondary);
    text-decoration: underline;
    transition: var(--transition);
}

.form-link a:hover {
    color: var(--accent);
}

.map-card {
    margin: 4px 0 24px;
}

.map-card > label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

/* ========== FORM MESSAGES ========== */
.form-error {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.08);
    color: #fca5a5;
    border-radius: 12px;
    margin-bottom: 16px;
}

.errorlist {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    color: var(--accent);
    font-size: 0.85rem;
}

/* ========== BUTTONS ========== */
.btn {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn--primary {
    background: linear-gradient(135deg, #b91c1c, var(--primary));
    color: white;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
}

/* Przesuwający się refleks światła po najechaniu */
.btn--primary::after {
    content: "";
    position: absolute;
    top: 0;
    left: -130%;
    width: 60%;
    height: 100%;
    background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: skewX(-20deg);
    transition: left 0.55s var(--ease-premium);
}

.btn--primary:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(220, 38, 38, 0.45);
}

.btn--primary:hover::after {
    left: 140%;
}

.btn--secondary {
    background: var(--bg-surface-alt);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.btn--secondary:hover {
    background: var(--border-light);
    transform: translateY(-1px);
}

.btn--danger {
    background: var(--danger);
    color: white;
}

.btn--danger:hover {
    background: var(--danger-hover);
}

/* ========== RESULTS COUNT ========== */
.results-count {
    margin: 0 0 8px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.results-count span {
    color: var(--accent);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ========== ACTIVE FILTERS ========== */
.filter-count {
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.form-group select.is-active-filter,
.form-group input.is-active-filter {
    border-color: rgba(220, 38, 38, 0.55);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

/* ========== ANNOUNCEMENT LIST ========== */
.ogloszenia-lista {
    display: flex;
    flex-direction: column;
    gap: 28px;
    margin-top: 20px;
}

.item {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: transform 0.35s var(--ease-premium), box-shadow 0.35s var(--ease-premium), border-color 0.35s var(--ease-premium);
    animation: fade-in-up 0.6s var(--ease-premium) both;
}

/* Kaskadowe wejście kolejnych kart */
.ogloszenia-lista .item:nth-child(1) { animation-delay: 0.05s; }
.ogloszenia-lista .item:nth-child(2) { animation-delay: 0.12s; }
.ogloszenia-lista .item:nth-child(3) { animation-delay: 0.19s; }
.ogloszenia-lista .item:nth-child(4) { animation-delay: 0.26s; }
.ogloszenia-lista .item:nth-child(5) { animation-delay: 0.33s; }
.ogloszenia-lista .item:nth-child(6) { animation-delay: 0.40s; }
.ogloszenia-lista .item:nth-child(n+7) { animation-delay: 0.47s; }

.item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md), 0 0 28px rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.45);
}

.item__top {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

/* ========== SLIDER (IMAGE CAROUSEL) ========== */
.slider {
    position: relative;
    width: 280px;
    height: 190px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
}

.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.6s var(--ease-premium);
}

/* Delikatny zoom zdjęcia po najechaniu na kartę (kadr przycina .slider
   przez overflow:hidden) */
.item:hover .slide.active {
    transform: scale(1.06);
}

.slide.active {
    opacity: 1;
    z-index: 1;
}

.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.slider-btn:hover {
    background: var(--primary);
}

.slider-btn.prev {
    left: 8px;
}

.slider-btn.next {
    right: 8px;
}

.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.85rem;
    background: linear-gradient(110deg, var(--bg-surface-alt) 30%, #2c2426 45%, var(--bg-surface-alt) 60%);
    background-size: 200% 100%;
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    to { background-position: -200% 0; }
}

/* ========== ITEM INFO ========== */
.item__info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.item__price {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
    background: linear-gradient(120deg, var(--accent), var(--primary));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.modal__price {
    font-size: 1.6rem;
    margin-bottom: 12px;
}

.item__info h3 {
    font-size: 1.35rem;
    margin-bottom: 4px;
}

.item__info h3 a:hover {
    color: var(--accent);
}

.item__info p {
    color: var(--text-secondary);
    line-height: 1.5;
}

.item__owner {
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px dashed var(--border-light);
    padding-top: 8px;
    margin-top: 4px;
}

.item__actions {
    margin-top: 12px;
}

/* ========== MODAL (PREVIEW) ========== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal__content {
    width: min(1200px, 96vw);
    max-height: 90vh;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.modal__close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    font-size: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    transition: var(--transition);
}

.modal__close:hover {
    background: var(--danger);
    transform: scale(1.05);
}

.modal__body {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 28px;
    padding: 28px;
}

.modal__gallery {
    min-width: 0;
}

.modal__main {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-elevated);
}

.modal__main-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--bg-elevated);
}

.modal__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    transition: var(--transition);
    z-index: 2;
}

.modal__nav:hover {
    background: var(--primary);
}

.modal__nav--prev {
    left: 16px;
}

.modal__nav--next {
    right: 16px;
}

.modal__thumbs {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.modal__thumbs img {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    opacity: 0.6;
    border: 2px solid transparent;
    transition: var(--transition);
}

.modal__thumbs img.active {
    opacity: 1;
    border-color: var(--primary);
}

.modal__info {
    overflow-y: auto;
    padding-right: 8px;
    color: var(--text-primary);
}

.modal__info h2 {
    margin-bottom: 16px;
}

.modal__info p {
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
    .modal__body {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .item__top {
        flex-direction: column;
    }

    .slider {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 10;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .topbar__container {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .page {
        padding: 20px 16px;
    }

    .form-card {
        padding: 20px;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ========== FOOTER ========== */
.stopka {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.stopka__links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stopka a {
    color: var(--text-secondary);
    transition: var(--transition);
}

.stopka a:hover {
    color: var(--accent);
}

/* ========== UTILITIES ========== */
.placeholder {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
}

/*hero*/
.hero {
    min-height: calc(100vh - 140px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero__content {
    width: 100%;
    max-width: 760px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 44px;
    text-align: center;
}

.hero__content h1 {
    margin: 0 0 16px;
    font-size: clamp(2rem, 4vw, 3.25rem);
    line-height: 1.15;
}

.hero__content p {
    margin: 0 auto 28px;
    max-width: 620px;
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--muted);
}

.hero__actions {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

.admin-actions {
    display: flex;
    gap: 16px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.form {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-bottom: 28px;
}

.form-success {
    padding: 12px 14px;
    border: 1px solid #86efac;
    background: #f0fdf4;
    color: #166534;
    border-radius: 12px;
    margin-bottom: 16px;
}

#filterMapWrap {
    width: 100%;
}

#filterMap {
        height: 300px;
        width: 100%;
        border-radius: 12px;
        z-index: 11;
}

.form-group {
    min-width: 0;
}
.specs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

.specs span {
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
}

.item__specs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.item__specs span {
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition);
}

.item:hover .item__specs span {
    border-color: rgba(220, 38, 38, 0.35);
}

.modal__specs {
    margin: 14px 0;
    padding: 14px;
    border-radius: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
}

.modal__specs p {
    margin: 6px 0;
    color: var(--text-primary);
}

.modal__specs strong {
    color: var(--accent);
}

/* ========== PREMIUM MOTION ========== */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(22px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes modal-pop {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.form-card {
    animation: fade-in-up 0.55s var(--ease-premium) both;
}

.modal.active .modal__content {
    animation: modal-pop 0.35s var(--ease-premium) both;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
