﻿:root {
    --bg: #ffffff;
    --text: #0f172a;
    --muted: #6b7280;
    --accent: #007ACC;
    --accent-hover: #0284c7;
    --card-radius: 10px;
    --radius: 8px;
    --gap: 18px;
    --shadow: 0 10px 30px rgba(2,6,23,0.06);
    --shadow-sm: 0 2px 6px rgba(2,6,23,0.06);
    --shadow-md: 0 10px 30px rgba(2,6,23,0.08);
    --control-bg: rgba(255,255,255,0.85);
}

/* Базовые стили */
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: #f5f5f5;
    color: var(--text);
}

/* Шапка */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

    header.user-header {
        background: var(--accent);
        color: #fff;
    }

    header.admin-header {
        background: #cc0000;
        color: #fff;
    }

    header nav {
        display: flex;
        gap: 16px;
    }

        header nav a {
            color: inherit;
            text-decoration: none;
            font-weight: 600;
            padding: 6px 10px;
            border-radius: var(--radius);
            transition: background .2s ease, color .2s ease;
        }

            header nav a:hover {
                background: rgba(255,255,255,0.15);
                color: #f0f0f0;
            }

/* Профиль справа */
.profile-menu {
    position: relative;
}

.profile-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.1);
    transition: background .2s ease;
}

    .profile-btn:hover {
        background: rgba(255,255,255,0.2);
    }

    .profile-btn img {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        object-fit: cover;
        box-shadow: 0 0 4px rgba(0,0,0,0.2);
    }

    .profile-btn span {
        font-weight: 600;
        color: #fff;
    }

/* Выпадающее меню */
.dropdown {
    position: absolute;
    right: 0;
    top: 110%;
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    min-width: 160px;
    overflow: hidden;
    z-index: 200;
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}

    .dropdown.show {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    .dropdown a {
        padding: 10px 14px;
        text-decoration: none;
        color: var(--text);
        font-weight: 500;
        transition: background .2s ease, color .2s ease;
    }

        .dropdown a:hover {
            background: #f9fafb;
            color: var(--accent);
        }

/* Контейнер */
.container {
    max-width: 900px;
    margin: 20px auto;
    background: var(--bg);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* Сетка объявлений */
.ads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--gap);
    padding: 12px;
    background: var(--bg);
}

/* Карточка объявления */
.ad-card {
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 300px;
    transition: transform .14s ease, box-shadow .14s ease;
    border: 1px solid rgba(0,0,0,0.04);
}

    .ad-card:hover {
        transform: translateY(-6px);
        box-shadow: 0 22px 48px rgba(2,6,23,0.08);
    }

.ad-card__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    pointer-events: none; /* оверлей не блокирует клики по карточке */
    background: rgba(0,0,0,0.18);
}

.ad-card__overlay-link {
    pointer-events: auto; /* ссылка принимает клики */
    text-decoration: none;
    display: inline-block;
}

.ad-card__overlay-badge {
    background: #fff;
    color: #222;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    border: 1px solid rgba(0,0,0,0.06);
}

/* Состояния карточки */
.ad-card--editable {
    border: 2px solid #4caf50;
}

.ad-card--deletable {
    border: 2px solid #f44336;
}

.ad-card--favorite .btn.fav {
    color: #e91e63;
}

/* Ссылка */
.ad-link {
    display: block;
    color: inherit;
    text-decoration: none;
    height: 100%;
}

/* Изображение */
.media {
    height: 180px;
    background: #f7fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.ad-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s ease;
}

.ad-card:hover .ad-image {
    transform: scale(1.05);
}

.ad-placeholder {
    color: var(--muted);
    padding: 18px;
    background: #f1f5f9;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
}

/* Контент */
.meta {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1 1 auto;
}

.title-price {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(15,23,42,0.04);
    padding-bottom: 8px;
}

.title {
    font-weight: 600;
    font-size: 1rem;
    margin: 0;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.price {
    font-weight: 800;
    font-size: 1.06rem;
    color: var(--accent);
    white-space: nowrap;
    transition: color .2s ease;
}

    .price:hover {
        color: var(--accent-hover);
    }

.desc {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.meta-foot {
    margin-top: auto;
    color: var(--muted);
    font-size: 0.85rem;
}

.date::before {
    content: "🕒 ";
    margin-right: 4px;
}

/* Контролы */
.controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 8px;
    z-index: 3;
    background: var(--control-bg);
    padding: 6px;
    border-radius: 999px;
    align-items: center;
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.btn {
    border: none;
    background: transparent;
    padding: 6px;
    cursor: pointer;
    color: var(--muted);
    font-size: 1.05rem;
    border-radius: 6px;
    transition: background .18s ease, transform .12s ease, color .12s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

    .btn:focus {
        outline: 2px solid rgba(14,165,233,0.35);
        outline-offset: 2px;
    }

    .btn:hover {
        color: var(--text);
        background: rgba(0,0,0,0.05);
        transform: translateY(-2px);
    }

    .btn:active {
        transform: scale(0.92);
        background: rgba(0,0,0,0.08);
    }

/* Профильная страница */
.profile-container {
    padding: 20px;
}

.profile-header {
    margin-bottom: 20px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.profile-top {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding-bottom: 20px;
}

.avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 6px rgba(0,0,0,0.15);
}

.profile-info p {
    margin: 4px 0;
    color: var(--muted);
}

.profile-info .btn.edit {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 16px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    transition: background .2s ease, transform .2s ease;
}

    .profile-info .btn.edit:hover {
        background: var(--accent-hover);
        transform: translateY(-2px);
    }

/* Пустой список */
.empty {
    color: var(--muted);
    padding: 18px;
    text-align: center;
}

/* Адаптив */
@media (max-width: 520px) {
    .media {
        height: 140px;
    }

    .ad-card {
        min-height: 260px;
    }

    .controls {
        top: 8px;
        right: 8px;
        padding: 4px;
    }
}

@media (max-width: 420px) {
    .ads-grid {
        grid-template-columns: 1fr;
    }

    .price {
        font-size: 1.2rem;
    }

    .profile-top {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

/* кружок аватара */ 
.avatar {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    overflow:hidden;
    border-radius:50%;
    background:#666;
    color:#fff;
    font-weight:700;
    text-transform:uppercase;
}

.avatar img {
    width:100%;
    height:100%;
    object-fit:cover;
    display:block;
    border-radius:50%;
}

.avatar-fallback {
    width:100%;
    height:100%;
    display:flex;
    align-items:center;
    justify-content:center;
}

/* размеры */
.avatar--sm { width:40px; height:40px; font-size:18px; }
.avatar--md { width:64px; height:64px; font-size:22px; }
.avatar--lg { width:150px; height:150px; font-size:48px; }

