/* ============================================================
   StayMastery HUB — Components
   ============================================================ */

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 9px var(--sp-5);
  border-radius: var(--r-pill);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* Varianti */
.btn-primary {
  background: var(--coral);
  color: var(--white);
  border-color: var(--coral);
}
.btn-primary:hover {
  background: var(--coral-h);
  border-color: var(--coral-h);
  box-shadow: var(--shadow-sm);
}

.btn-dark {
  background: var(--dark);
  color: var(--white);
  border-color: var(--dark);
}
.btn-dark:hover {
  background: #2a2520;
  box-shadow: var(--shadow-sm);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-outline:hover {
  background: var(--bg-alt);
  border-color: var(--muted);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-alt);
  color: var(--text);
}

.btn-danger {
  background: var(--red-pale);
  color: var(--red);
  border-color: var(--red-pale);
}
.btn-danger:hover {
  background: var(--red);
  color: var(--white);
}

.btn-success {
  background: var(--green-pale);
  color: var(--green);
  border-color: var(--green-pale);
}
.btn-success:hover {
  background: var(--green);
  color: var(--white);
}

/* Taglie */
.btn-sm { padding: 6px var(--sp-3); font-size: var(--text-xs); }
.btn-lg { padding: 12px var(--sp-8); font-size: var(--text-base); }
.btn-icon { padding: 8px; border-radius: var(--r-md); }
.btn-icon.btn-sm { padding: 6px; }
.btn-full { width: 100%; }

/* Loading state */
.btn.loading { pointer-events: none; opacity: .7; }
.btn.loading::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-left: var(--sp-2);
}

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.card-sm  { padding: var(--sp-4); }
.card-md  { padding: var(--sp-5) var(--sp-6); }
.card-lg  { padding: var(--sp-8); }
.card-flat { box-shadow: none; }
.card-hover {
  transition: box-shadow var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
  cursor: pointer;
}
.card-hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--sp-4);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.card-footer {
  padding-top: var(--sp-4);
  margin-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

/* ── KPI CARD ───────────────────────────────────────────────── */
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  box-shadow: var(--shadow-xs);
}
.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi-card-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.kpi-card-icon.coral { background: var(--coral-pale); }
.kpi-card-icon.green { background: var(--green-pale); }
.kpi-card-icon.amber { background: var(--amber-pale); }
.kpi-card-icon.dark  { background: var(--bg-alt); }
.kpi-card-trend {
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  display: flex;
  align-items: center;
  gap: 3px;
}
.kpi-card-trend.up   { color: var(--green); }
.kpi-card-trend.down { color: var(--coral); }

/* ── BADGES ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
}
.badge-no-dot::before { display: none; }

/* Status booking */
.badge-confirmed      { background: #dcfce7; color: #15803d; }
.badge-pending        { background: var(--amber-pale); color: var(--amber); }
.badge-cancelled      { background: var(--red-pale);   color: var(--red); }
.badge-no_show        { background: var(--red-pale);   color: var(--red); }
.badge-online_checkin { background: #ffedd5; color: #c2410c; }
.badge-checked_in     { background: #dbeafe; color: #1d4ed8; }
.badge-completed      { background: #f3f4f6; color: #374151; }

/* OTA */
.badge-airbnb  { background: #fff0f0; color: #FF5A5F; }
.badge-booking { background: #e8f0fc; color: #003580; }
.badge-expedia { background: #fff8e1; color: #d97706; }
.badge-vrbo    { background: #eef2fa; color: #195ABB; }
.badge-direct  { background: var(--green-pale); color: var(--green); }
.badge-other   { background: var(--bg-alt); color: var(--muted); }

/* Task status */
.badge-done        { background: var(--green-pale); color: var(--green); }
.badge-in_progress { background: #FFF7ED; color: #C2410C; }
.badge-skipped     { background: var(--bg-alt); color: var(--muted); }

/* Checkin status */
.badge-link_sent          { background: #EFF6FF; color: #1D4ED8; }
.badge-document_uploaded  { background: var(--amber-pale); color: var(--amber); }
.badge-verified           { background: var(--green-pale); color: var(--green); }
.badge-signed             { background: var(--green-pale); color: var(--green-h); }

/* ── FORMS ──────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.form-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--dark);
}
.form-label-optional {
  font-weight: var(--fw-regular);
  color: var(--muted);
  font-size: var(--text-xs);
  margin-left: var(--sp-2);
}
.form-hint {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: 2px;
}
.form-error {
  font-size: var(--text-xs);
  color: var(--red);
  margin-top: 2px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 9px var(--sp-3);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--dark);
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
  outline: none;
  -webkit-appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--subtle); font-weight: var(--fw-regular); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px var(--coral-pale);
}
.input.error { border-color: var(--red); }
.input.error:focus { box-shadow: 0 0 0 3px var(--red-pale); }
.input:disabled, .select:disabled { background: var(--bg-alt); color: var(--muted); cursor: not-allowed; }

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888480' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: var(--sp-8);
  cursor: pointer;
}

.textarea { resize: vertical; min-height: 96px; line-height: var(--leading-normal); }

/* Input con icona */
.input-wrap { position: relative; }
.input-wrap .input { padding-left: var(--sp-10); }
.input-wrap .input-icon {
  position: absolute;
  left: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: 16px;
}
.input-wrap .input-action {
  position: absolute;
  right: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  cursor: pointer;
  padding: 2px;
}
.input-wrap .input-action:hover { color: var(--text); }

/* Search */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-pill);
  padding: 0 var(--sp-3);
  transition: border-color var(--dur-fast);
}
.search-bar:focus-within { border-color: var(--coral); }
.search-bar input {
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font);
  font-size: var(--text-sm);
  color: var(--dark);
  padding: 8px 0;
  flex: 1;
}
.search-bar .search-icon { color: var(--muted); font-size: 16px; }

/* Checkbox / Radio */
.check-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  user-select: none;
}
.check-wrap input[type="checkbox"],
.check-wrap input[type="radio"] {
  width: 18px; height: 18px;
  accent-color: var(--coral);
  cursor: pointer;
}
.check-label { font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text); }

/* Toggle */
.toggle {
  position: relative;
  display: inline-flex;
  width: 40px; height: 22px;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: var(--r-pill);
  transition: background var(--dur-fast);
}
.toggle input:checked + .toggle-track { background: var(--coral); }
.toggle-thumb {
  position: absolute;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  top: 3px; left: 3px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast);
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(18px); }

/* ── TABLE ──────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--white);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th:first-child { border-radius: var(--r-lg) 0 0 0; }
.table th:last-child  { border-radius: 0 var(--r-lg) 0 0; }
.table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr {
  transition: background var(--dur-fast);
  cursor: pointer;
}
.table tbody tr:hover { background: var(--bg); }
.table-empty {
  text-align: center;
  padding: var(--sp-16) var(--sp-8);
  color: var(--muted);
  font-size: var(--text-sm);
}

/* ── AVATAR ─────────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--coral-pale);
  color: var(--coral);
  font-size: var(--text-sm);
  font-weight: var(--fw-black);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
}
.avatar-sm { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--text-md); }
.avatar-dark { background: var(--dark); color: var(--white); }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* ── CHECKLIST ITEM ─────────────────────────────────────────── */
.checklist-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--green);
  cursor: pointer;
  flex-shrink: 0;
}
.checklist-item-text {
  font-size: var(--text-sm);
  color: var(--text);
  flex: 1;
}
.checklist-item.done .checklist-item-text {
  text-decoration: line-through;
  color: var(--muted);
}

/* ── MODAL ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,23,20,.55);
  backdrop-filter: blur(2px);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  animation: fadeIn var(--dur-fast) var(--ease);
}
.modal {
  background: var(--white);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp var(--dur-base) var(--ease);
}
.modal-sm { max-width: 380px; }
.modal-lg { max-width: 720px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-6);
  border-bottom: 1px solid var(--border);
}
.modal-body { padding: var(--sp-6); }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  background: var(--bg);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.modal-close {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  font-size: 20px;
}
.modal-close:hover { background: var(--bg-alt); color: var(--dark); }

/* ── TOAST ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--dark);
  color: var(--white);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  min-width: 280px;
  max-width: 400px;
  animation: slideInRight var(--dur-base) var(--ease);
}
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--green); }
.toast.error   .toast-icon { color: var(--coral); }
.toast.warning .toast-icon { color: var(--amber); }
.toast-close {
  margin-left: auto;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  flex-shrink: 0;
}
.toast-close:hover { color: var(--white); }

/* ── DROPDOWN ───────────────────────────────────────────────── */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + var(--sp-2));
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: var(--z-dropdown);
  overflow: hidden;
  animation: fadeIn var(--dur-fast) var(--ease);
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
  cursor: pointer;
  transition: background var(--dur-fast);
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger:hover { background: var(--red-pale); }
.dropdown-divider { height: 1px; background: var(--border); margin: var(--sp-1) 0; }

/* ── TABS ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-alt);
  border-radius: var(--r-pill);
  padding: 3px;
}
.tab {
  flex: 1;
  padding: 7px var(--sp-4);
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--muted);
  border-radius: var(--r-pill);
  text-align: center;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  user-select: none;
}
.tab.active {
  background: var(--white);
  color: var(--dark);
  box-shadow: var(--shadow-sm);
}
.tab:not(.active):hover { color: var(--text); }

/* Tabs underline */
.tabs-underline {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
}
.tab-underline {
  padding: var(--sp-3) var(--sp-5);
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--dur-fast), border-color var(--dur-fast);
  white-space: nowrap;
}
.tab-underline.active { color: var(--coral); border-bottom-color: var(--coral); }
.tab-underline:not(.active):hover { color: var(--text); }

/* ── PROGRESS BAR ───────────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--bg-alt);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--coral);
  transition: width var(--dur-slow) var(--ease);
}
.progress-bar.green  { background: var(--green); }
.progress-bar.amber  { background: var(--amber); }

/* ── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-16) var(--sp-8);
  text-align: center;
}
.empty-state-icon { font-size: 48px; opacity: .4; }
.empty-state-title { font-size: var(--text-md); font-weight: var(--fw-bold); color: var(--dark); }
.empty-state-desc { font-size: var(--text-sm); color: var(--muted); max-width: 320px; line-height: var(--leading-loose); }

/* ── DIVIDER ────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── SKELETON LOADER ────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--border) 50%, var(--bg-alt) 75%);
  background-size: 200% 100%;
  border-radius: var(--r-md);
  animation: shimmer 1.5s infinite;
}
.skel-text  { height: 14px; margin-bottom: var(--sp-2); }
.skel-title { height: 20px; width: 60%; }
.skel-card  { height: 120px; border-radius: var(--r-lg); }

/* ── ANIMATIONS ─────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
