/* =========================================================
   Kodali Homestays — shared app UI (auth, booking, admin)
   Loaded alongside styles.css, which supplies the design tokens
   (--maroon, --gold, --font-display, .btn, .container, etc.)
   ========================================================= */

/* ---------- Simple top bar for non-marketing pages ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg); border-bottom: 1px solid var(--line);
  height: var(--header-h);
  display: flex; align-items: center;
}
.topbar .nav-inner { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 1rem; }
.topbar .brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--ink); }
.topbar .brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; }
.topbar-links { display: flex; align-items: center; gap: 1rem; font-weight: 600; font-size: .94rem; }
.topbar-links a { color: var(--ink-soft); }
.topbar-links a:hover, .topbar-links a.active { color: var(--maroon); }
.topbar-user { display: flex; align-items: center; gap: .8rem; font-size: .9rem; color: var(--ink-soft); }

.app-main { min-height: calc(100vh - var(--header-h)); background: var(--bg-2); padding-block: clamp(2rem, 5vw, 3.5rem); }

/* ---------- Auth card ---------- */
.auth-shell { display: flex; justify-content: center; padding-inline: 1rem; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: clamp(1.6rem, 4vw, 2.4rem); box-shadow: var(--shadow-md);
}
.auth-card h1 { font-size: 1.7rem; margin-bottom: .3rem; }
.auth-sub { color: var(--ink-soft); font-size: .95rem; margin-bottom: 1.6rem; }
.auth-switch { margin-top: 1.4rem; text-align: center; font-size: .92rem; color: var(--ink-soft); }
.auth-switch a { color: var(--saffron-ink); font-weight: 700; }

.auth-divider { display: flex; align-items: center; gap: .8rem; margin: 1.2rem 0; color: var(--ink-faint); font-size: .85rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.social-auth-row { display: grid; gap: .7rem; }
.social-auth-btn { display: flex; align-items: center; justify-content: center; gap: .6rem; width: 100%; }
.auth-admin-link { display: block; margin-top: .6rem; text-align: center; font-size: .85rem; color: var(--ink-faint); }

/* ---------- Form fields (shared by auth / booking / admin) ---------- */
.form-grid { display: grid; gap: 1rem; }
.field { display: grid; gap: .4rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field label { font-weight: 700; font-size: .88rem; color: var(--ink); }
.field input, .field select, .field textarea {
  font: inherit; color: var(--ink); background: #FFFDF9;
  border: 1.5px solid var(--line); border-radius: var(--r-sm);
  padding: .75rem .85rem; min-height: 46px; width: 100%;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--saffron); box-shadow: 0 0 0 3px rgba(198,93,33,.16);
}
.field-hint { font-size: .8rem; color: var(--ink-faint); }
.phone-row { display: flex; gap: .5rem; }
.phone-row select { flex: 0 0 auto; width: 6.4rem; font-size: .92rem; padding-inline: .5rem; }
.phone-row input { flex: 1; }
.form-submit { width: 100%; margin-top: .4rem; }

/* ---------- Alerts / toasts ---------- */
.alert { padding: .8rem 1rem; border-radius: var(--r-sm); font-size: .9rem; font-weight: 600; margin-bottom: 1rem; }
.alert-error { background: #FBEAE4; color: #A8330F; border: 1px solid #F1C4B2; }
.alert-success { background: #EEF3E9; color: #3F5A30; border: 1px solid #D6E2C9; }
.alert-info { background: #FBEFD6; color: #7C5A1E; border: 1px solid #EFDBA3; }
[hidden] { display: none !important; }

/* ---------- Status badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .65rem; border-radius: var(--r-pill); font-size: .78rem; font-weight: 700; letter-spacing: .02em; }
.badge-pending_payment { background: #FBEFD6; color: #8A5E12; }
.badge-confirmed { background: #E4F0E1; color: #2E5A22; }
.badge-cancelled, .badge-failed { background: #F6E1DC; color: #9A2E17; }

/* ---------- Loading spinner ---------- */
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.spinner-dark { border-color: rgba(60,20,15,.2); border-top-color: var(--maroon); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards / panels shared by booking + dashboard ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(1.4rem, 3vw, 2rem); box-shadow: var(--shadow-sm); }
.panel + .panel { margin-top: 1.4rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.4rem; }

/* ---------- Room picker (booking page) ---------- */
.room-pick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.room-pick {
  border: 2px solid var(--line); border-radius: var(--r); padding: 1rem; cursor: pointer; text-align: left;
  background: var(--surface); transition: border-color .2s ease, box-shadow .2s ease;
  display: flex; flex-direction: column; gap: .5rem;
}
.room-pick img { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: var(--r-sm); }
.room-pick.selected { border-color: var(--saffron); box-shadow: 0 0 0 3px rgba(198,93,33,.14); }
.room-pick h3 { font-size: 1.05rem; color: var(--maroon); }
.room-pick-card { display: flex; flex-direction: column; gap: .4rem; }
.room-pick-card .room-pick { flex: 1; }
.room-pick-photos-link {
  text-align: center; font-size: .82rem; font-weight: 600; color: var(--saffron-ink);
  padding: .4rem; border-radius: var(--r-sm); transition: background .15s ease;
}
.room-pick-photos-link:hover { background: var(--bg-2); text-decoration: underline; }
.room-pick .price { font-weight: 700; color: var(--ink); }
.room-pick .price small { font-weight: 500; color: var(--ink-faint); }

/* On small screens, force a compact 2-up grid instead of one card per row. */
@media (max-width: 560px) {
  .room-pick-grid { grid-template-columns: repeat(2, 1fr); gap: .7rem; }
  .room-pick { padding: .6rem; gap: .3rem; }
  .room-pick h3 { font-size: .88rem; line-height: 1.2; }
  .room-pick .field-hint { font-size: .72rem; }
  .room-pick .price { font-size: .92rem; }
}
@media (max-width: 360px) {
  .room-pick-grid { grid-template-columns: 1fr; }
}

/* ---------- Calendar ---------- */
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.calendar-head button { border: 1px solid var(--line); border-radius: var(--r-sm); padding: .4rem .7rem; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-dow { text-align: center; font-size: .75rem; font-weight: 700; color: var(--ink-faint); padding-bottom: .3rem; }
.calendar-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); font-size: .88rem; font-weight: 600; color: var(--ink);
  background: var(--surface); cursor: pointer; border: 1px solid var(--line); position: relative;
}
.calendar-day.disabled { color: var(--ink-faint); background: transparent; border-color: transparent; cursor: not-allowed; text-decoration: line-through; }
.calendar-day.booked { background: #C9372E; color: #fff; border-color: #A62A22; cursor: not-allowed; }
.calendar-day.today { border-color: var(--gold); border-width: 2px; }
.calendar-day.in-range { background: #F3DFB4; }
.calendar-day.range-start, .calendar-day.range-end { background: var(--saffron); color: #fff; }
.calendar-day.empty { visibility: hidden; }
.calendar-day.closed { background: #B98530; color: #fff; border-color: #8C6423; }
.calendar-day.selected { outline: 2px solid var(--saffron); outline-offset: -2px; background: #F3DFB4; }
.calendar-day-check { position: absolute; top: 3px; left: 3px; margin: 0; width: 14px; height: 14px; cursor: pointer; }
.calendar-day-num { pointer-events: none; }
.calendar-day-price {
  position: absolute; bottom: 2px; left: 0; right: 0; text-align: center;
  font-size: .58rem; font-weight: 700; color: var(--saffron-ink); pointer-events: none;
}
.calendar-legend { display: flex; gap: 1.2rem; margin-top: .8rem; font-size: .82rem; color: var(--ink-soft); flex-wrap: wrap; }
.calendar-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.calendar-actions { display: flex; align-items: center; gap: .8rem; margin-top: 1.2rem; flex-wrap: wrap; }
.cal-booking-detail p { margin: 0 0 .4rem; }
.cal-booking-detail hr { border: none; border-top: 1px solid var(--line); margin: 1rem 0; }

/* ---------- Toast notification ---------- */
.toast {
  position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%) translateY(20px);
  background: var(--maroon-ink); color: var(--on-dark); padding: .8rem 1.4rem; border-radius: var(--r-md);
  font-weight: 600; font-size: .92rem; box-shadow: var(--shadow-md); z-index: 300;
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: #7A2A1F; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---------- Payment methods row ---------- */
.payment-methods-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.payment-method-chip {
  display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 700;
  color: var(--ink-soft); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: .3rem .7rem;
}
.payment-method-chip svg { color: var(--saffron-ink); }

/* ---------- Booking summary ---------- */
.summary-row { display: flex; justify-content: space-between; padding: .5rem 0; border-bottom: 1px dashed var(--line); font-size: .95rem; }
.summary-row:last-of-type { border-bottom: none; }
.summary-total { font-weight: 800; font-size: 1.15rem; color: var(--maroon); }

/* ---------- Tables (admin bookings) ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data-table th { text-align: left; padding: .7rem .8rem; border-bottom: 2px solid var(--line); color: var(--ink-faint); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
table.data-table td { padding: .7rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data-table tr:hover td { background: var(--bg-2); }

/* ---------- Admin dashboard layout ---------- */
.dash-shell { display: grid; grid-template-columns: 220px 1fr; gap: 1.6rem; align-items: start; }
.dash-nav { position: sticky; top: calc(var(--header-h) + 1rem); display: grid; gap: .3rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: .6rem; }
.dash-nav button {
  text-align: left; padding: .7rem .9rem; border-radius: var(--r-sm); font-weight: 700; color: var(--ink-soft);
  display: flex; align-items: center; gap: .6rem;
}
.dash-nav button.active, .dash-nav button:hover { background: var(--bg-2); color: var(--maroon); }
.dash-panel { display: none; }
.dash-panel.active { display: block; }

/* ---------- Checkbox grid (amenities / policy) ---------- */
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem .8rem; }
.checkbox-item { display: flex; align-items: flex-start; gap: .5rem; font-size: .9rem; color: var(--ink); }
.checkbox-item input { margin-top: .2rem; flex: none; width: 16px; height: 16px; }

/* ---------- Offer cards ---------- */
.offer-card { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.2rem; background: var(--surface); margin-bottom: 1rem; }
.offer-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.offer-active-toggle { display: flex; align-items: center; gap: .4rem; font-weight: 700; font-size: .9rem; }

/* ---------- Admin room editor ---------- */
.room-edit-card { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.2rem; background: var(--surface); margin-bottom: 1rem; }
.room-edit-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.room-edit-photos { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .6rem; }
.room-photo-thumb { position: relative; width: 90px; height: 68px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); }
.room-photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.room-photo-thumb button { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; background: rgba(20,20,20,.7); color: #fff; font-size: .7rem; line-height: 1; display: grid; place-items: center; }
.upload-btn { border: 1.5px dashed var(--gold); border-radius: var(--r-sm); padding: .6rem 1rem; font-weight: 700; color: var(--saffron-ink); font-size: .85rem; cursor: pointer; display: inline-flex; align-items: center; gap: .5rem; }
.upload-btn input { display: none; }
.feature-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.feature-tag { background: var(--bg-2); border-radius: var(--r-pill); padding: .3rem .7rem; font-size: .82rem; font-weight: 600; display: inline-flex; align-items: center; gap: .4rem; }
.feature-tag button { color: var(--ink-faint); font-weight: 900; }
.tag-input-row { display: flex; gap: .5rem; margin-top: .6rem; }
.tag-input-row input { flex: 1; }

@media (max-width: 860px) {
  .dash-shell { grid-template-columns: 1fr; }
  .dash-nav { position: static; display: flex; overflow-x: auto; }
  .field-row { grid-template-columns: 1fr; }
}

/* ---------- Reports ---------- */
.report-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.report-stat {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: .3rem;
}
.report-stat-label { font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.report-stat-value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; color: var(--maroon-ink); }

.report-table .report-row { cursor: pointer; }
.report-table .report-row:hover { background: var(--bg-2); }
.report-table .report-row:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.report-bar-track { width: 100%; min-width: 90px; height: 10px; border-radius: var(--r-pill); background: var(--bg-2); overflow: hidden; }
.report-bar-fill { height: 100%; background: var(--saffron); border-radius: var(--r-pill); }

.report-modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 14, 8, .55); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 1.2rem;
}
.report-modal {
  background: var(--surface); border-radius: var(--r-lg); max-width: 900px; width: 100%;
  max-height: 85vh; overflow-y: auto; padding: 1.4rem clamp(1rem, 3vw, 1.8rem); box-shadow: var(--shadow-md);
}
.report-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.report-modal-close { font-size: 1.6rem; line-height: 1; color: var(--ink-soft); padding: .2rem .5rem; }
.report-modal-close:hover { color: var(--maroon); }

/* ---------- Booking message thread (admin <-> guest chat) ---------- */
.chat-thread { display: flex; flex-direction: column; gap: .6rem; max-height: 360px; overflow-y: auto; padding: .3rem .2rem; margin-bottom: 1rem; }
.chat-msg { max-width: 80%; padding: .55rem .8rem; border-radius: var(--r-sm); background: var(--bg-2); }
.chat-msg-mine { align-self: flex-end; background: var(--saffron); color: #fff; }
.chat-msg-mine .chat-msg-meta { color: rgba(255,255,255,.75); }
.chat-msg-text { white-space: pre-wrap; word-break: break-word; margin: 0; }
.chat-msg-meta { font-size: .74rem; color: var(--ink-faint); margin: .25rem 0 0; }
.chat-empty { color: var(--ink-faint); font-size: .9rem; text-align: center; padding: 1.4rem 0; }
.chat-compose { display: flex; gap: .6rem; align-items: flex-end; }
.chat-compose textarea { flex: 1; font: inherit; color: var(--ink); background: #FFFDF9; border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: .6rem .75rem; resize: vertical; min-height: 46px; }
.chat-compose textarea:focus { outline: none; border-color: var(--saffron); box-shadow: 0 0 0 3px rgba(198,93,33,.16); }
.chat-email-row { display: flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--ink-soft); margin-top: .5rem; }

/* ---------- Notification bell ---------- */
.notif-bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; color: var(--ink-soft); background: transparent; border: none; cursor: pointer; transition: background .15s ease, color .15s ease; }
.notif-bell:hover { background: var(--bg-2); color: var(--maroon); }
.notif-badge {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 3px;
  display: flex; align-items: center; justify-content: center;
  background: var(--maroon); color: #fff; font-size: .62rem; font-weight: 700;
  border-radius: 999px; border: 2px solid var(--bg); line-height: 1;
}

/* ---------- Inbox list (Profile tab) ---------- */
.inbox-item { padding: .8rem .9rem; border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: .6rem; cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.inbox-item:hover { border-color: var(--saffron); background: var(--bg-2); }
.inbox-item-unread { border-left: 3px solid var(--maroon); background: #FBF3EA; }
.inbox-item .chat-msg-meta { margin: 0 0 .25rem; }
.inbox-item .chat-msg-text { font-size: .92rem; }
