/* =====================================================================
   JASABARIS - Stylesheet
   Palet: Teal (primary) + Slate (neutral) + Amber (accent)
   ===================================================================== */

:root {
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #ccfbf1;
    --accent: #f59e0b;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 4px 16px rgba(15, 23, 42, .08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
    --max: 1140px;
}

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

html { background: var(--bg); }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.container { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.header-inner {
    display: flex; align-items: center; gap: 20px;
    height: 64px;
}
.brand {
    display: flex; align-items: center; gap: 8px;
    font-weight: 800; font-size: 1.25rem; color: var(--text);
    letter-spacing: -.02em;
}
.brand:hover { text-decoration: none; }
.brand .logo-mark {
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
}
.brand .brand-accent { color: var(--primary); }

.header-search { flex: 1; max-width: 460px; }
.header-search form { display: flex; }
.header-search input {
    flex: 1; height: 42px; padding: 0 14px;
    border: 1px solid var(--border); border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    font-size: .95rem; outline: none;
}
.header-search input:focus { border-color: var(--primary); }
.header-search button {
    height: 42px; padding: 0 18px; border: none;
    background: var(--primary); color: #fff; cursor: pointer;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-weight: 600;
}
.header-search button:hover { background: var(--primary-dark); }

.header-nav { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.header-nav a { color: var(--text-muted); font-weight: 500; font-size: .95rem; }
.header-nav a:hover { color: var(--text); text-decoration: none; }

.nav-badge {
    position: relative; display: inline-flex; align-items: center;
}
.nav-badge .count {
    position: absolute; top: -8px; right: -10px;
    background: var(--danger); color: #fff;
    font-size: .65rem; font-weight: 700;
    min-width: 16px; height: 16px; line-height: 16px;
    text-align: center; border-radius: 999px; padding: 0 4px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 18px; border-radius: var(--radius-sm);
    font-weight: 600; font-size: .95rem; cursor: pointer;
    border: 1px solid transparent; transition: all .15s ease;
    text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #422006; }
.btn-accent:hover { background: #d97706; color: #422006; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-block { width: 100%; }
.btn-sm { height: 34px; padding: 0 12px; font-size: .85rem; }
.btn-lg { height: 50px; padding: 0 28px; font-size: 1.05rem; }

/* ---------- Hero ---------- */
.hero {
    background: linear-gradient(160deg, var(--primary-dark), var(--primary));
    color: #fff; padding: 64px 0;
}
.hero h1 { font-size: 2.6rem; line-height: 1.15; letter-spacing: -.03em; margin-bottom: 14px; }
.hero p { font-size: 1.15rem; opacity: .92; max-width: 560px; margin-bottom: 28px; }
.hero-search {
    display: flex; gap: 10px; max-width: 620px; flex-wrap: wrap;
}
.hero-search input {
    flex: 1; min-width: 220px; height: 54px; padding: 0 18px;
    border: none; border-radius: var(--radius-sm); font-size: 1rem; outline: none;
}
.hero-stats { display: flex; gap: 40px; margin-top: 36px; }
.hero-stats .stat strong { display: block; font-size: 1.8rem; }
.hero-stats .stat span { opacity: .85; font-size: .9rem; }

/* ---------- Categories strip ---------- */
.section { padding: 48px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 24px; }
.section-head h2 { font-size: 1.5rem; letter-spacing: -.02em; }
.section-head a { font-weight: 600; }

.cat-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px;
}
.cat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 14px; text-align: center;
    color: var(--text); transition: all .15s ease;
}
.cat-card:hover { text-decoration: none; box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--primary-light); }
.cat-card .cat-ico {
    width: 46px; height: 46px; margin: 0 auto 10px;
    border-radius: 12px; background: var(--primary-light); color: var(--primary-dark);
    display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
}
.cat-card span { font-weight: 600; font-size: .9rem; }

/* ---------- Ads grid ---------- */
.ads-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
}
.ad-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
    transition: all .15s ease;
}
.ad-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }
.ad-card .ad-cover {
    aspect-ratio: 16 / 9; background: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    color: var(--primary-dark); font-weight: 700; overflow: hidden;
}
.ad-card .ad-cover img { width: 100%; height: 100%; object-fit: cover; }
.ad-body { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.ad-cat {
    display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color: var(--primary-dark); background: var(--primary-light);
    padding: 3px 8px; border-radius: 999px; margin-bottom: 8px; align-self: flex-start;
}
.ad-title { font-size: 1.05rem; font-weight: 700; line-height: 1.35; color: var(--text); margin-bottom: 6px; }
.ad-title a { color: inherit; }
.ad-title a:hover { color: var(--primary-dark); text-decoration: none; }
.ad-desc { color: var(--text-muted); font-size: .9rem; margin-bottom: 12px; flex: 1;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ad-meta { display: flex; align-items: center; justify-content: space-between; font-size: .85rem; color: var(--text-muted); }
.ad-price { font-weight: 800; color: var(--accent); font-size: 1.05rem; }
.ad-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.ad-loc { display: flex; align-items: center; gap: 4px; }

/* ---------- Avatar ---------- */
.avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    background: var(--primary); color: #fff; display: flex;
    align-items: center; justify-content: center; font-weight: 700; font-size: .8rem;
    overflow: hidden;
}
.avatar.lg { width: 56px; height: 56px; font-size: 1.1rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Forms / Cards ---------- */
.auth-wrap { max-width: 440px; margin: 56px auto; }
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-sm);
}
.card h1 { font-size: 1.5rem; margin-bottom: 6px; letter-spacing: -.02em; }
.card .sub { color: var(--text-muted); margin-bottom: 22px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.form-control {
    width: 100%; min-height: 44px; padding: 10px 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: .95rem; font-family: inherit; outline: none; background: #fff; color: var(--text);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
textarea.form-control { resize: vertical; min-height: 120px; line-height: 1.6; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: .82rem; color: var(--text-muted); margin-top: 4px; }
.form-foot { margin-top: 8px; text-align: center; color: var(--text-muted); font-size: .92rem; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: .92rem; border: 1px solid; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert ul { margin: 4px 0 0 18px; }

/* ---------- Page layout ---------- */
.page { padding: 32px 0 56px; }
.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 1.8rem; letter-spacing: -.02em; }
.page-head p { color: var(--text-muted); }

.layout-2col { display: grid; grid-template-columns: 280px 1fr; gap: 28px; align-items: start; }

/* sidebar filters */
.sidebar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; position: sticky; top: 84px; }
.sidebar h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 12px; }
.filter-list { list-style: none; }
.filter-list li { margin-bottom: 4px; }
.filter-list a { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); font-size: .92rem; }
.filter-list a:hover, .filter-list a.active { background: var(--primary-light); color: var(--primary-dark); text-decoration: none; }
.filter-list a .num { color: var(--text-muted); font-size: .82rem; }

/* ---------- Single ad ---------- */
.ad-detail { display: grid; grid-template-columns: 1fr 320px; gap: 28px; align-items: start; }
.ad-hero-cover { aspect-ratio: 16/8; border-radius: var(--radius); overflow: hidden; background: var(--primary-light); display:flex; align-items:center; justify-content:center; color: var(--primary-dark); font-size: 2rem; font-weight: 800; }
.ad-hero-cover img { width:100%; height:100%; object-fit: cover; }
.ad-detail-body h1 { font-size: 1.8rem; letter-spacing: -.02em; margin: 18px 0 8px; }
.ad-detail-desc { white-space: pre-wrap; color: #1e293b; margin-top: 16px; }
.seller-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; position: sticky; top: 84px; }
.seller-box .price-big { font-size: 1.6rem; font-weight: 800; color: var(--accent); margin-bottom: 4px; }
.seller-row { display: flex; align-items: center; gap: 12px; margin: 18px 0; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.meta-list { list-style: none; margin: 16px 0; }
.meta-list li { display: flex; justify-content: space-between; padding: 7px 0; font-size: .92rem; }
.meta-list li span:first-child { color: var(--text-muted); }

/* ---------- Dashboard tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tabs a { padding: 12px 18px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary-dark); border-bottom-color: var(--primary); }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: .92rem; }
.table th { background: #f1f5f9; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.table tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-paused { background: #fef9c3; color: #854d0e; }
.badge-closed { background: #fee2e2; color: #991b1b; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty .empty-ico { font-size: 2.5rem; margin-bottom: 12px; }
.empty h3 { color: var(--text); font-size: 1.2rem; margin-bottom: 6px; }

/* ---------- Chat ---------- */
.chat-app {
    display: grid; grid-template-columns: 320px 1fr;
    height: calc(100vh - 64px - 1px);
    background: var(--surface); border-top: 1px solid var(--border);
}
.chat-list { border-right: 1px solid var(--border); overflow-y: auto; }
.chat-list-head { padding: 18px 20px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 1.1rem; position: sticky; top:0; background: var(--surface); z-index: 2; }
.conv-item { display: flex; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); cursor: pointer; color: var(--text); }
.conv-item:hover { background: var(--bg); text-decoration: none; }
.conv-item.active { background: var(--primary-light); }
.conv-item .conv-main { flex: 1; min-width: 0; }
.conv-item .conv-name { font-weight: 700; font-size: .95rem; display:flex; justify-content: space-between; gap: 8px; }
.conv-item .conv-name .time { font-weight: 400; font-size: .75rem; color: var(--text-muted); white-space: nowrap; }
.conv-item .conv-ad { font-size: .78rem; color: var(--primary-dark); margin: 1px 0; }
.conv-item .conv-last { font-size: .85rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .conv-unread { background: var(--primary); color:#fff; min-width: 20px; height: 20px; border-radius: 999px; font-size: .7rem; font-weight: 700; display: flex; align-items:center; justify-content: center; padding: 0 6px; }

.chat-main { display: flex; flex-direction: column; height: 100%; }
.chat-head { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; background: var(--surface); }
.chat-head .ch-info { flex: 1; min-width: 0; }
.chat-head .ch-name { font-weight: 700; }
.chat-head .ch-ad { font-size: .82rem; color: var(--text-muted); }
.chat-body { flex: 1; overflow-y: auto; padding: 20px; background: #f1f5f9; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 70%; padding: 9px 13px; border-radius: 14px; font-size: .92rem; line-height: 1.45; word-wrap: break-word; }
.msg .msg-time { display: block; font-size: .68rem; opacity: .7; margin-top: 3px; }
.msg.in { align-self: flex-start; background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-input { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; background: var(--surface); }
.chat-input input { flex: 1; height: 46px; padding: 0 16px; border: 1px solid var(--border); border-radius: 999px; outline: none; font-size: .95rem; }
.chat-input input:focus { border-color: var(--primary); }
.chat-input button { width: 46px; height: 46px; border-radius: 50%; border: none; background: var(--primary); color: #fff; cursor: pointer; font-size: 1.1rem; flex-shrink: 0; }
.chat-input button:hover { background: var(--primary-dark); }
.chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); text-align: center; padding: 20px; }

/* ---------- Footer ---------- */
.site-footer { background: #0f172a; color: #cbd5e1; padding: 40px 0 24px; margin-top: 56px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; margin-bottom: 28px; }
.site-footer h4 { color: #fff; font-size: .95rem; margin-bottom: 12px; }
.site-footer a { color: #cbd5e1; display: block; padding: 4px 0; font-size: .9rem; }
.site-footer a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid #1e293b; padding-top: 18px; font-size: .85rem; color: #94a3b8; text-align: center; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 32px; }
.pagination a, .pagination span {
    min-width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-weight: 600;
}
.pagination a:hover { border-color: var(--primary); text-decoration: none; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Utilities ---------- */
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
.hide-mobile { }

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
    .ads-grid { grid-template-columns: repeat(2, 1fr); }
    .cat-grid { grid-template-columns: repeat(3, 1fr); }
    .layout-2col { grid-template-columns: 1fr; }
    .ad-detail { grid-template-columns: 1fr; }
    .seller-box, .sidebar { position: static; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .chat-app { grid-template-columns: 1fr; }
    .chat-app.show-conv .chat-list { display: none; }
    .chat-app:not(.show-conv) .chat-main { display: none; }
}
@media (max-width: 640px) {
    .header-search { display: none; }
    .hero h1 { font-size: 2rem; }
    .ads-grid { grid-template-columns: 1fr; }
    .cat-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .hero-stats { gap: 24px; }
    .footer-grid { grid-template-columns: 1fr; }
}
