/* =========================================================
   Пламби — стили
   ========================================================= */

:root {
    --green: #00aa4b;
    --green-hover: #009140;
    --green-light: #e8f7ef;
    --blue: #00a5ff;
    --red: #e53e3e;
    --yellow: #f5b400;
    --text: #1a1a1a;
    --muted: #777c80;
    --bg: #f7f8fa;
    --card-bg: #ffffff;
    --border: #e5e8eb;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.12);
    --radius: 10px;
    --header-h: 64px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

img { max-width: 100%; display: block; }

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-hover); }

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ---------- Кнопки ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    background: none;
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
    white-space: nowrap;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-hover); color: #fff; }
.btn-outline { background: #fff; border-color: var(--green); color: var(--green); }
.btn-outline:hover { background: var(--green-light); color: var(--green-hover); }
.btn-danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-sm { padding: 8px 14px; font-size: 14px; }
.btn-block { width: 100%; }

.btn-fav { background: #fff; border-color: var(--border); color: var(--text); }
.btn-fav:hover { border-color: var(--red); color: var(--red); }
.btn-fav.active { background: #fff5f5; border-color: var(--red); color: var(--red); }
.btn-fav .fav-heart { font-size: 18px; line-height: 1; }

/* ---------- Шапка ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
    border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: var(--header-h); }

.logo { display: inline-flex; align-items: center; gap: 10px; }
.logo-mark {
    width: 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--green); color: #fff;
    font-size: 20px; font-weight: 800;
    border-radius: 10px;
}
.logo-text { font-size: 22px; font-weight: 800; color: var(--text); }
.logo:hover .logo-text { color: var(--green); }

.header-search { flex: 1; display: flex; max-width: 520px; }
.header-search input {
    flex: 1;
    min-width: 0;
    height: 42px;
    padding: 0 16px;
    border: 2px solid var(--green);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    outline: none;
}
.header-search input:focus { border-color: var(--green); }
.header-search button {
    height: 42px;
    padding: 0 22px;
    background: var(--green);
    color: #fff;
    font-weight: 600;
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
}
.header-search button:hover { background: var(--green-hover); }

.header-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }

/* Выпадающее меню пользователя */
.user-menu { position: relative; }
.user-menu-btn {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 6px 12px;
    background: none; border: none;
    font-weight: 600; color: var(--text);
    border-radius: var(--radius);
}
.user-menu-btn:hover { background: var(--bg); }
.avatar {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--green-light); color: var(--green);
    font-weight: 700; border-radius: 50%;
    text-transform: uppercase;
}
.avatar-lg { width: 48px; height: 48px; font-size: 20px; }
.avatar-xxl { width: 84px; height: 84px; font-size: 36px; }
.user-menu-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    min-width: 200px;
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    padding: 6px;
    display: none;
    z-index: 200;
}
.user-menu-dropdown.open { display: block; }
.user-menu-dropdown a {
    display: block; padding: 10px 14px;
    color: var(--text); border-radius: 6px;
    font-weight: 500;
}
.user-menu-dropdown a:hover { background: var(--bg); color: var(--text); }
.user-menu-dropdown a.danger { color: var(--red); }

.menu-toggle {
    display: none;
    flex-direction: column; justify-content: center; gap: 4px;
    width: 42px; height: 42px;
    background: none; border: none;
    padding: 8px;
}
.menu-toggle span {
    display: block; height: 3px; width: 100%;
    background: var(--text); border-radius: 2px;
    transition: transform .2s, opacity .2s;
}
.menu-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Панель категорий ---------- */
.category-bar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: var(--header-h);
    z-index: 90;
}
.category-bar-inner {
    display: flex; gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.category-bar-inner::-webkit-scrollbar { display: none; }
.category-bar-inner a {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 14px;
    color: var(--text); font-size: 14px; font-weight: 500;
    border-radius: 8px 8px 0 0;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}
.category-bar-inner a:hover { background: var(--bg); color: var(--text); }
.category-bar-inner a.active { color: var(--green); border-bottom-color: var(--green); background: var(--green-light); }
.cat-icon { font-size: 18px; }

/* ---------- Флеш / алерты ---------- */
.flash {
    margin: 16px 0 0;
    padding: 12px 18px;
    border-radius: var(--radius);
    font-weight: 500;
    border: 1px solid transparent;
}
.flash-success { background: var(--green-light); border-color: var(--green); color: var(--green-hover); }
.flash-error { background: #fdeeee; border-color: var(--red); color: var(--red); }
.flash-info { background: #e8f4fd; border-color: var(--blue); color: #086da8; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-danger { background: #fdeeee; border: 1px solid #f5b8b8; color: var(--red); }

/* ---------- Контент ---------- */
.main { flex: 1; padding-top: 24px; padding-bottom: 40px; }

.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-title { font-size: 24px; font-weight: 700; }
.section-count { color: var(--muted); }
.section-link { font-weight: 600; font-size: 14px; }

/* ---------- Hero ---------- */
.hero {
    background: linear-gradient(135deg, #00aa4b 0%, #00c25a 55%, #00d970 100%);
    color: #fff;
    border-radius: 16px;
    padding: 48px 40px;
    margin-top: 20px;
}
.hero h1 { font-size: 34px; font-weight: 800; margin-bottom: 8px; }
.hero p { font-size: 17px; opacity: .95; margin-bottom: 24px; }
.hero .btn-primary { background: #fff; color: var(--green); }
.hero .btn-primary:hover { background: var(--green-light); }

/* ---------- Сетки ---------- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.category-card {
    display: flex; flex-direction: column; gap: 6px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 16px;
    color: var(--text);
    transition: box-shadow .15s, transform .15s, border-color .15s;
}
.category-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); border-color: var(--green); color: var(--text); }
.category-icon { font-size: 30px; }
.category-name { font-weight: 600; }
.category-count { font-size: 13px; color: var(--muted); }

.ads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
}

/* ---------- Карточка объявления ---------- */
.ad-card {
    display: flex; flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    color: var(--text);
    transition: box-shadow .15s, transform .15s;
}
.ad-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); color: var(--text); }

.card-photo {
    aspect-ratio: 4 / 3;
    background: #f0f2f4;
    overflow: hidden;
}
.card-photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.ad-card:hover .card-photo img { transform: scale(1.05); }
.card-photo-empty {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: #b3b9bf;
    font-size: 13px;
    background: repeating-linear-gradient(45deg, #f0f2f4, #f0f2f4 10px, #f6f7f9 10px, #f6f7f9 20px);
}

.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-price { font-size: 18px; font-weight: 700; color: var(--text); }
.card-title {
    font-size: 14px; color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}
.card-meta {
    display: flex; justify-content: space-between; gap: 8px;
    margin-top: 6px;
    font-size: 12px; color: var(--muted);
}

/* ---------- Пагинация ---------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.page {
    min-width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 10px;
    background: #fff; border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text); font-weight: 600;
}
.page:hover { border-color: var(--green); color: var(--green); }
.page.active { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------- Пустое состояние ---------- */
.empty-state {
    text-align: center;
    background: #fff;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
}
.empty-state p { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.empty-state span { color: var(--muted); }

/* ---------- Хлебные крошки ---------- */
.breadcrumbs {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--muted);
    margin-bottom: 16px; flex-wrap: wrap;
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--green); }

/* ---------- Страница объявления ---------- */
.ad-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 28px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
}
.ad-gallery { min-width: 0; }
.ad-photo {
    width: 100%;
    border-radius: 12px;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #f0f2f4;
}
.ad-photo-empty {
    display: flex; align-items: center; justify-content: center;
    color: #b3b9bf; font-size: 16px;
    background: repeating-linear-gradient(45deg, #f0f2f4, #f0f2f4 12px, #f6f7f9 12px, #f6f7f9 24px);
}

.ad-info { display: flex; flex-direction: column; gap: 14px; }
.ad-price { font-size: 30px; font-weight: 800; }
.ad-title { font-size: 20px; font-weight: 600; line-height: 1.3; }
.ad-meta {
    display: flex; flex-wrap: wrap; gap: 8px 18px;
    font-size: 13px; color: var(--muted);
}
.ad-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.ad-seller {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
}
.seller-name { display: flex; align-items: center; gap: 12px; }
.seller-title { font-weight: 700; }
.seller-sub { font-size: 12px; color: var(--muted); }
.seller-phone {
    text-align: center;
    font-size: 22px; font-weight: 800;
    color: var(--green);
    background: var(--green-light);
    border: 1px dashed var(--green);
    border-radius: 10px;
    padding: 10px;
}

.ad-description { border-top: 1px solid var(--border); padding-top: 14px; }
.ad-description h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.ad-description p { color: #333; white-space: pre-wrap; }

/* ---------- Формы ---------- */
.form-wrap, .auth-wrap { max-width: 640px; margin: 0 auto; }
.auth-wrap { max-width: 440px; }
.auth-form {
    background: #fff; border: 1px solid var(--border);
    border-radius: 16px; padding: 32px;
    margin-top: 20px;
}
.auth-form h1 { font-size: 26px; margin-bottom: 4px; }
.auth-sub { color: var(--muted); margin-bottom: 20px; }
.auth-alt { margin-top: 16px; font-size: 14px; text-align: center; color: var(--muted); }
.auth-alt.hint { font-size: 13px; }

.form-wrap h1 { font-size: 26px; margin-bottom: 20px; }

.form, .auth-form { display: flex; flex-direction: column; gap: 16px; }

.form-wrap .form {
    background: #fff; border: 1px solid var(--border);
    border-radius: 16px; padding: 28px;
}

.field { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.field label { font-weight: 600; font-size: 14px; }
.field input[type="text"], .field input[type="email"],
.field input[type="password"], .field input[type="file"],
.field input[type="number"], .field select, .field textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(0, 170, 75, .12);
}
.field textarea { resize: vertical; min-height: 120px; }
.field input[type="file"] { padding: 8px; cursor: pointer; }
.field-row { display: flex; gap: 16px; }

.form-actions { display: flex; gap: 10px; margin-top: 4px; }

.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }

/* Превью фото */
.photo-preview {
    margin-top: 8px;
    width: 100%; max-width: 320px;
    border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.photo-preview img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }

.current-photo { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.current-photo img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; }

/* ---------- Поиск: фильтры ---------- */
.search-filters {
    display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
    background: #fff; border: 1px solid var(--border);
    border-radius: 12px; padding: 16px; margin-bottom: 20px;
}
.search-filters .field { min-width: 160px; }
.search-filters .field label { display: none; }

/* ---------- Профиль ---------- */
.profile-head {
    display: flex; align-items: center; gap: 24px;
    background: #fff; border: 1px solid var(--border);
    border-radius: 16px; padding: 28px;
}
.profile-head h1 { font-size: 26px; }
.profile-contact { color: var(--muted); font-size: 14px; margin-top: 2px; }
.profile-stats { display: flex; gap: 28px; margin-top: 14px; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 20px; }
.stat span { font-size: 13px; color: var(--muted); }

.my-ads { display: flex; flex-direction: column; gap: 12px; }
.my-ad {
    display: flex; align-items: center; gap: 16px;
    background: #fff; border: 1px solid var(--border);
    border-radius: 12px; padding: 12px;
}
.my-ad-photo {
    width: 96px; height: 72px; flex-shrink: 0;
    border-radius: 8px; overflow: hidden;
    background: #f0f2f4;
    display: flex; align-items: center; justify-content: center;
    color: #b3b9bf; font-size: 12px;
}
.my-ad-photo img { width: 100%; height: 100%; object-fit: cover; }
.my-ad-info { flex: 1; min-width: 0; }
.my-ad-title { font-weight: 600; color: var(--text); }
.my-ad-title:hover { color: var(--green); }
.my-ad-price { font-weight: 700; }
.my-ad-meta { font-size: 12px; color: var(--muted); display: flex; gap: 14px; margin-top: 2px; }
.my-ad-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- Подвал ---------- */
.site-footer {
    background: #1f2328;
    color: #c7cdd3;
    margin-top: auto;
}
.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 40px;
    padding: 40px 16px 24px;
}
.footer-logo { margin-bottom: 10px; }
.footer-logo .logo-text { color: #fff; }
.footer-brand p { font-size: 14px; max-width: 300px; }
.footer-col h4 { color: #fff; font-size: 15px; margin-bottom: 12px; }
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.footer-col a { color: #c7cdd3; font-size: 14px; }
.footer-col a:hover { color: var(--green); }
.footer-bottom {
    display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    border-top: 1px solid rgba(255, 255, 255, .1);
    padding: 16px;
    font-size: 13px;
    color: #8a919a;
}

/* ---------- Адаптив ---------- */
@media (max-width: 960px) {
    .ad-page { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
    .header-inner { gap: 12px; }
    .header-search { order: 3; max-width: none; flex-basis: 100%; padding-bottom: 10px; }
    .header-inner { flex-wrap: wrap; height: auto; padding-top: 10px; }
    .site-header { position: static; }
    .category-bar { position: static; top: auto; }

    .header-actions {
        position: fixed;
        top: 0; right: 0; bottom: 0;
        width: min(300px, 85vw);
        background: #fff;
        flex-direction: column; align-items: stretch;
        padding: 72px 20px 20px;
        box-shadow: -8px 0 30px rgba(0, 0, 0, .15);
        transform: translateX(100%);
        transition: transform .25s;
        z-index: 150;
    }
    .header-actions.open { transform: translateX(0); }
    .header-actions .btn { justify-content: center; }
    .user-menu, .user-menu-btn { width: 100%; }
    .user-menu-btn { justify-content: space-between; }
    .user-menu-dropdown { position: static; box-shadow: none; border: 1px solid var(--border); }

    .menu-toggle { display: flex; margin-left: auto; }

    .hero { padding: 32px 24px; }
    .hero h1 { font-size: 26px; }

    .ads-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
    .category-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

    .field-row { flex-direction: column; }
    .profile-head { flex-direction: column; align-items: flex-start; }
    .profile-stats { gap: 20px; }
    .my-ad { flex-wrap: wrap; }
    .my-ad-actions { width: 100%; justify-content: flex-end; }
    .footer-grid { grid-template-columns: 1fr; gap: 24px; }
    .form-wrap .form, .auth-form { padding: 20px; }
    .section-title { font-size: 20px; }
}
