/* ═══════════════════════════════════════════════════════════
   Combate Del Mar Dashboard  —  Styles
   ══════════════════════════════════════════════════════════ */

:root {
  --sidebar-width: 300px;
  --nav-height: 52px;
  --bg-dark:      #0f1923;
  --bg-sidebar:   #141f2e;
  --bg-content:   #1a2535;
  --bg-card:      #1e2d40;
  --bg-input:     #0f1923;
  --border-color: #2a3a50;
  --text-primary: #e8edf3;
  --text-muted:   #7a8fa6;
  --airbnb-color: #ff5a5f;
  --booking-color:#003580;
  --advisory-bg:  #2a1f0a;
  --advisory-border: #d97706;
}

/* ── Base ──────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body {
  height: 100%;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}

/* ── Navbar ────────────────────────────────────────────── */
.navbar {
  background: var(--bg-sidebar) !important;
  border-bottom: 1px solid var(--border-color);
  height: var(--nav-height);
  z-index: 100;
}
.navbar-brand { font-size: 1rem; letter-spacing: 0.03em; }

.platform-badge-airbnb  { background: var(--airbnb-color) !important; }
.platform-badge-booking { background: var(--booking-color) !important; }
.badge.bg-unconfigured  { background: #555 !important; opacity: 0.7; }

/* ── Main Layout ───────────────────────────────────────── */
.main-layout {
  display: flex;
  height: calc(100vh - var(--nav-height));
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}
.reservation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  -webkit-overflow-scrolling: touch;
}
.reservation-list::-webkit-scrollbar { width: 4px; }
.reservation-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.month-group-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 8px 4px;
}

/* Reservation card */
.res-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  /* Touch-friendly min height */
  min-height: 64px;
}
.res-card:hover  { border-color: #3a5a7a; background: #243447; }
.res-card:active { opacity: 0.85; }
.res-card.active { border-color: #4a9eff; background: #1a3050; }
.res-card.res-checkin-today  { border-left: 3px solid #22c55e; }
.res-card.res-active         { border-left: 3px solid #4a9eff; }
.res-card.res-checkout-today { border-left: 3px solid #f59e0b; }
.res-card.res-past           { opacity: 0.55; }

.res-card-name  { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-card-dates { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.res-card-meta  { display: flex; gap: 6px; align-items: center; margin-top: 4px; flex-wrap: wrap; }

/* Listing name pill (e.g. "Unit A") on sidebar cards */
.listing-name-pill {
  font-size: 10px;
  background: #1e2d40;
  border: 1px solid #ff5a5f44;
  border-radius: 20px;
  padding: 1px 7px;
  color: #ff8a8d;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Listing name badge in detail header */
.listing-name-badge {
  background: #ff5a5f22 !important;
  color: #ff8a8d !important;
  border: 1px solid #ff5a5f55;
  font-size: 11px;
}

/* Guest count pill on card */
.guest-count-pill {
  font-size: 10px;
  background: #1e2d40;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1px 7px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* ── Content Area ──────────────────────────────────────── */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-content);
}

/* ── Detail Panel ──────────────────────────────────────── */
.detail-panel {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.detail-panel::-webkit-scrollbar { width: 5px; }
.detail-panel::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }

.detail-header {
  padding: 16px 20px 0;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}
.detail-header h4 { color: var(--text-primary); font-size: 1.1rem; }
.stay-dates { font-size: 14px; font-weight: 600; }

/* Guest count badge (inline in header) */
.guest-count-badge {
  cursor: pointer;
  font-size: 11px;
  transition: opacity 0.15s;
}
.guest-count-badge:hover { opacity: 0.8; }

/* Tabs */
.detail-tabs {
  padding: 0 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}
.detail-tabs .nav-link {
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  font-size: 13px;
  border-radius: 0;
  min-height: 44px; /* touch target */
}
.detail-tabs .nav-link:hover  { color: var(--text-primary); background: none; }
.detail-tabs .nav-link.active { color: #4a9eff; background: none; border-bottom-color: #4a9eff; }

.tab-content-panel { padding: 16px 20px; flex: 1; }

/* Note/message form inputs */
.add-note-form textarea,
.add-note-form input,
.add-note-form select {
  background: var(--bg-input) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
  font-size: 13px;
  /* Prevent iOS zoom on focus */
  font-size: max(13px, 16px);
}
@media (min-width: 769px) {
  .add-note-form textarea,
  .add-note-form input,
  .add-note-form select { font-size: 13px; }
}
.add-note-form textarea:focus,
.add-note-form input:focus {
  box-shadow: 0 0 0 2px #4a9eff33 !important;
  border-color: #4a9eff !important;
}

/* Note items */
.note-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  position: relative;
}
.note-item:hover .note-actions { opacity: 1; }
.note-content { font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.note-content.editing {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px;
  width: 100%;
  min-height: 60px;
  color: var(--text-primary);
  resize: vertical;
}
.note-meta    { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.note-actions { opacity: 0; transition: opacity 0.15s; position: absolute; top: 8px; right: 10px; display: flex; gap: 4px; }

/* Message bubbles */
.message-bubble           { display: flex; flex-direction: column; margin-bottom: 12px; max-width: 85%; }
.message-bubble.guest     { align-self: flex-start; }
.message-bubble.host      { align-self: flex-end; margin-left: auto; }
.bubble-content           { padding: 10px 14px; border-radius: 14px; font-size: 13px; line-height: 1.5; position: relative; }
.guest .bubble-content    { background: var(--bg-card); border: 1px solid var(--border-color); border-bottom-left-radius: 4px; }
.host  .bubble-content    { background: #1a3050; border: 1px solid #2a4a6a; border-bottom-right-radius: 4px; }
.bubble-content.important-msg { border-color: #f59e0b !important; box-shadow: 0 0 0 1px #f59e0b33; }
.bubble-meta              { font-size: 10px; color: var(--text-muted); margin-top: 3px; display: flex; gap: 6px; align-items: center; }
.host  .bubble-meta       { justify-content: flex-end; }
.messages-container       { display: flex; flex-direction: column; }

/* ── Advisories Panel ──────────────────────────────────── */
.advisories-panel {
  background: var(--advisory-bg);
  border-top: 2px solid var(--advisory-border);
  flex-shrink: 0;
  max-height: 240px;
  display: flex;
  flex-direction: column;
  transition: max-height 0.25s ease;
}
.advisories-panel.collapsed { max-height: 46px; overflow: hidden; }
.advisories-header { padding: 10px 16px; border-bottom: 1px solid #3a2a0a; flex-shrink: 0; }
#advisories-body   { overflow-y: auto; flex: 1; padding: 8px 12px; }
.advisory-card     { background: #1f1508; border: 1px solid #3a2a0a; border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; }
.advisory-card.has-schedule { border-left: 3px solid var(--advisory-border); }
.advisory-title   { font-size: 13px; font-weight: 600; color: #fbbf24; }
.advisory-content { font-size: 12px; color: #a08040; margin-top: 4px; line-height: 1.5; max-height: 48px; overflow: hidden; }
.advisory-schedule { font-size: 11px; color: #d97706; margin-top: 5px; }
.advisory-card button { opacity: 0; transition: opacity 0.15s; }
.advisory-card:hover button { opacity: 1; }

/* ── Utility ───────────────────────────────────────────── */
.btn-xs { padding: 3px 8px; font-size: 11px; line-height: 1.6; border-radius: 4px; min-height: 28px; }
.platform-dot-airbnb  { color: var(--airbnb-color); }
.platform-dot-booking { color: #4dabf7; }

.form-control, .form-select {
  background-color: var(--bg-input) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
  /* iOS zoom prevention */
  font-size: max(13px, 16px) !important;
}
@media (min-width: 769px) {
  .form-control, .form-select { font-size: 13px !important; }
}
.form-control::placeholder { color: var(--text-muted) !important; }
.form-control:focus, .form-select:focus { box-shadow: 0 0 0 2px #4a9eff33 !important; }

.toast { background: #1e2d40 !important; border: 1px solid var(--border-color); color: var(--text-primary); }

.spinning { animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

/* Back button — hidden on desktop */
.back-btn { display: none !important; }

/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --nav-height: 56px; }

  .main-layout {
    flex-direction: column;
    height: calc(100vh - var(--nav-height));
    overflow: hidden;
  }

  /* Sidebar: full screen, scrollable */
  .sidebar {
    width: 100%;
    min-width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    /* Take full height when content-area is hidden */
    flex: 1;
  }

  /* Content area: full screen, hidden until a reservation is selected */
  .content-area {
    display: none;
    width: 100%;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
  }

  /* When detail is open, show content and hide sidebar */
  .main-layout.show-detail .sidebar      { display: none; }
  .main-layout.show-detail .content-area { display: flex; }

  /* Show back button on mobile when detail is open */
  .main-layout.show-detail ~ * .back-btn,
  .show-detail-back .back-btn { display: inline-flex !important; }
  #btn-back { display: none !important; }
  body.detail-open #btn-back { display: inline-flex !important; }

  /* Detail panel: full height, scrollable */
  .detail-panel { min-height: 0; }

  /* Advisories: shorter on mobile */
  .advisories-panel { max-height: 180px; }
  .advisories-panel.collapsed { max-height: 46px; }

  /* Larger tap targets */
  .res-card { padding: 12px 14px; min-height: 72px; }
  .detail-tabs .nav-link { min-height: 48px; padding: 12px 16px; }

  /* Guest count editor: full width on mobile */
  #guest-count-editor .d-flex { max-width: 100% !important; }

  /* Tab body: comfortable padding */
  .tab-content-panel { padding: 14px 16px; }
  .detail-header     { padding: 14px 16px 0; }

  /* Stack message input on mobile */
  .add-note-form .d-flex.gap-2 { flex-wrap: wrap; }
  .add-note-form #msg-content  { min-width: 0; width: 100%; }

  /* Navbar: keep brand visible */
  .navbar-brand { font-size: 0.95rem; }
}

/* ── Small phones (≤ 380px) ───────────────────────────── */
@media (max-width: 380px) {
  .navbar-brand { font-size: 0.85rem; }
  .res-card-name { font-size: 12px; }
  .tab-content-panel { padding: 12px; }
}
