/* ============================================
   Casa della Rosa · Interior Design Portfolio
   ============================================ */

:root {
  --navy: #1a2744;
  --navy-light: #2a3f6a;
  --blue: #3d6b99;
  --blue-light: #6b9fd4;
  --rose: #c98a8a;
  --rose-light: #e8d3d3;
  --sand: #f5f0e8;
  --sand-dark: #e8dfd2;
  --cream: #faf8f4;
  --white: #ffffff;
  --text: #2c2c2c;
  --text-light: #6b6b6b;
  --text-muted: #999;
  --gold: #c4a265;
  --green: #5d8a5d;
  --green-light: #e3eee3;
  --amber: #d49a3a;
  --amber-light: #f5e8cf;
  --red: #b85454;
  --red-light: #f4dada;
  --border: #e7e2d8;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

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

html { -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text);
  background: var(--cream);
  line-height: 1.6;
  min-height: 100vh;
}

img { max-width: 100%; height: auto; display: block; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font: inherit; color: inherit; }

/* ---- Header ---- */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 28px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: 0.01em;
  line-height: 1;
}

.brand .tagline {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--rose);
  margin-top: 6px;
  font-weight: 500;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.year-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-light);
  font-weight: 500;
}

.year-selector select {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--cream);
  color: var(--navy);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-transform: none;
}

.year-selector select:focus {
  outline: 2px solid var(--blue-light);
  outline-offset: 2px;
}

/* ---- Sync status indicator ---- */
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-light);
  background: var(--sand);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.sync-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.sync-status.syncing { color: var(--amber); }
.sync-status.syncing::before { background: var(--amber); animation: syncPulse 1s ease-in-out infinite; }
.sync-status.synced { color: var(--green); background: var(--green-light); border-color: var(--green); }
.sync-status.synced::before { background: var(--green); }
.sync-status.offline { color: var(--text-muted); }
.sync-status.offline::before { background: var(--text-muted); }
.sync-status.error { color: var(--red); background: var(--red-light); border-color: var(--red-light); }
.sync-status.error::before { background: var(--red); }
@keyframes syncPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---- Tabs ---- */
.tabs {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 12px 22px;
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.tab-btn.active {
  color: var(--navy);
  border-bottom-color: var(--rose);
  font-weight: 600;
}

.badge {
  display: inline-flex;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: var(--rose);
  color: var(--white);
  font-size: 0.72rem;
  font-weight: 600;
  align-items: center;
  justify-content: center;
}

.tab-btn.active .badge { background: var(--navy); }

/* ---- Main / Tab panels ---- */
main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 28px 60px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.intro {
  margin-bottom: 28px;
  max-width: 760px;
}

.intro h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 10px;
}

.intro p {
  color: var(--text-light);
  font-size: 0.97rem;
}

.intro p + p { margin-top: 8px; }

/* ---- Rooms grid ---- */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 22px;
}

.room-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.25s, transform 0.25s;
}

.room-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.room-image {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--sand);
}

.room-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.room-count-pill {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(26, 39, 68, 0.85);
  color: var(--white);
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  backdrop-filter: blur(8px);
}

.room-body {
  padding: 20px 22px 22px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.room-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 4px;
}

.room-notes {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 14px;
  font-style: italic;
}

.room-progress {
  height: 4px;
  background: var(--sand);
  border-radius: 2px;
  margin-bottom: 16px;
  overflow: hidden;
}

.room-progress-fill {
  height: 100%;
  background: var(--rose);
  transition: width 0.3s ease;
  width: 0;
}

.item-list { list-style: none; }

.item-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--sand);
  font-size: 0.92rem;
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
}

.item-row:last-child { border-bottom: none; }

.item-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  margin-top: 2px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}

.item-row input[type="checkbox"]:hover { border-color: var(--rose); }

.item-row input[type="checkbox"]:checked {
  background: var(--rose);
  border-color: var(--rose);
}

.item-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.item-row.checked .item-label {
  color: var(--text-light);
  text-decoration: line-through;
  text-decoration-color: var(--rose-light);
}

.item-label { flex: 1; }

/* ---- Filters ---- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.filter-btn {
  padding: 7px 15px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--white);
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text-light);
  transition: all 0.15s;
}

.filter-btn:hover { border-color: var(--rose); color: var(--navy); }

.filter-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}

/* ---- Needed list ---- */
.needed-list {
  display: grid;
  gap: 16px;
}

.needed-group {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.needed-group-header {
  padding: 14px 20px;
  background: var(--sand);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.needed-group-header h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--navy);
}

.needed-group-count {
  font-size: 0.78rem;
  color: var(--text-light);
  font-weight: 500;
}

.needed-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--sand);
}

.needed-item:last-child { border-bottom: none; }

.needed-item-info { display: flex; flex-direction: column; gap: 2px; }

.needed-item-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.needed-item-room {
  font-size: 0.76rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.status-btn {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--white);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-light);
  white-space: nowrap;
  transition: all 0.15s;
}

.status-btn:hover { border-color: var(--text-light); }

.status-btn[data-status="have"].active {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green);
}

.status-btn[data-status="buy"].active {
  background: var(--amber-light);
  border-color: var(--amber);
  color: var(--amber);
}

.status-btn[data-status="rent"].active {
  background: var(--blue-light);
  border-color: var(--blue);
  color: var(--navy);
}

.status-btn.active { font-weight: 600; }

.needed-item-remove {
  padding: 6px 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}

.needed-item-remove:hover { color: var(--red); }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state p { margin-bottom: 6px; }

.link-btn {
  color: var(--rose);
  font-weight: 600;
  text-decoration: underline;
  padding: 0;
}

.link-btn:hover { color: var(--navy); }

/* ---- Summary ---- */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.summary-card {
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--white);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.summary-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
  margin-bottom: 8px;
}

.summary-num {
  display: block;
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 600;
  line-height: 1;
}

.summary-card.have { border-left: 3px solid var(--green); }
.summary-card.have .summary-num { color: var(--green); }
.summary-card.buy { border-left: 3px solid var(--amber); }
.summary-card.buy .summary-num { color: var(--amber); }
.summary-card.rent { border-left: 3px solid var(--blue); }
.summary-card.rent .summary-num { color: var(--blue); }
.summary-card.undecided { border-left: 3px solid var(--rose); }
.summary-card.undecided .summary-num { color: var(--rose); }

.summary-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.summary-breakdown { display: grid; gap: 18px; }

/* ---- Buttons ---- */
.btn-primary, .btn-ghost, .btn-danger {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--navy);
  color: var(--white);
}

.btn-primary:hover { background: var(--navy-light); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-ghost:hover { background: var(--sand); border-color: var(--rose); }

.btn-danger {
  background: transparent;
  border: 1px solid var(--red-light);
  color: var(--red);
}

.btn-danger:hover { background: var(--red-light); }

/* ---- Footer ---- */
.site-footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 30px 28px 40px;
  text-align: center;
  border-top: 1px solid var(--border);
  color: var(--text-light);
  font-size: 0.85rem;
}

.site-footer .muted { color: var(--text-muted); font-size: 0.78rem; margin-top: 4px; }

/* ---- Responsive ---- */
@media (max-width: 720px) {
  .header-inner { padding: 16px 20px 10px; }
  .brand h1 { font-size: 1.5rem; }
  .tabs { padding: 0 20px; gap: 2px; }
  .tab-btn { padding: 10px 14px; font-size: 0.82rem; }
  main { padding: 22px 18px 50px; }
  .rooms-grid { grid-template-columns: 1fr; gap: 18px; }
  .intro h2 { font-size: 1.6rem; }
  .summary-num { font-size: 2rem; }
  .needed-item { grid-template-columns: 1fr; }
  .header-controls { flex-wrap: wrap; }
}

@media print {
  .site-header, .summary-actions, .filters, .needed-item-remove, .site-footer { display: none; }
  .tab-panel { display: block !important; }
  .room-card, .needed-group { break-inside: avoid; }
  .modal { display: none !important; }
}

/* ---- Room image: zoom hint ---- */
.room-image { cursor: zoom-in; }
.room-image::after {
  content: "🔍 Ingrandisci";
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--navy);
  padding: 5px 11px;
  border-radius: 14px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s, transform 0.2s;
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.room-card:hover .room-image::after { opacity: 1; transform: translateY(0); }

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: stretch;
  justify-content: center;
}
.modal.open { display: flex; }
body.modal-open { overflow: hidden; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 40, 0.78);
  backdrop-filter: blur(4px);
  cursor: zoom-out;
}

.modal-content {
  position: relative;
  background: var(--cream);
  width: min(1400px, 100%);
  height: 100%;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  animation: modalRise 0.25s ease;
}

@keyframes modalRise {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
  gap: 16px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.1;
}

.modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-light);
  font-style: italic;
  margin-top: 2px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.modal-close {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--sand);
  color: var(--navy);
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--sand-dark); }

#modal-edit-toggle.active {
  background: var(--rose);
  color: var(--white);
  border-color: var(--rose);
}

.modal-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 0;
  overflow: hidden;
}

.modal-image-wrap {
  background: #1c1f2c;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 20px;
}

.modal-image-stage {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: inline-block;
  line-height: 0;
}

.modal-image-stage img {
  max-width: 100%;
  max-height: calc(100vh - 140px);
  width: auto;
  height: auto;
  display: block;
  border-radius: 6px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.4);
}

.modal-image-stage.edit-mode { cursor: crosshair; }
.modal-image-stage.edit-mode img { box-shadow: 0 0 0 3px var(--rose), 0 6px 30px rgba(0, 0, 0, 0.4); }

.markers-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.marker {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--rose);
  color: var(--white);
  border: 2px solid var(--white);
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s, background 0.15s;
}

.marker:hover, .marker.highlight {
  transform: translate(-50%, -50%) scale(1.25);
  background: var(--navy);
  z-index: 2;
}

.marker.checked { background: var(--blue); }
.marker.checked:hover, .marker.checked.highlight { background: var(--navy); }

.marker-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: var(--white);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.marker:hover .marker-tooltip, .marker.highlight .marker-tooltip { opacity: 1; }

.edit-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--rose);
  color: var(--white);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  animation: pulseHint 1.5s ease-in-out infinite;
}
@keyframes pulseHint {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.modal-sidebar {
  background: var(--white);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.edit-banner {
  padding: 12px 14px;
  background: var(--rose-light);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--navy);
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--rose);
}

.modal-item-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-item {
  display: grid;
  grid-template-columns: auto 22px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.92rem;
  line-height: 1.35;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}

.modal-item:hover { background: var(--sand); }
.modal-item.highlight { background: var(--rose-light); border-color: var(--rose); }
.modal-item.has-marker { font-weight: 500; }
.modal-item.editing { background: var(--rose-light); border-color: var(--rose); box-shadow: 0 0 0 1px var(--rose); }

.modal-item-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sand);
  color: var(--text-light);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-item.has-marker .modal-item-num {
  background: var(--rose);
  color: var(--white);
}
.modal-item.has-marker.is-checked .modal-item-num { background: var(--blue); }

.modal-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
.modal-item input[type="checkbox"]:checked {
  background: var(--rose);
  border-color: var(--rose);
}
.modal-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.modal-item-clear {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 3px 7px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.modal-item.has-marker:hover .modal-item-clear { opacity: 1; }
.modal-item-clear:hover { color: var(--red); background: var(--red-light); }

@media (max-width: 900px) {
  .modal-body { grid-template-columns: 1fr; grid-template-rows: minmax(280px, 50vh) 1fr; }
  .modal-sidebar { border-left: none; border-top: 1px solid var(--border); }
  .modal-image-stage img { max-height: 100%; }
  .modal-title { font-size: 1.3rem; }
  .modal-actions { flex-wrap: wrap; }
  #modal-edit-toggle { font-size: 0.78rem; padding: 8px 12px; }
}
