@import url('https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300;400;600&display=swap');

/* =========================
   THEME SYSTEM
========================= */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: rgba(0,0,0,0.08);

  --accent: #2563eb;
  --accent-hover: #1d4ed8;

  --dark-bg: #0b1220;
  --dark-surface: #111827;
  --dark-card: #1f2937;
  --dark-text: #e5e7eb;
}

/* =========================
   GLOBAL
========================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Source Sans Pro', sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
}

/* =========================
   NAVBAR
========================= */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--dark-surface);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo {
  color: white;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

.nav-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-links a {
  color: white;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
}

.nav-links a:hover {
  background: rgba(255,255,255,0.1);
}

/* =========================
   SECTIONS
========================= */
.section {
  display: none;
  padding: 16px;
}

.active {
  display: block;
}

/* =========================
   GRID
   auto-fill, min 200px, max 4 columns
========================= */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* hard cap at 4 columns on wide screens */
@media (min-width: 900px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* =========================
   CARD
   No img tag — background-image set inline by JS
========================= */
.card {
  position: relative;
  background-color: #1f2937; /* fallback while image loads */
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1/1;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
  transform: scale(1.03);
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
}

.card:hover .overlay {
  background: rgba(0,0,0,0.8);
  transform: translateY(-3px);
}

/* =========================
   OVERLAY (RENT + LOCATION)
========================= */
.overlay {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;

  background: rgba(0,0,0,0.65);
  color: white;

  padding: 10px 12px;
  border-radius: 12px;

  display: flex;
  justify-content: space-between;
  align-items: center;

  transition: all 0.25s ease;
  transform: translateY(0);
}

.overlay .loc {
  font-size: 14px;
  font-weight: 500;
  opacity: 0.95;
}

.overlay .rent {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

/* =========================
   FORM
========================= */
.form-box {
  max-width: 500px;
  margin: auto;
  background: white;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
}

input, textarea {
  width: 100%;
  padding: 12px;
  margin: 8px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* =========================
   BUTTONS
========================= */
button {
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  background: var(--accent-hover);
}

/* =========================
   POPUP
========================= */
.popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
  z-index: 9999;
  overflow-y: auto;
  box-sizing: border-box;
}

.popup-content {
  position: relative;
  width: 100%;
  max-width: 750px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  background: #111827;
}

/* =========================
   POPUP SLIDER — full image, arrows overlaid
========================= */
.popup-slider {
  position: relative;
  width: 100%;
  height: 480px;
}

#popupImg {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-color: #1f2937;
}

/* =========================
   ARROWS — float over image
========================= */
.arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background: rgba(0,0,0,0.5);
  border: none;
  color: #f9fafb;
  font-size: 16px;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.arrow:hover {
  background: #2563eb;
}

.arrow.left  { left: 10px; }
.arrow.right { right: 10px; }

/* =========================
   CLOSE BUTTON
========================= */
.popup-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-close:hover {
  background: rgba(255,0,0,0.7);
}

/* =========================
   POPUP DETAILS — below image
========================= */
.popup-details {
  padding: 20px 22px 22px;
  color: white;
}

/* =========================
   SIDE BY SIDE MANAGE LISTINGS
========================= */
#adminListings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px;
}

.admin-card {
  background: #1f2937;
  color: white;
  padding: 10px;
  border-radius: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
}

/* =========================
   DROPDOWN
========================= */
.dropdown {
  position: relative;
}

.dropbtn {
  color: white;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 8px;
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  background: white;
  min-width: 200px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.dropdown-content div {
  padding: 10px;
  cursor: pointer;
}

.dropdown-content div:hover {
  background: #f3f4f6;
}

.dropdown:hover .dropdown-content {
  display: block;
}

/* =========================
   ADMIN PANEL
========================= */
#adminPanel {
  background: var(--dark-bg);
  color: var(--dark-text);
  min-height: 100vh;
  padding: 20px;
}

/* =========================
   RESPONSIVE — TABLET
========================= */
@media (max-width: 768px) {
  .popup-slider {
    height: 380px;
  }

  .popup-content {
    max-width: 100%;
    margin: 0 6px;
  }
}

/* =========================
   RESPONSIVE — MOBILE
========================= */
@media (max-width: 480px) {
  /* Navbar: stack logo above links if needed */
  .navbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }

  .nav-links {
    gap: 4px;
    flex-wrap: wrap;
  }

  .nav-links a {
    padding: 6px 8px;
    font-size: 16px;
    text-decoration: none;
  }

  .dropbtn {
    padding: 6px 8px;
    font-size: 13px;
  }

  /* Grid: 2 columns on small phones */
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* Popup: near full screen */
  .popup {
    padding: 0;
    align-items: flex-end;
  }

  .popup-content {
    border-radius: 16px 16px 0 0;
    max-width: 100%;
    width: 100%;
  }

  .popup-slider {
    height: 300px;
  }

  .popup-details {
    padding: 16px 14px 18px;
  }

  /* Overlay text smaller on tiny cards */
  .overlay {
    padding: 6px 8px;
    bottom: 6px;
    left: 6px;
    right: 6px;
  }

  .overlay .loc  { font-size: 11px; }
  .overlay .rent { font-size: 12px; }
}

/* =========================
   RESPONSIVE — VERY SMALL (< 360px)
========================= */
@media (max-width: 360px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.overlay .phone {
  font-size: 12px;
  color: #e5e7eb;
  width: 100%;
  margin-top: 4px;
}

/* =========================
   IMAGE PREVIEW — COVER SELECTOR
========================= */
#imagePreview {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.img-box {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 0.2s;
}

.img-box.img-cover {
  border-color: #2563eb;
}

.img-box img {
  width: 100px;
  height: 80px;
  object-fit: cover;
  display: block;
  border-radius: 6px;
}

.img-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(220,38,38,0.85);
  color: white;
  border: none;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.img-remove:hover {
  background: crimson;
}

.img-set-cover {
  position: absolute;
  bottom: 3px;
  left: 3px;
  right: 3px;
  padding: 3px 0;
  font-size: 10px;
  font-weight: 700;
  background: rgba(0,0,0,0.65);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
}

.img-set-cover:hover {
  background: #2563eb;
}

.img-cover-label {
  position: absolute;
  bottom: 3px;
  left: 3px;
  right: 3px;
  padding: 3px 0;
  font-size: 10px;
  font-weight: 700;
  background: #2563eb;
  color: white;
  border-radius: 4px;
  text-align: center;
}

.listing-note {
  margin-top: 14px !important;
  padding-top: 12px;
  border-top: 1px solid #374151;
  color: #6b7280 !important;
  font-size: 12px !important;
  line-height: 1.6;
}