/* =========================================================
   OwnerListing v2 — Stylesheet
   ========================================================= */

/* ── Utility ──────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --clr-primary:   #1e3a5f;
  --clr-accent:    #2c82c9;
  --clr-income:    #1a7a4a;
  --clr-expense:   #922b21;
  --clr-warn:      #c0392b;
  --clr-ok:        #1a7a4a;
  --clr-muted:     #6c757d;
  --clr-bg:        #f4f6f9;
  --clr-card:      #ffffff;
  --clr-border:    #dee2e6;
  --clr-row-even:  #f8f9fa;
  --clr-row-hover: #e8f4fd;
  --radius:        6px;
  --shadow:        0 2px 8px rgba(0,0,0,.12);
}

html { font-size: 15px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--clr-bg);
  color: #212529;
  min-height: 100vh;
}

a { color: var(--clr-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ───────────────────────────────────────────── */
.navbar {
  background: var(--clr-primary);
  padding: .6rem 1.5rem;
}
.navbar-inner {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
}
.navbar a {
  color: #e8edf5;
  font-weight: 600;
  font-size: .9rem;
  padding: .25rem .5rem;
  border-radius: var(--radius);
  transition: background .15s;
}
.navbar a:hover { background: rgba(255,255,255,.15); text-decoration: none; }
.nav-brand { font-weight: 700; font-size: 1rem; color: #fff; letter-spacing: .02em; margin-right: .5rem; }

/* Hamburger button — always visible */
.nav-hamburger {
  display: flex !important;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 4px;
  cursor: pointer;
  padding: 5px;
  flex-direction: column;
  gap: 4px;
  min-width: 32px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-hamburger:hover { background: rgba(255,255,255,.25); }
.nav-hamburger span {
  display: block !important;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  flex-shrink: 0;
}
/* Dropdown menu — hidden by default */
.nav-dropdown {
  display: none !important;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--clr-primary);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  padding: .4rem 0;
  min-width: 160px;
  z-index: 100;
  flex-direction: column;
}
.nav-dropdown.open { display: flex !important; }
.nav-dropdown a {
  padding: .6rem 1rem !important;
  font-size: .9rem !important;
  border-radius: 0 !important;
  white-space: nowrap;
}
.nav-dropdown a:hover { background: rgba(255,255,255,.15); }
/* Primary nav links — always visible inline */
.nav-primary { display: flex; align-items: center; gap: .3rem; }
.navbar-inner { position: relative; }

/* ── Page container ───────────────────────────────────── */
.container { max-width: 920px; margin: 0 auto; padding: 1.2rem 1rem; }

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: var(--clr-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem;
  margin-bottom: 1rem;
}
.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--clr-primary);
  margin-bottom: .8rem;
  border-bottom: 2px solid var(--clr-border);
  padding-bottom: .4rem;
}

/* ── Login form ───────────────────────────────────────── */
.login-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 60px);
}
.login-card {
  background: var(--clr-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: 360px;
  max-width: 95vw;
}
.login-card h1 {
  text-align: center;
  font-size: 1.6rem;
  color: var(--clr-primary);
  margin-bottom: 1.5rem;
}
.login-card .logo { text-align: center; font-size: 2.5rem; margin-bottom: .5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .9rem; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  font-size: .95rem;
  transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px rgba(44,130,201,.15);
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--clr-accent);   color: #fff; }
.btn-success  { background: var(--clr-income);   color: #fff; }
.btn-danger   { background: var(--clr-expense);  color: #fff; }
.btn-warning  { background: #e67e22; color: #fff; }
.btn-light    { background: #e9ecef; color: #333; }
.btn-sm       { padding: .3rem .7rem; font-size: .82rem; }
.btn-full     { width: 100%; justify-content: center; }

/* ── Alerts ───────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-weight: 500;
}
.alert-error   { background: #fde8e8; color: var(--clr-warn); border: 1px solid #f5c6c6; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── Tables ───────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
table.data-table th {
  background: var(--clr-primary);
  color: #fff;
  padding: .5rem .7rem;
  text-align: left;
  white-space: nowrap;
}
table.data-table td {
  padding: .45rem .7rem;
  border-bottom: 1px solid var(--clr-border);
  vertical-align: middle;
}
table.data-table tr:nth-child(even) td { background: var(--clr-row-even); }
table.data-table tr:hover td { background: var(--clr-row-hover); }

/* ── Tab bar ─────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-bottom: 3px solid var(--clr-border);
}
.tab-btn {
  padding: .6rem 1.5rem;
  font-size: .95rem;
  font-weight: 600;
  color: var(--clr-muted);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -3px;
  cursor: pointer;
  text-decoration: none;
  transition: color .2s, border-color .2s;
}
.tab-btn:hover { color: var(--clr-primary); }
.tab-btn.active {
  color: var(--clr-primary);
  border-bottom-color: var(--clr-accent);
  background: rgba(44,130,201,.06);
}
.tab-btn .tab-count {
  display: inline-block;
  background: var(--clr-border);
  color: var(--clr-muted);
  font-size: .75rem;
  font-weight: 700;
  padding: .1rem .45rem;
  border-radius: 10px;
  margin-left: .35rem;
  vertical-align: middle;
}
.tab-btn.active .tab-count {
  background: var(--clr-accent);
  color: #fff;
}

/* ── Filter / search bar ──────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: flex-end;
  background: var(--clr-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: .9rem;
  margin-bottom: 1rem;
}
.filter-bar label { font-size: .82rem; font-weight: 600; display: block; margin-bottom: .15rem; }
.filter-bar select, .filter-bar input {
  padding: .35rem .55rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  font-size: .88rem;
}

/* ── Summary boxes ────────────────────────────────────── */
.summary-box {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: .8rem 0;
}
.summary-box .sum-item {
  background: var(--clr-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: .7rem 1.2rem;
  flex: 1;
  min-width: 140px;
  text-align: center;
}
.sum-item .sum-label { font-size: .78rem; font-weight: 600; color: var(--clr-muted); }
.sum-item .sum-value { font-size: 1.3rem; font-weight: 700; color: var(--clr-primary); }

/* ── Listing badges ───────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-green   { background: #d4edda; color: #155724; }
.badge-yellow  { background: #fff3cd; color: #856404; }
.badge-red     { background: #f8d7da; color: #842029; }
.badge-expired { background: #e9ecef; color: #6c757d; }
.badge-sale    { background: #d4edda; color: #155724; }
.badge-rent    { background: #cce5ff; color: #004085; }
.badge-active  { background: #d1e7dd; color: #0a3622; }
.badge-inactive{ background: #f8d7da; color: #842029; }

/* ── Listing card grid ────────────────────────────────── */
.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.2rem;
}
.listing-card {
  background: var(--clr-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.listing-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
}
.listing-photo {
  position: relative;
  height: 200px;
  overflow: hidden;
  background: #e9ecef;
}
.listing-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.listing-photo .no-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--clr-muted);
  font-size: .9rem;
}
.listing-photo .listing-type-badge {
  position: absolute;
  top: .5rem;
  left: .5rem;
}
.listing-photo .badge {
  position: absolute;
  top: .5rem;
  right: .5rem;
}
.listing-info {
  padding: .9rem;
}
.listing-info h3 {
  font-size: 1rem;
  margin-bottom: .3rem;
}
.listing-info h3 a {
  color: var(--clr-primary);
}
.listing-info h3 a:hover {
  color: var(--clr-accent);
}
.listing-price {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--clr-accent);
  margin-bottom: .3rem;
}
.listing-location {
  font-size: .85rem;
  color: var(--clr-muted);
  margin-bottom: .4rem;
}
.listing-desc {
  font-size: .85rem;
  color: #555;
  line-height: 1.4;
}

/* ── Photo gallery (listing detail) ───────────────────── */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .8rem;
  margin-bottom: 1.5rem;
}
.photo-gallery img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform .15s;
  border: 1px solid var(--clr-border);
}
.photo-gallery img:hover {
  transform: scale(1.03);
}

/* ── Photo lightbox ───────────────────────────────────── */
.lightbox-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.85);
  z-index: 99999;
  align-items: center;
  justify-content: center;
}
.lightbox-overlay.active { display: flex; }
.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
}
.lightbox-close {
  position: absolute;
  top: 1rem; right: 1.5rem;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,.5);
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  font-size: 2.5rem;
  cursor: pointer;
  padding: .5rem;
  text-shadow: 0 2px 4px rgba(0,0,0,.5);
  user-select: none;
}
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

/* ── Photo upload preview ─────────────────────────────── */
.photo-upload-preview {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: .5rem;
}
.photo-upload-preview .photo-thumb {
  position: relative;
  width: 100px;
  min-height: 100px;
  height: auto;
}
.photo-upload-preview .photo-thumb img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--clr-border);
}
.photo-upload-preview .photo-thumb label {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(255,0,0,.8);
  color: #fff;
  font-size: .7rem;
  padding: 1px 5px;
  border-radius: 3px;
  cursor: pointer;
}

/* ── Superadmin table ─────────────────────────────────── */
.sa-table { width:100%; border-collapse:collapse; font-size:.875rem; }
.sa-table th { background:var(--clr-bg); font-weight:600; padding:.5rem .7rem; text-align:left; border-bottom:2px solid var(--clr-border); white-space:nowrap; }
.sa-table td { padding:.45rem .7rem; border-bottom:1px solid var(--clr-border); vertical-align:middle; }
.sa-table tr:hover td { background:#f8fafc; }
.sa-table tr.row-editing td { background:#fffbe6; }
.sa-table tr.row-editing:hover td { background:#fff8d6; }
.sa-actions { display:flex; gap:.35rem; flex-wrap:wrap; align-items:center; }
.edit-panel { background:#fffbe6; border:1px solid #ffc107; border-radius:8px; padding:1rem 1.2rem; margin-bottom:1.2rem; }
.edit-panel h3 { margin:0 0 .8rem; font-size:1rem; }
.edit-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:.8rem; }

/* ── Listing detail page ──────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: .4rem .8rem;
  margin-bottom: 1rem;
  align-items: baseline;
}
.detail-grid .detail-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--clr-muted);
}
.detail-grid .detail-value {
  font-size: .95rem;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .navbar { padding: .5rem .8rem; }
  .navbar-inner { gap: .5rem; }
  .navbar a { font-size: .82rem; padding: .2rem .4rem; }
  .nav-brand { font-size: .88rem; margin-right: .2rem; }
  .container { padding: .8rem .5rem; }
  .card { padding: .8rem; }
  .filter-bar { flex-direction: column; gap: .5rem; }
  .filter-bar select, .filter-bar input { width: 100%; }
  table.data-table { font-size: .78rem; }
  table.data-table th, table.data-table td { padding: .35rem .4rem; }
  .summary-box { flex-direction: column; }
  .listing-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
  .login-card { padding: 1.5rem 1rem; width: 95vw; }
  .btn { padding: .4rem .7rem; font-size: .84rem; }
  .photo-gallery { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .tab-btn { padding: .5rem .8rem; font-size: .88rem; }
}

@media (max-width: 480px) {
  html { font-size: 14px; }
  .navbar { padding: .4rem .5rem; }
  .navbar-inner { gap: .3rem; }
  .navbar a { font-size: .78rem; padding: .2rem .3rem; }
  .nav-brand { font-size: .82rem; }
  .nav-primary { gap: .15rem; }
  .nav-primary a { font-size: .72rem; }
  .listing-grid { grid-template-columns: 1fr; }
  .photo-gallery img { height: 140px; }
  .tab-btn { padding: .45rem .6rem; font-size: .82rem; }
  .tab-btn .tab-count { font-size: .65rem; padding: .05rem .35rem; }
  /* WhatsApp card mobile */
  .wa-card-inner { flex-direction: column; text-align: center; }
  .wa-card-inner img { width: 44px; height: 44px; }
}

@media print {
  .navbar, .no-print { display: none !important; }
  body { background: #fff; }
}
