/* ============================================================
   Classifieds — style.css
   Clean, no-framework, mobile-friendly
   Supports light/dark mode (auto + manual toggle)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg:       #f5f5f5;
  --surface:  #ffffff;
  --border:   #e0e0e0;
  --primary:  #1565c0;
  --primary-h:#0d47a1;
  --danger:   #c62828;
  --success:  #2e7d32;
  --text:     #212121;
  --muted:    #616161;
  --accent:   #e3f2fd;
  --radius:   8px;
  --shadow:   0 1px 4px rgba(0,0,0,.10);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg:       #121212;
  --surface:  #1e1e1e;
  --border:   #333333;
  --primary:  #42a5f5;
  --primary-h:#64b5f6;
  --danger:   #ef5350;
  --success:  #66bb6a;
  --text:     #e0e0e0;
  --muted:    #9e9e9e;
  --accent:   #1a2a3a;
  --shadow:   0 1px 4px rgba(0,0,0,.30);
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

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

/* ---- Navbar ---- */
.navbar {
  background: var(--primary);
  color: #fff;
  padding: .6rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  flex-wrap: wrap;
  gap: .5rem;
}

[data-theme="dark"] .navbar {
  background: #1a1a2e;
}

.nav-brand {
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .3px;
}
.nav-brand:hover { text-decoration: none; opacity: .9; }

.nav-right {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}

.nav-user {
  font-weight: 600;
  font-size: .88rem;
  margin-right: .2rem;
  opacity: .9;
}

/* ---- Theme toggle ---- */
.btn-theme {
  background: transparent;
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
  padding: .25rem .6rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 500;
  line-height: 1.4;
  transition: background .15s;
  white-space: nowrap;
}
.btn-theme:hover { background: rgba(255,255,255,.15); }

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: .45rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: background .15s;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-h); text-decoration: none; color: #fff; }
.btn-ghost {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,.5);
}
.btn-ghost:hover { background: rgba(255,255,255,.15); text-decoration: none; }
.btn-ghost-dark {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
}
.btn-ghost-dark:hover { background: var(--accent); text-decoration: none; }
.btn-full { width: 100%; text-align: center; }
.btn-sm { padding: .3rem .65rem; font-size: .82rem; }
.btn-approve { background: #388e3c; color: #fff; }
.btn-approve:hover { background: #2e7d32; }
.btn-delete { background: var(--danger); color: #fff; }
.btn-delete:hover { background: #b71c1c; }

[data-theme="dark"] .btn-approve { background: #2e7d32; }
[data-theme="dark"] .btn-approve:hover { background: #388e3c; }
[data-theme="dark"] .btn-delete { background: #c62828; }
[data-theme="dark"] .btn-delete:hover { background: #d32f2f; }

/* ---- Container ---- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}
.container-narrow {
  max-width: 740px;
}

/* ---- Layout (sidebar + listings) ---- */
.layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
  margin-top: 1.25rem;
}
@media (max-width: 640px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---- Search ---- */
.search-form {
  display: flex;
  gap: .5rem;
}
.search-input {
  flex: 1;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
}
.search-input:focus { outline: 2px solid var(--primary); border-color: transparent; }

/* ---- Sidebar ---- */
.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  height: fit-content;
  box-shadow: var(--shadow);
}
.sidebar-title {
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin: 0 0 .75rem;
}
.cat-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.cat-list li { margin: .25rem 0; }
.cat-list a {
  display: block;
  padding: .3rem .5rem;
  border-radius: 5px;
  color: var(--text);
  font-size: .92rem;
}
.cat-list a:hover { background: var(--accent); text-decoration: none; }
.cat-list a.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* ---- Ad cards ---- */
.listings {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.ad-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: block;
  box-shadow: var(--shadow);
  transition: box-shadow .15s, border-color .15s;
  color: var(--text);
}
.ad-card:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,.12);
  border-color: var(--primary);
  text-decoration: none;
}

.ad-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .35rem;
}
.ad-category {
  background: var(--accent);
  color: var(--primary);
  font-size: .75rem;
  font-weight: 600;
  padding: .1rem .5rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.ad-date { font-size: .78rem; color: var(--muted); }

.ad-title {
  margin: .25rem 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.ad-desc {
  margin: .25rem 0 .5rem;
  font-size: .9rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ad-price {
  font-weight: 700;
  color: var(--primary);
  font-size: .95rem;
}

/* ---- Single ad detail ---- */
.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: .9rem;
  color: var(--muted);
}
.ad-detail {
  padding: 1.5rem;
}
.ad-detail-title {
  font-size: 1.5rem;
  margin: .5rem 0;
}
.ad-price-large {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  margin: .75rem 0;
}
.ad-detail-desc { margin: 1.25rem 0; }
.ad-detail-desc h3 { margin-bottom: .4rem; font-size: 1rem; color: var(--muted); }
.ad-detail-desc p { white-space: pre-wrap; }
.ad-contact-box {
  background: var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 1.25rem;
}
.ad-contact-box h3 { margin: 0 0 .75rem; font-size: .95rem; }
.ad-contact-box p { margin: 0; font-weight: 600; font-size: 1.05rem; }

/* ---- Contact links ---- */
.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}
.contact-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .45rem .85rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: .95rem;
  transition: background .15s, box-shadow .15s;
  text-decoration: none;
}
.contact-link:hover { text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.contact-link-phone {
  background: #e8f5e9;
  color: #2e7d32;
}
.contact-link-phone:hover { background: #c8e6c9; color: #1b5e20; }
.contact-link-wa {
  background: #25d366;
  color: #fff;
}
.contact-link-wa:hover { background: #1da851; color: #fff; }
.contact-link-email {
  background: #e3f2fd;
  color: #1565c0;
}
.contact-link-email:hover { background: #bbdefb; color: #0d47a1; }
.contact-link-web {
  background: #f3e5f5;
  color: #7b1fa2;
}
.contact-link-web:hover { background: #e1bee7; color: #6a1b9a; }

[data-theme="dark"] .contact-link-phone { background: #1b3a1f; color: #66bb6a; }
[data-theme="dark"] .contact-link-phone:hover { background: #254a2b; }
[data-theme="dark"] .contact-link-wa { background: #1a7a3a; color: #fff; }
[data-theme="dark"] .contact-link-wa:hover { background: #25a04e; }
[data-theme="dark"] .contact-link-email { background: #1a2a3a; color: #64b5f6; }
[data-theme="dark"] .contact-link-email:hover { background: #233a4f; }
[data-theme="dark"] .contact-link-web { background: #2a1a30; color: #ce93d8; }
[data-theme="dark"] .contact-link-web:hover { background: #3a2544; }

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

/* ---- Form ---- */
.form-card { padding: 1.75rem; }
.page-title { margin-bottom: 1.25rem; }

.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: .35rem;
  font-size: .92rem;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: 2px solid var(--primary);
  border-color: transparent;
}
.form-group textarea { resize: vertical; }

.required { color: var(--danger); margin-left: .2rem; }
.optional { color: var(--muted); font-weight: 400; font-size: .82rem; }
.form-note { font-size: .85rem; color: var(--muted); margin-bottom: .75rem; }
.form-hint { font-size: .8rem; color: var(--muted); margin: .35rem 0 0; }

/* ---- Alerts ---- */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-weight: 500;
}
.alert-success { background: #e8f5e9; color: var(--success); border: 1px solid #a5d6a7; }
.alert-error   { background: #ffebee; color: var(--danger);  border: 1px solid #ef9a9a; }

[data-theme="dark"] .alert-success { background: #1b3a1f; border-color: #2e7d32; }
[data-theme="dark"] .alert-error   { background: #3a1a1a; border-color: #c62828; }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-icon { font-size: 3rem; margin-bottom: .75rem; }

/* ---- Admin tabs ---- */
.admin-tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.tab-btn {
  padding: .5rem 1.25rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: .92rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Admin table ---- */
.admin-table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.admin-table th {
  background: var(--primary);
  color: #fff;
  padding: .6rem .85rem;
  text-align: left;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.admin-table td {
  padding: .6rem .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.admin-table tr:last-child td { border-bottom: none; }
.row-pending { background: #fffde7; }
[data-theme="dark"] .row-pending { background: #2a2a10; }
.admin-desc {
  font-size: .8rem;
  color: var(--muted);
  margin: .2rem 0 0;
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.actions { white-space: nowrap; display: flex; gap: .4rem; align-items: flex-start; }

/* ---- Badges ---- */
.badge {
  padding: .15rem .5rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  display: inline-block;
}
.badge-approved { background: #e8f5e9; color: var(--success); }
.badge-pending  { background: #fff3e0; color: #e65100; }
.badge-admin    { background: #e3f2fd; color: #1565c0; }
.badge-mod      { background: #f3e5f5; color: #7b1fa2; }
.badge-user     { background: #f5f5f5; color: #616161; }

[data-theme="dark"] .badge-approved { background: #1b3a1f; }
[data-theme="dark"] .badge-pending  { background: #3a2a10; }
[data-theme="dark"] .badge-admin    { background: #1a2a3a; }
[data-theme="dark"] .badge-mod      { background: #2a1a30; }
[data-theme="dark"] .badge-user     { background: #2a2a2a; color: #9e9e9e; }

/* ---- Role select (admin user management) ---- */
.role-select {
  padding: .25rem .4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .82rem;
  font-weight: 600;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.role-form { display: inline-flex; align-items: center; }

/* ---- Radio group (settings) ---- */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.radio-label {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  cursor: pointer;
  font-size: .92rem;
}
.radio-label input[type="radio"] {
  width: auto;
  margin-top: .3rem;
  cursor: pointer;
}

/* ---- Price + currency row ---- */
.price-row {
  display: flex;
  gap: .5rem;
}

.price-row .currency-select {
  flex: 0 0 90px; /* Locks the dropdown to exactly 90px so it can't grow or shrink */
  width: 90px;
  padding: .55rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: inherit;
  font-weight: 600;
  background: var(--accent);
  color: var(--primary);
  cursor: pointer;
}

.price-row .currency-select:focus { 
  outline: 2px solid var(--primary); 
  border-color: transparent; 
}

.price-row input { 
  flex: 1 1 auto; /* Forces the input to expand and fill the remaining space */
  width: 100%; 
  min-width: 0; 
}

/* ---- Currency management (admin) ---- */
.section-title { font-size: 1.2rem; margin-bottom: 1rem; }
.currency-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.currency-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  box-shadow: var(--shadow);
}
.currency-reorder {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.btn-reorder {
  padding: .1rem .4rem;
  font-size: .75rem;
  background: var(--accent);
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
}
.btn-reorder:hover { background: var(--primary); color: #fff; }
.currency-edit-form {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex: 1;
}
.currency-code-input {
  width: 80px;
  padding: .35rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .92rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.currency-code-input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.currency-space-label {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .85rem;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}
.currency-space-label input[type="checkbox"] { width: auto; margin: 0; cursor: pointer; }
.currency-add-form {
  max-width: 500px;
  margin-top: 1rem;
  padding: 1rem 1.25rem;
}
.currency-add-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ---- Invite codes (profile) ---- */
.invite-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.invite-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  flex-wrap: wrap;
}
.invite-code {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .5px;
  background: var(--accent);
  color: var(--primary);
  padding: .2rem .6rem;
  border-radius: 4px;
}
.invite-date {
  font-size: .8rem;
  color: var(--muted);
  margin-left: auto;
}
.copy-btn { margin-left: .25rem; }

/* ---- Footer ---- */
.footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: .85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* ---- Responsive nav ---- */
@media (max-width: 600px) {
  .navbar { padding: .5rem .75rem; }
  .nav-right { gap: .3rem; }
  .btn-sm { padding: .2rem .4rem; font-size: .75rem; }
  .btn-theme { font-size: .75rem; padding: .2rem .4rem; }
  .nav-user { display: none; }
}
