:root {
    --primary: #0d6efd;
    --primary-dark: #0a58ca;
    --surface: #ffffff;
    --surface-2: #f8f9fa;
    --border: #e9ecef;
    --text: #212529;
    --text-muted: #6c757d;
    --navbar-bg: #0f1623;
    --shadow: 0 2px 12px rgba(0,0,0,.08);
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f4f6f9;
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; }

/* ===== Navbar ===== */
#main-navbar {
    background: var(--navbar-bg) !important;
    box-shadow: 0 2px 16px rgba(0,0,0,.25);
    height: 60px;
    padding: 0;
}

.brand-diamond { color: #3b9eff; }
.brand-ykt { color: #3b9eff; }
.navbar-brand { font-size: 1.25rem; letter-spacing: -.5px; }

.search-input {
    background: #1e2a3a;
    border: 1px solid #2d3f55;
    color: #fff;
    border-radius: 8px 0 0 8px !important;
}
.search-input::placeholder { color: #6c7a8a; }
.search-input:focus { background: #243044; border-color: #3b9eff; color: #fff; box-shadow: none; }

.btn-search {
    background: var(--primary);
    border: none;
    color: #fff;
    border-radius: 0 8px 8px 0 !important;
    padding: 0 16px;
}
.btn-search:hover { background: var(--primary-dark); color: #fff; }

.btn-post {
    background: linear-gradient(135deg, #0d6efd, #0a58ca);
    color: #fff !important;
    border: none;
    border-radius: 8px;
    padding: 8px 18px;
    font-weight: 600;
    font-size: .875rem;
    transition: all .2s;
}
.btn-post:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(13,110,253,.4); }

.nav-icon-btn {
    position: relative;
    font-size: 1.2rem;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background .2s;
}
.nav-icon-btn:hover { background: rgba(255,255,255,.08); }

.badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dc3545;
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    position: absolute;
    top: 2px;
    right: 2px;
    line-height: 1;
}

.avatar-xs { width: 28px; height: 28px; object-fit: cover; }
.avatar-sm { width: 36px; height: 36px; object-fit: cover; }
.avatar-md { width: 48px; height: 48px; object-fit: cover; }
.avatar-lg { width: 90px; height: 90px; object-fit: cover; }

/* ===== Category chips ===== */
.cat-bar { border-bottom: 1px solid var(--border); overflow-x: auto; flex-wrap: nowrap !important; padding-bottom: 12px; }
.cat-bar::-webkit-scrollbar { height: 3px; }
.cat-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: .85rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    transition: all .15s;
    flex-shrink: 0;
}
.cat-chip:hover { border-color: var(--primary); color: var(--primary); background: #f0f5ff; }
.cat-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Filter card ===== */
.filter-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    position: sticky;
    top: 70px;
}

/* ===== Ads grid ===== */
.ads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.ad-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow .2s, transform .2s;
    display: flex;
    flex-direction: column;
}
.ad-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    transform: translateY(-2px);
}

.ad-card-img {
    position: relative;
    height: 180px;
    background: #f0f2f5;
    overflow: hidden;
}
.ad-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s;
}
.ad-card:hover .ad-card-img img { transform: scale(1.04); }

.ad-no-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 2.5rem;
}

.ad-cat-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: .7rem;
    padding: 2px 8px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.ad-card-body { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.ad-price { font-weight: 700; font-size: 1rem; color: var(--primary); }
.ad-title { font-size: .88rem; color: var(--text); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ad-meta { display: flex; gap: 10px; font-size: .75rem; color: var(--text-muted); margin-top: auto; padding-top: 6px; }
.ad-meta span { display: flex; align-items: center; gap: 2px; }

/* ===== Detail/Card ===== */
.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.gallery-main-img { max-height: 480px; width: 100%; object-fit: contain; background: #000; }
.gallery-thumb { width: 72px; height: 54px; object-fit: cover; cursor: pointer; opacity: .75; transition: opacity .15s; }
.gallery-thumb:hover { opacity: 1; }
.ad-no-photo-lg { display: flex; align-items: center; justify-content: center; flex-direction: column; height: 300px; background: #f0f2f5; }

.ad-description { line-height: 1.7; color: #444; white-space: pre-line; }

.safety-card { background: #f0fff4; border-color: #b7ebce; }

/* ===== Auth pages ===== */
.auth-page { background: linear-gradient(135deg, #0f1623 0%, #1a2744 100%); min-height: 100vh; }
.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.auth-logo { font-size: 1.6rem; font-weight: 800; color: var(--navbar-bg); }
.auth-logo .brand-ykt { color: var(--primary); }

/* ===== Chat ===== */
.chat-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.chat-messages { background: #f4f6f9; }

.msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 12px;
}
.msg-mine { flex-direction: row-reverse; }

.msg-bubble {
    max-width: 70%;
    border-radius: 16px;
    padding: 10px 14px;
    position: relative;
}
.msg-theirs .msg-bubble { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-mine .msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }

.msg-body { line-height: 1.5; word-break: break-word; }
.msg-time { font-size: .7rem; opacity: .65; margin-top: 4px; text-align: right; }

.chat-input-area { background: var(--surface); }
.chat-list-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    color: var(--text);
    transition: box-shadow .15s, border-color .15s;
}
.chat-list-item:hover { box-shadow: var(--shadow); border-color: var(--primary); }
.chat-unread { border-left: 3px solid var(--primary); }

.animate-typing { animation: blink 1s step-start infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ===== Admin stats ===== */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-icon { font-size: 1.75rem; margin-bottom: 8px; }
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .825rem; color: var(--text-muted); margin-top: 4px; }

/* ===== Profile balance ===== */
.balance-card { background: linear-gradient(135deg, #f0f5ff, #e8edff); border: 1px solid #c5d5ff; }

/* ===== Photo upload ===== */
.photo-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.photo-upload-area:hover { border-color: var(--primary); background: #f0f5ff; }
.photo-upload-area input { margin-top: 12px; }

/* ===== Footer ===== */
.footer { background: var(--navbar-bg); color: #8fa3bf; }
.footer-link { color: #8fa3bf; text-decoration: none; }
.footer-link:hover { color: #fff; }

/* ===== Empty state ===== */
.empty-state { color: var(--text-muted); }

/* ===== Scrollbar global ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ced4da; border-radius: 3px; }

/* ===== Payment / pricing cards ===== */
.pricing-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    cursor: pointer;
    transition: all .2s;
    position: relative;
}
.pricing-card:hover { border-color: var(--primary); box-shadow: 0 4px 20px rgba(13,110,253,.12); }
.pricing-card.selected { border-color: var(--primary); background: #f0f5ff; }
.pricing-card .price-tag { font-size: 2rem; font-weight: 800; color: var(--primary); }
.pricing-card.priority-card { border-color: #ffc107; }
.pricing-card.priority-card:hover { border-color: #e0a800; box-shadow: 0 4px 20px rgba(255,193,7,.2); }
.pricing-card.priority-card.selected { border-color: #e0a800; background: #fffdf0; }
.pricing-card.priority-card .price-tag { color: #e0a800; }
.priority-badge {
    position: absolute;
    top: -12px;
    right: 16px;
    background: linear-gradient(135deg, #ffc107, #fd7e14);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.platega-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 14px;
    font-size: .85rem;
    font-weight: 600;
    color: #333;
}

/* ===== Topup amounts ===== */
.topup-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all .2s;
    background: var(--surface);
}
.topup-chip:hover, .topup-chip.selected { border-color: var(--primary); color: var(--primary); background: #f0f5ff; }

/* ===== Priority ad indicator ===== */
.ad-priority-star {
    position: absolute;
    top: 8px;
    right: 8px;
    background: linear-gradient(135deg, #ffc107, #fd7e14);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    z-index: 1;
}

/* ===== Responsive ===== */
@media (max-width: 991px) {
    .navbar-collapse {
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--navbar-bg);
        padding: 8px 16px 16px;
        border-radius: 0 0 14px 14px;
        box-shadow: 0 12px 40px rgba(0,0,0,.5);
        z-index: 1025;
    }
    #main-navbar { overflow: visible; }
}

@media (max-width: 768px) {
    .ads-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
    .ad-card-img { height: 140px; }
    .auth-card { padding: 24px 18px; }
    .filter-card { position: static; }
    .msg-bubble { max-width: 85%; }
}

@media (max-width: 480px) {
    .ads-grid { grid-template-columns: repeat(2, 1fr); }
}
