/* app.css — REX property map + live bidding styles.
   Teal design system. Mobile-responsive. */

/* ─── Tokens ─────────────────────────────────────── */
:root {
  --teal-deep:   #005C5C;
  --teal-primary: #008080;
  --teal-light:   #00A3A3;
  --teal-pale:    #E0F7F7;
  --dark:         #0A1A1A;
  --white:        #FFFFFF;
  --gray-50:      #F5FAFA;
  --gray-100:     #EBF4F4;
  --gray-200:     #D0E0E0;
  --gray-400:     #8AA0A0;
  --gray-600:     #4A6B6B;
  --gray-800:     #1A3030;
  --accent:       #00D4A8;
  --accent-dark:  #00A888;
  --danger:       #E53E3E;
  --shadow-sm:    0 1px 4px rgba(0,0,0,.08);
  --shadow-md:    0 4px 16px rgba(0,0,0,.12);
  --radius:       8px;
}

/* ─── Reset & Base ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'DM Sans', 'Helvetica Neue', sans-serif;
  color: var(--dark);
  background: var(--white);
  overflow: hidden;
  height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; outline: none; }
input, select { font-family: inherit; }

/* ─── Nav ───────────────────────────────────────── */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.5rem;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,128,128,.1);
  box-shadow: var(--shadow-sm);
}
.logo { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.35rem; color: var(--teal-deep); letter-spacing: -.5px; }
.logo span { color: var(--teal-light); }
.nav-links { display: flex; align-items: center; gap: .75rem; }
.nav-links a { font-size: .875rem; color: var(--gray-600); transition: color .2s; }
.nav-links a:hover { color: var(--teal-primary); }
.nav-cta {
  background: var(--teal-primary); color: var(--white);
  padding: .4rem 1rem; border-radius: 6px;
  font-weight: 600; font-size: .875rem;
  transition: background .2s;
}
.nav-cta:hover { background: var(--teal-deep); color: var(--white); }

/* ─── App Container ──────────────────────────────── */
#app-container {
  display: flex; height: 100vh;
  padding-top: 56px; /* nav height */
}

/* ─── Map Panel ─────────────────────────────────── */
#map-panel {
  flex: 1; position: relative;
  overflow: hidden;
}
#property-map { width: 100%; height: 100%; }

/* Leaflet teal marker style */
.custom-marker {
  background: var(--teal-primary); color: var(--white);
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,128,128,.5);
  border: 2.5px solid var(--white);
  cursor: pointer;
  transition: transform .2s;
}
.custom-marker:hover { transform: scale(1.15); }
.custom-marker.auction-soon { background: #F6AD55; color: var(--dark); }
.custom-marker.ending-soon { background: var(--danger); }

/* Map controls overlay */
#map-controls {
  position: absolute; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  z-index: 500;
  display: flex; gap: .5rem;
}
.map-btn {
  background: var(--white); color: var(--teal-deep);
  border: 1.5px solid var(--teal-primary);
  padding: .5rem 1rem; border-radius: 20px;
  font-size: .8rem; font-weight: 600;
  display: flex; align-items: center; gap: .4rem;
  box-shadow: var(--shadow-md);
  transition: all .2s;
}
.map-btn:hover { background: var(--teal-pale); }

/* ─── Sidebar ───────────────────────────────────── */
#sidebar {
  width: 420px; min-width: 340px;
  background: var(--gray-50);
  border-left: 1px solid var(--gray-200);
  overflow-y: auto;
  display: flex; flex-direction: column;
}

#sidebar.hidden-panel #property-list { display: none; }
#sidebar.hidden-panel #bid-panel { display: flex; }

/* ─── Property List ─────────────────────────────── */
.sidebar-header {
  padding: 1.25rem 1.25rem .75rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
  background: var(--white);
  position: sticky; top: 0; z-index: 10;
}
.sidebar-header h2 { font-size: 1rem; font-weight: 700; color: var(--teal-deep); }
.badge {
  background: var(--teal-pale); color: var(--teal-primary);
  font-size: .75rem; font-weight: 700;
  padding: .2rem .6rem; border-radius: 20px;
}

/* ─── Listing Cards ─────────────────────────────── */
#listings-container { padding: .75rem; display: flex; flex-direction: column; gap: .6rem; }
.listing-card {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow-sm);
}
.listing-card:hover { border-color: var(--teal-light); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.listing-card.selected { border-color: var(--teal-primary); box-shadow: 0 0 0 3px rgba(0,128,128,.15); }

.listing-img { width: 100%; height: 160px; object-fit: cover; background: var(--gray-100); }
.listing-body { padding: .75rem; }
.listing-price { font-size: 1.15rem; font-weight: 800; color: var(--teal-deep); }
.listing-address { font-size: .8rem; color: var(--gray-600); margin-top: .15rem; }
.listing-details { display: flex; gap: .5rem; margin: .4rem 0; }
.listing-detail { font-size: .72rem; background: var(--gray-100); color: var(--gray-600); padding: .15rem .45rem; border-radius: 4px; font-weight: 600; }

.listing-auction {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--gray-200);
}
.auction-timer { font-size: .78rem; font-weight: 700; color: var(--teal-primary); }
.auction-timer.ending-soon { color: var(--danger); }
.auction-badge {
  font-size: .65rem; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  padding: .15rem .45rem; border-radius: 4px;
  background: var(--teal-pale); color: var(--teal-primary);
}
.auction-badge.live { background: #FED7D7; color: var(--danger); }

/* ─── Bid Panel ─────────────────────────────────── */
#bid-panel {
  flex-direction: column;
  padding: 1rem 1.25rem;
  display: none; /* toggled via .hidden-panel on parent */
}
#bid-panel.visible { display: flex; }

.back-btn {
  display: flex; align-items: center; gap: .35rem;
  background: none; color: var(--gray-600); font-size: .82rem;
  font-weight: 600; margin-bottom: .75rem;
  padding: .25rem 0;
  transition: color .2s;
}
.back-btn:hover { color: var(--teal-primary); }

#bid-property-info { margin-bottom: 1rem; }
#bid-property-info .bid-prop-img { width: 100%; height: 200px; object-fit: cover; border-radius: var(--radius); margin-bottom: .75rem; }
#bid-property-info .bid-prop-price { font-size: 1.5rem; font-weight: 800; color: var(--teal-deep); }
#bid-property-info .bid-prop-address { font-size: .875rem; color: var(--gray-600); margin-top: .2rem; }
#bid-property-info .bid-prop-stats { display: flex; gap: .4rem; margin-top: .5rem; flex-wrap: wrap; }

/* ─── Countdown ─────────────────────────────────── */
#countdown-container {
  background: linear-gradient(135deg, var(--teal-deep) 0%, var(--teal-primary) 100%);
  color: var(--white); border-radius: var(--radius);
  padding: 1rem 1.25rem; text-align: center; margin-bottom: 1rem;
}
#countdown-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; opacity: .8; }
#countdown-timer { font-family: 'Space Grotesk', monospace; font-size: 2.25rem; font-weight: 700; letter-spacing: -1px; margin: .25rem 0; }
#countdown-status { font-size: .65rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; opacity: .9; }

/* ─── Current Bid ───────────────────────────────── */
#current-bid-display {
  background: var(--white); border: 2px solid var(--teal-primary);
  border-radius: var(--radius); padding: 1rem 1.25rem;
  text-align: center; margin-bottom: 1rem; box-shadow: var(--shadow-sm);
}
.bid-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-400); font-weight: 700; }
#current-bid-amount { font-family: 'Space Grotesk', monospace; font-size: 2rem; font-weight: 800; color: var(--teal-deep); margin: .2rem 0; }
#bidder-info { font-size: .78rem; color: var(--gray-600); }

/* ─── Bid History ───────────────────────────────── */
#bid-history { margin-bottom: 1rem; }
#bid-history h3 { font-size: .85rem; font-weight: 700; color: var(--gray-800); margin-bottom: .5rem; }
#bid-list { display: flex; flex-direction: column; gap: .3rem; max-height: 140px; overflow-y: auto; }
.bid-entry {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 6px; padding: .45rem .75rem; font-size: .78rem;
}
.bid-entry.top-bid { border-color: var(--teal-light); background: var(--teal-pale); }
.bid-entry .bidder { font-weight: 600; color: var(--gray-800); }
.bid-entry .bid-amt { font-weight: 800; color: var(--teal-deep); }
.bid-entry .bid-time { font-size: .68rem; color: var(--gray-400); }

/* ─── Bid Form ──────────────────────────────────── */
#bid-form-container { margin-top: auto; }
#bid-form-container h3 { font-size: .9rem; font-weight: 700; color: var(--gray-800); margin-bottom: .75rem; }
.form-group { margin-bottom: .75rem; }
.form-group label { display: block; font-size: .72rem; font-weight: 700; color: var(--gray-600); text-transform: uppercase; letter-spacing: .3px; margin-bottom: .3rem; }
.form-group input {
  width: 100%; padding: .6rem .75rem;
  border: 1.5px solid var(--gray-200); border-radius: 6px;
  font-size: .875rem; color: var(--dark);
  background: var(--white);
  transition: border-color .2s;
}
.form-group input:focus { border-color: var(--teal-primary); outline: none; }
.bid-input-wrap { position: relative; }
.currency-prefix { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--gray-400); }
.bid-input-wrap input { padding-left: 1.5rem; }
#bid-error { font-size: .75rem; color: var(--danger); margin-top: .25rem; min-height: 1rem; }

.bid-btn {
  width: 100%; padding: .8rem;
  background: var(--teal-primary); color: var(--white);
  font-size: .9rem; font-weight: 700; border-radius: var(--radius);
  transition: background .2s, transform .1s;
  display: flex; align-items: center; justify-content: center; gap: .4rem;
}
.bid-btn:hover { background: var(--teal-deep); }
.bid-btn:active { transform: scale(.98); }
.bid-btn:disabled { background: var(--gray-400); cursor: not-allowed; }

/* ─── Loading / Spinner ──────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(255,255,255,.9);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--teal-primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-overlay p { font-size: .875rem; color: var(--gray-600); font-weight: 600; }
#loading-overlay.hidden { display: none; }

/* ─── Toast ─────────────────────────────────────── */
#toast-container { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: .5rem; align-items: center; }
.toast {
  background: var(--dark); color: var(--white);
  padding: .65rem 1.25rem; border-radius: 20px;
  font-size: .82rem; font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toastIn .3s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--teal-primary); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Responsive ────────────────────────────────── */
@media (max-width: 768px) {
  #app-container { flex-direction: column; overflow-y: auto; }
  #map-panel { height: 50vh; min-height: 300px; }
  #sidebar { width: 100%; min-width: unset; border-left: none; border-top: 1px solid var(--gray-200); }
  #map-controls { bottom: .75rem; }
  #countdown-timer { font-size: 1.75rem; }
  #current-bid-amount { font-size: 1.5rem; }
}
@media (max-width: 480px) {
  nav { padding: .75rem 1rem; }
  .nav-links { gap: .4rem; }
  .nav-links a:not(.nav-cta) { display: none; }
}