/* ============================================================
   StayMastery HUB — Layout Shell
   Sidebar fissa sinistra + Topbar + Main scrollabile
   ============================================================ */

/* ── APP SHELL ──────────────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: width var(--dur-slow) var(--ease);
  overflow: hidden;
}

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5);
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
  min-height: var(--topbar-h);
  text-decoration: none;
}
.sidebar-logo-text {
  font-size: 18px;
  font-weight: var(--fw-black);
  color: var(--coral);
  letter-spacing: -.03em;
  white-space: nowrap;
}
.sidebar-logo-badge {
  font-size: 9px;
  font-weight: var(--fw-bold);
  letter-spacing: .15em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  margin-left: 2px;
  white-space: nowrap;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: var(--sp-3) var(--sp-3);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
  font-size: 9px;
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: rgba(255,255,255,.25);
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 9px var(--sp-3);
  border-radius: var(--r-md);
  color: rgba(255,255,255,.55);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur-fast), color var(--dur-fast);
  margin-bottom: 1px;
}
.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.85);
}
.nav-item.active {
  background: rgba(232,101,90,.15);
  color: var(--coral);
}
.nav-item.active .nav-icon { color: var(--coral); }

.nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: rgba(255,255,255,.4);
  transition: color var(--dur-fast);
}
.nav-item:hover .nav-icon { color: rgba(255,255,255,.7); }

.nav-badge {
  margin-left: auto;
  background: var(--coral);
  color: white;
  font-size: 10px;
  font-weight: var(--fw-black);
  min-width: 18px; height: 18px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}
.nav-badge.green { background: var(--green); }

/* Sidebar footer */
.sidebar-footer {
  padding: var(--sp-3);
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--dur-fast);
}
.sidebar-user:hover { background: rgba(255,255,255,.07); }
.sidebar-user-info {
  flex: 1;
  overflow: hidden;
  min-width: 0;
}
.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: rgba(255,255,255,.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: var(--text-xs);
  color: rgba(255,255,255,.35);
  white-space: nowrap;
}

/* ── MAIN AREA ──────────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left var(--dur-slow) var(--ease);
}

/* ── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: rgba(247,245,242,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
  z-index: var(--z-base);
  flex-shrink: 0;
}
.topbar-title {
  font-size: var(--text-md);
  font-weight: var(--fw-heavy);
  color: var(--dark);
  flex: 1;
  min-width: 0;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}
.topbar-date {
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── PAGE CONTENT ───────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: var(--sp-6);
  max-width: var(--content-max);
  width: 100%;
}
.page-content.full { max-width: 100%; }

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.page-header-left { display: flex; flex-direction: column; gap: var(--sp-1); }
.page-header-desc { font-size: var(--text-sm); color: var(--muted); margin-top: var(--sp-1); }
.page-actions { display: flex; align-items: center; gap: var(--sp-3); flex-shrink: 0; }

/* ── KPI GRID ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

/* ── CONTENT GRID ───────────────────────────────────────────── */
.content-grid {
  display: grid;
  gap: var(--sp-5);
}
.content-grid-2   { grid-template-columns: 1fr 1fr; }
.content-grid-3   { grid-template-columns: 1fr 1fr 1fr; }
.content-grid-sidebar { grid-template-columns: 1fr 320px; }
.content-grid-sidebar-lg { grid-template-columns: 1fr 400px; }

/* ── FILTERS BAR ────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px var(--sp-3);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast);
  white-space: nowrap;
}
.filter-chip:hover { border-color: var(--coral); color: var(--coral); }
.filter-chip.active {
  background: var(--coral-pale);
  border-color: var(--coral);
  color: var(--coral);
}
.filter-chip-close { font-size: 14px; opacity: .6; }
.filter-chip-close:hover { opacity: 1; }

/* ── PAGINATION ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-4) 0;
}
.page-btn {
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--dur-fast);
}
.page-btn:hover { background: var(--bg-alt); color: var(--text); }
.page-btn.active { background: var(--coral); color: white; }
.page-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ── CALENDAR GRID ──────────────────────────────────────────── */
/* ── CALENDARIO REDESIGN ──────────────────────────────────────── */
.cal-legend {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  background: var(--white);
  border-radius: 16px 16px 0 0;
  border-bottom: 1px solid var(--border);
}
.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: var(--fw-med);
  color: var(--muted);
}
.cal-legend-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.cal-container {
  overflow-x: auto;
  border-radius: 0 0 20px 20px;
  background: var(--white);
  box-shadow: 0 4px 24px rgba(15,23,42,.07);
}
.cal-header-row {
  display: flex;
  border-bottom: 1.5px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 10;
}
.cal-unit-label {
  width: 210px;
  flex-shrink: 0;
  padding: var(--sp-3) var(--sp-4);
  font-size: 10px;
  font-weight: var(--fw-black);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  border-right: 1.5px solid var(--border);
  background: var(--bg);
  position: sticky;
  left: 0;
  z-index: 1;
  box-shadow: 2px 0 6px rgba(0,0,0,.06);
}
.cal-day-header {
  flex: 1;
  min-width: 38px;
  border-right: 1px solid var(--border);
  padding: var(--sp-2) 0 var(--sp-1);
  text-align: center;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.cal-day-header .cal-dh-name {
  font-size: 9px;
  font-weight: var(--fw-med);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.cal-day-header .cal-dh-num {
  font-size: 13px;
  font-weight: var(--fw-black);
  color: var(--dark);
  line-height: 1;
}
.cal-day-header.weekend { background: #fafafa; }
.cal-day-header.today .cal-dh-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--coral);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-day-header.today .cal-dh-name { color: var(--coral); }

.cal-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  min-height: 62px;
  transition: background .1s;
}
.cal-row:hover { background: rgba(15,23,42,.012); }
.cal-row:last-child { border-bottom: none; }

.cal-unit-cell {
  width: 210px;
  flex-shrink: 0;
  padding: var(--sp-3) var(--sp-4);
  border-right: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  background: var(--bg);
  position: sticky;
  left: 0;
  z-index: 2;
  box-shadow: 2px 0 6px rgba(0,0,0,.06);
}
.cal-unit-name {
  font-size: var(--text-sm);
  font-weight: var(--fw-heavy);
  color: var(--dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-property-name {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-days-row {
  flex: 1;
  display: flex;
  position: relative;
}
.cal-day-cell {
  flex: 1;
  min-width: 38px;
  border-right: 1px solid var(--border);
  position: relative;
}
.cal-day-cell.weekend { background: #fafafa; }
.cal-day-cell.today { background: rgba(239,68,68,.04); }
/* Nessun border nelle celle corpo — solo header mostra le colonne */
.cal-day-cell { border-right: none; }
.cal-booking-block {
  position: absolute;
  top: 7px; bottom: 7px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  overflow: hidden;
  cursor: pointer;
  z-index: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,.12), inset 0 0 0 1.5px rgba(255,255,255,.35);
  transition: transform .15s, box-shadow .15s;
  min-width: 0;
}
.cal-booking-block:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
  z-index: 3;
}
.cal-ota-badge {
  width: 16px; height: 16px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255,255,255,.25);
  color: white;
  letter-spacing: 0;
}
.cal-booking-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  flex: 1;
}
.cal-booking-name {
  font-size: 11px;
  font-weight: var(--fw-heavy);
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.cal-booking-meta {
  font-size: 9px;
  font-weight: var(--fw-med);
  color: rgba(255,255,255,.8);
  white-space: nowrap;
  line-height: 1.2;
}

/* ── DOCUMENTO FISCALE MODAL ─────────────────────────────────── */
.fdoc-shell {
  background: var(--white);
  border-radius: 16px;
  width: 98vw;
  max-width: 1200px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,.22);
  overflow: hidden;
}
.fdoc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 3px solid var(--coral);
  flex-shrink: 0;
}
.fdoc-title { font-size: 15px; font-weight: var(--fw-heavy); color: var(--dark); }
.fdoc-body  { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 20px; }
.fdoc-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

/* Top 3 colonne */
.fdoc-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: flex-start;
}
.fdoc-col { display: flex; flex-direction: column; gap: 8px; }
.fdoc-section-title {
  font-size: 11px;
  font-weight: var(--fw-black);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.fdoc-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.fdoc-lbl {
  font-size: 12px;
  font-weight: var(--fw-heavy);
  color: var(--dark);
  white-space: nowrap;
  min-width: 108px;
  text-align: right;
  flex-shrink: 0;
}
/* legacy aliases (kept for safety) */
.fdoc-col-left, .fdoc-col-center { display: flex; flex-direction: column; gap: 8px; }
.fdoc-field-row { display: flex; align-items: center; gap: 8px; }
.fdoc-label { font-size: 12px; font-weight: var(--fw-heavy); color: var(--dark); white-space: nowrap; min-width: 110px; text-align: right; }
.fdoc-input-sm  { width: 100px; }
.fdoc-input-xs  { width: 70px; }
.fdoc-input-md  { flex: 1; min-width: 0; }

/* Pagamento immediato */
.fdoc-pay-box {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid var(--border);
}
.fdoc-pay-title { font-size: 13px; font-weight: var(--fw-heavy); color: var(--dark); margin-bottom: 12px; border-bottom: 2px solid #22c55e; padding-bottom: 6px; }

/* Righe documento */
.fdoc-lines-wrap { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.fdoc-lines-table { width: 100%; border-collapse: collapse; }
.fdoc-lines-table thead tr { background: var(--bg); }
.fdoc-lines-table th { padding: 8px 10px; font-size: 12px; font-weight: var(--fw-heavy); color: var(--muted); text-align: left; border-bottom: 1px solid var(--border); }
.fdoc-lines-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.fdoc-lines-table tr:last-child td { border-bottom: none; }
.fdoc-lines-table input { border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; font-size: 13px; width: 100%; background: var(--white); }
.fdoc-lines-table input:focus { outline: none; border-color: var(--coral); }

/* Totali */
.fdoc-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.fdoc-total-row {
  display: flex;
  gap: 16px;
  font-size: 13px;
  min-width: 300px;
  justify-content: space-between;
}
.fdoc-total-row span:last-child { font-weight: var(--fw-heavy); min-width: 80px; text-align: right; }
.fdoc-total-sospeso { font-size: 14px; font-weight: var(--fw-black); color: var(--coral); }

/* Sezione addebiti nel modal booking */
.fdoc-booking-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.fdoc-booking-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 13px;
}
.fdoc-booking-item-left { display: flex; flex-direction: column; gap: 2px; }
.fdoc-booking-item-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: var(--fw-heavy);
  background: rgba(239,68,68,.1);
  color: var(--coral);
}

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .kpi-grid             { grid-template-columns: repeat(2, 1fr); }
  .content-grid-sidebar { grid-template-columns: 1fr; }
  .content-grid-2       { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root {
    --sidebar-w: 0px;
  }
  .sidebar {
    transform: translateX(-100%);
    width: 240px;
  }
  .sidebar.open {
    transform: translateX(0);
    width: 240px;
  }
  .main            { margin-left: 0; }
  .kpi-grid        { grid-template-columns: 1fr 1fr; }
  .content-grid-3  { grid-template-columns: 1fr; }
  .page-content    { padding: var(--sp-4); }
  .page-header     { flex-direction: column; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-content { padding: var(--sp-3); }
  .topbar  { padding: 0 var(--sp-4); }
}

/* ── OVERLAY per sidebar mobile ─────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,23,20,.5);
  z-index: calc(var(--z-sidebar) - 1);
}
@media (max-width: 768px) {
  .sidebar-overlay.visible { display: block; }
}
