/* ============================================================
   Cloudbeds Manager — Widget Dashboard Design
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Foundation */
  --bg: #E8E5E0;
  --surface: #FFFFFF;
  --surface-inset: #F5F3F0;

  /* Accent palette */
  --gold: #E8C840;
  --gold-hover: #D4B635;
  --gold-light: #FBF4D4;
  --lavender: #B8A5E0;
  --lavender-light: #EEEAF8;
  --mint: #90D4A0;
  --mint-light: #E4F5E9;
  --coral: #E87461;
  --coral-light: #FDEAE7;

  /* Neutrals */
  --text: #1E1E1E;
  --text-muted: #8A8A8A;
  --text-light: #B0ADA8;
  --border: #E8E5E0;
  --border-light: #F0EDEA;

  /* Sizing */
  --radius: 24px;
  --radius-sm: 14px;
  --radius-pill: 999px;
  --shadow: 0 4px 20px rgba(0,0,0,0.06);
  --shadow-hover: 0 8px 30px rgba(0,0,0,0.10);
  --transition: 300ms ease;
}

/* ---- Base ---- */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---- Header ---- */
header {
  background: var(--surface);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 0 var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo { flex-shrink: 0; }

header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* ---- Tab Navigation ---- */
nav {
  display: flex;
  gap: 6px;
  background: var(--surface-inset);
  padding: 4px;
  border-radius: var(--radius-pill);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 22px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-pill);
  transition: all var(--transition);
  font-family: inherit;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  background: var(--gold);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(232,200,64,0.3);
}

/* ---- Auth Controls ---- */
#auth-controls { display: flex; align-items: center; gap: 8px; }

.btn-login {
  background: var(--gold) !important;
  color: var(--text) !important;
  font-weight: 600 !important;
  padding: 10px 24px !important;
  border-radius: var(--radius-pill) !important;
  font-size: 0.9rem !important;
  box-shadow: 0 2px 12px rgba(232,200,64,0.3);
}

.btn-login:hover {
  background: var(--gold-hover) !important;
}

/* ---- Main ---- */
main {
  padding: 28px;
  max-width: 1200px;
  margin: 0 auto;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- Cards / Panels ---- */
.card {
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.panel { /* keep class for JS compat */ }

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.card-header.mini {
  margin-bottom: 14px;
}

.card-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}

.card-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.card-inset {
  background: var(--surface-inset);
  border: none;
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 20px;
}

/* ---- Two Column Layout ---- */
.two-col {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 860px) {
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  header { padding: 12px 16px; }
  main { padding: 16px; }
  .card { padding: 20px; border-radius: 20px; }
  .two-col { grid-template-columns: 1fr; }
}

/* ---- Room Type Cards ---- */
.room-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--surface-inset);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  cursor: pointer;
  transition: all var(--transition);
}

.room-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(232,200,64,0.15);
}

.room-card .name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.room-card .meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 2px;
}

/* ---- Tables ---- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  scrollbar-width: none;
}

.table-wrap::-webkit-scrollbar { display: none; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

thead th {
  padding: 10px 16px;
  text-align: left;
  color: var(--text-light);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--surface-inset);
  position: sticky;
  top: 0;
}

thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: var(--surface-inset); }

td input[type="number"] {
  width: 100px;
  font-size: 1rem;
  font-weight: 700;
}

.derived-label {
  display: inline-block;
  background: var(--lavender-light);
  color: var(--lavender);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

/* ---- Form Sections ---- */
.form-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  margin-top: 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.form-section-label:first-child { margin-top: 0; }

.more-options {
  margin: 20px 0;
}

.more-options summary {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  padding: 10px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.more-options summary::before {
  content: '›';
  font-size: 1.1rem;
  transition: transform var(--transition);
  display: inline-block;
}

.more-options[open] summary::before {
  transform: rotate(90deg);
}

.more-options summary::-webkit-details-marker { display: none; }

/* ---- Forms ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
}

.full-width { grid-column: 1 / -1; }

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.lookup-row {
  margin-bottom: 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--text);
}

.label-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding-top: 8px;
}

/* ---- Inputs ---- */
input, select {
  background: var(--surface-inset);
  border: 1.5px solid transparent;
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  transition: all var(--transition);
  width: 100%;
}

input::placeholder {
  color: var(--text-light);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--gold);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--gold-light);
}

input[type="checkbox"] {
  width: auto;
  padding: 0;
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* ---- Toggle Switch ---- */
.toggle-wrap {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: var(--radius-pill);
  transition: background var(--transition);
  cursor: pointer;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  transition: transform var(--transition);
}

input[type="checkbox"]:checked + .toggle-track {
  background: var(--lavender);
}

input[type="checkbox"]:checked + .toggle-track::after {
  transform: translateX(18px);
}

/* ---- Select Wrapper ---- */
.select-wrap {
  position: relative;
}

.select-wrap select {
  appearance: none;
  background: var(--text);
  color: white;
  padding: 12px 36px 12px 14px;
  border-radius: var(--radius-pill);
  border: none;
  font-weight: 500;
  cursor: pointer;
}

.select-wrap select:focus {
  box-shadow: 0 0 0 3px var(--gold-light);
  background: #333;
}

.select-chevron {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: white;
}

/* ---- Buttons ---- */
.btn {
  background: var(--gold);
  color: var(--text);
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  transition: all var(--transition);
  min-height: 44px;
  white-space: nowrap;
}

.btn:hover {
  background: var(--gold-hover);
  box-shadow: 0 4px 16px rgba(232,200,64,0.3);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary-lg {
  width: 100%;
  padding: 14px 28px;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
}

.btn-sm {
  background: var(--surface-inset);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-sm:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.btn-icon {
  padding: 8px;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-save {
  background: var(--surface-inset);
  color: var(--text);
  border: 1.5px solid var(--border);
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  transition: all var(--transition);
}

.btn-save:hover {
  background: var(--gold);
  border-color: var(--gold);
}

.btn-danger {
  background: var(--coral);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  margin-top: 16px;
  transition: all var(--transition);
  min-height: 44px;
}

.btn-danger:hover {
  background: #D4614F;
  box-shadow: 0 4px 16px rgba(232,116,97,0.3);
}

/* ---- Feedback ---- */
.feedback {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
  font-size: 0.85rem;
  line-height: 1.5;
  font-weight: 500;
}

.feedback.success {
  background: var(--mint-light);
  border: none;
  color: #3A8A50;
}

.feedback.error {
  background: var(--coral-light);
  border: none;
  color: var(--coral);
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  top: 28px;
  right: 28px;
  padding: 14px 24px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  transform: translateY(-20px);
  opacity: 0;
  transition: all var(--transition);
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  background: var(--mint);
  color: #1E1E1E;
}

.toast.error {
  background: var(--coral);
  color: white;
}

/* ---- Rates Header ---- */
.rates-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.rates-header .card-header {
  margin-bottom: 0;
}

/* ---- Bulk Update ---- */
.bulk-update {
  border: none;
}

.bulk-update .form-row {
  margin-bottom: 0;
}

/* ---- Loading ---- */
.loading-placeholder {
  color: var(--text-muted);
  padding: 32px 16px;
  text-align: center;
  font-size: 0.9rem;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Shimmer placeholder animation ---- */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}

/* ---- Reservation Detail ---- */
.res-detail {
  font-size: 0.9rem;
  line-height: 1.8;
  overflow: hidden;
}

.res-detail dt {
  color: var(--text-muted);
  float: left;
  width: 140px;
  font-size: 0.8rem;
  font-weight: 600;
}

.res-detail dd {
  margin-left: 150px;
  margin-bottom: 4px;
  font-weight: 500;
}

/* ---- Custom Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-light);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ---- Success Splash ---- */
.splash {
  position: fixed;
  inset: 0;
  background: rgba(30,30,30,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.splash.show {
  display: flex;
  opacity: 1;
}

.splash-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px 36px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: splashIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes splashIn {
  0% { transform: scale(0.8) translateY(20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.splash-icon {
  margin-bottom: 20px;
}

.splash-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.splash-id {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: -0.02em;
  word-break: break-all;
}

.splash-details {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 28px;
}

.splash-btn {
  min-width: 200px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 16px;
  }
  .header-left { justify-content: center; }
  nav { justify-content: center; }
  #auth-controls { justify-content: center; }

  main { padding: 12px; }

  .card {
    padding: 20px 16px;
    border-radius: 20px;
    margin-bottom: 12px;
  }

  .two-col { grid-template-columns: 1fr; gap: 12px; }

  .form-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }

  .form-row { gap: 8px; }

  input, select, .select-wrap select {
    padding: 14px 14px;
    font-size: 1rem;
    min-height: 48px;
  }

  .btn { min-height: 48px; font-size: 0.95rem; }
  .btn-primary-lg { padding: 16px 28px; font-size: 1rem; border-radius: var(--radius-sm); }

  .splash-card { padding: 40px 24px; }
  .splash-id { font-size: 1.5rem; }

  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  td, th { padding: 10px 8px; font-size: 0.8rem; }
  td input[type="number"] { width: 80px; font-size: 0.9rem; }
}
