/* CasaRoma AI - Stili FASE 5: Checklist, Admin, Strumenti, Mappa */
/* Design premium mobile-first, dark mode WCAG AA */

/* ============ Checklist Page Layout ============ */
.checklist-page {
  padding: 12px;
  max-width: 800px;
  margin: 0 auto;
}

/* ============ CTA Banner (gradient) ============ */
.checklist-cta {
  position: relative;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #1565C0 0%, #0D47A1 50%, #1976D2 100%);
  color: #fff;
  overflow: hidden;
  margin-bottom: 20px;
}

.checklist-cta::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -10%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}

.checklist-cta::after {
  content: '';
  position: absolute;
  bottom: -20%;
  right: 15%;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
}

.checklist-cta__title {
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.4;
  position: relative;
  z-index: 1;
}

.checklist-cta__sub {
  font-size: 0.75rem;
  opacity: 0.85;
  margin-top: 4px;
  position: relative;
  z-index: 1;
}

[data-theme="dark"] .checklist-cta {
  background: linear-gradient(135deg, #1565C0 0%, #0D47A1 50%, #1A237E 100%);
}

/* ============ Checklist Header ============ */
.checklist-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding: 0 2px;
}

.checklist-header__info {
  flex: 1;
  min-width: 0;
}

.checklist-header__title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.3;
}

.checklist-header__subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.checklist-header__count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

/* ============ Progress Bar Globale ============ */
.checklist-progress {
  margin-bottom: 24px;
  padding: 0 2px;
}

.checklist-progress__bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.checklist-progress__fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(90deg, var(--success), #34D399);
  position: relative;
}

.checklist-progress__fill.low {
  background: linear-gradient(90deg, var(--error), #F87171);
}

.checklist-progress__fill.mid {
  background: linear-gradient(90deg, var(--accent), #FFA040);
}

/* ============ Checklist Category Accordion ============ */
.checklist-category {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-normal);
}

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

.checklist-category__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  background: var(--bg-card);
  transition: background var(--t-fast);
  user-select: none;
  border-left: 3px solid var(--primary);
}

.checklist-category__header:active {
  background: var(--primary-bg);
}

.checklist-category__header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.checklist-category__icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.checklist-category__name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.checklist-category__count {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.checklist-category__progress-mini {
  width: 52px;
  flex-shrink: 0;
}

.checklist-category__chevron {
  flex-shrink: 0;
  transition: transform var(--t-normal);
  color: var(--text-tertiary);
}

.checklist-category.open .checklist-category__chevron {
  transform: rotate(90deg);
}

.checklist-category__body {
  display: none;
  padding: 4px 12px 12px;
}

.checklist-category.open .checklist-category__body {
  display: block;
}

/* ============ Checklist Item ============ */
.checklist-item {
  padding: 14px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  background: var(--bg);
  transition: background var(--t-fast), box-shadow var(--t-fast);
  border: 1px solid transparent;
}

.checklist-item:last-of-type {
  margin-bottom: 0;
}

.checklist-item:hover {
  border-color: var(--border);
}

.checklist-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}

.checklist-item__name {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.checklist-item__name-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checklist-item__required {
  font-size: 0.625rem;
  font-weight: 800;
  color: var(--error);
  flex-shrink: 0;
}

.checklist-item__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.checklist-item__action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}

.checklist-item__action-btn:hover {
  background: var(--primary-bg);
}

.checklist-item__action-btn:active {
  transform: scale(0.92);
}

.checklist-item__desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.5;
}

/* ============ Status Badge (semafori) — redesign premium ============ */
.checklist-statuses {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--t-fast);
  background: var(--bg-card);
  color: var(--text-secondary);
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

.status-badge:active {
  transform: scale(0.94);
}

/* Dot indicatore dentro il badge */
.status-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all var(--t-fast);
}

.status-badge.non_iniziato { border-color: color-mix(in srgb, var(--error) 30%, transparent); }
.status-badge.non_iniziato::before { background: var(--error); }
.status-badge.non_iniziato.active {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error);
  font-weight: 700;
}

.status-badge.in_lavorazione { border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.status-badge.in_lavorazione::before { background: var(--accent); }
.status-badge.in_lavorazione.active {
  background: var(--warning-bg);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.status-badge.disponibile { border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.status-badge.disponibile::before { background: var(--success); }
.status-badge.disponibile.active {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success);
  font-weight: 700;
}

.status-badge.non_applicabile { border-color: color-mix(in srgb, var(--text-tertiary) 30%, transparent); }
.status-badge.non_applicabile::before { background: var(--text-tertiary); }
.status-badge.non_applicabile.active {
  background: var(--bg);
  color: var(--text-tertiary);
  border-color: var(--text-tertiary);
  font-weight: 700;
}

/* ============ Visibility toggle moderno ============ */
.checklist-visibility {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 0.6875rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
}

.checklist-visibility:has(input:checked) {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary);
}

.checklist-visibility input {
  display: none;
}

/* ============ Status Dot (buyer view) ============ */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border);
}

.status-dot.disponibile { background: var(--success); }
.status-dot.in_lavorazione { background: var(--accent); }
.status-dot.non_iniziato { background: var(--error); }
.status-dot.non_applicabile { background: var(--text-tertiary); }

/* ============ Notes textarea moderno ============ */
.checklist-notes {
  margin-top: 10px;
}

.checklist-notes textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.8125rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  font-family: var(--font);
}

.checklist-notes textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.checklist-notes textarea::placeholder {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

/* ============ Item footer (timestamp + azioni inline) ============ */
.checklist-item__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.checklist-item__timestamp {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============ File Upload Zone ============ */
.file-upload-zone {
  margin-top: 10px;
}

.file-upload-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  transition: border-color var(--t-fast);
}

.file-upload-item:hover {
  border-color: var(--primary);
}

.file-upload-item__info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.file-upload-item__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-upload-item__icon.pdf {
  background: var(--error-bg);
}

.file-upload-item__icon.img {
  background: var(--primary-bg);
}

.file-upload-item__icon.doc {
  background: var(--info-bg);
}

.file-upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--t-fast);
  margin-top: 6px;
  background: var(--bg-card);
}

.file-upload-dropzone:hover,
.file-upload-dropzone.drag-active {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.file-upload-dropzone:active {
  transform: scale(0.99);
}

.file-upload-dropzone__text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
}

.file-upload-dropzone__hint {
  font-size: 0.625rem;
  color: var(--text-tertiary);
}

/* ============ Add item/category buttons ============ */
.checklist-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}

.checklist-add-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}

.checklist-add-btn:active {
  transform: scale(0.98);
}

.checklist-add-btn--sm {
  padding: 10px;
  font-size: 0.75rem;
  border-width: 1.5px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

/* ============ Footer Azioni ============ */
.checklist-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 24px;
}

.checklist-footer .btn {
  font-size: 0.8125rem;
  padding: 12px 14px;
  border-radius: var(--radius);
  justify-content: center;
}

.checklist-footer .btn svg {
  width: 16px;
  height: 16px;
}

/* Autosave feedback */
.checklist-autosave {
  text-align: center;
  padding: 8px 0;
  font-size: 0.6875rem;
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* ============ Admin Table ============ */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.admin-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg);
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
}

.admin-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: var(--primary-bg);
}

/* ============ Strumenti Hero ============ */
.strumenti-hero {
  text-align: center;
  padding: 24px 16px;
}

.strumenti-hero h2 {
  font-size: 1.375rem;
  line-height: 1.3;
  color: var(--text);
}

/* ============ Calculator Card ============ */
.calculator-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
}

/* ============ Myth Accordion ============ */
.myth-accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.myth-accordion__header {
  display: flex;
  align-items: center;
  padding: 12px;
  cursor: pointer;
  background: var(--bg-card);
  transition: background var(--t-fast);
}

.myth-accordion__header:hover {
  background: var(--primary-bg);
}

.myth-accordion__header svg:last-child {
  transition: transform var(--t-fast);
  flex-shrink: 0;
}

.myth-accordion.open .myth-accordion__header svg:last-child {
  transform: rotate(90deg);
}

.myth-accordion__body {
  display: none;
  padding: 0 12px 12px;
}

.myth-accordion.open .myth-accordion__body {
  display: block;
}

/* ============ Map Price Marker ============ */
.map-price-marker {
  background: transparent !important;
  border: none !important;
}

/* ============ Progress Bar (inline) ============ */
.progress-bar {
  width: 100%;
  border-radius: 4px;
  overflow: hidden;
}

/* ============ Dark Mode WCAG AA ============ */
[data-theme="dark"] .checklist-category {
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

[data-theme="dark"] .checklist-category__header {
  background: var(--bg-card);
}

[data-theme="dark"] .checklist-item {
  background: var(--bg-card);
  border-color: var(--border);
}

[data-theme="dark"] .status-badge {
  background: var(--bg);
}

[data-theme="dark"] .file-upload-item {
  background: var(--bg);
  border-color: var(--border);
}

[data-theme="dark"] .file-upload-dropzone {
  border-color: var(--border);
  background: var(--bg);
}

[data-theme="dark"] .file-upload-dropzone:hover,
[data-theme="dark"] .file-upload-dropzone.drag-active {
  border-color: var(--primary);
  background: var(--primary-bg);
}

[data-theme="dark"] .checklist-notes textarea {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .checklist-add-btn {
  border-color: var(--border);
  color: var(--text-secondary);
}

[data-theme="dark"] .checklist-add-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}

[data-theme="dark"] .admin-table th {
  background: var(--bg);
  color: var(--text-secondary);
}

[data-theme="dark"] .admin-table tr:hover td {
  background: var(--primary-bg);
}

[data-theme="dark"] .calculator-card {
  background: var(--bg-card);
  border-color: var(--border);
}

[data-theme="dark"] .strumenti-hero h2 {
  color: var(--text);
}

[data-theme="dark"] .myth-accordion__header {
  background: var(--bg-card);
}

[data-theme="dark"] .checklist-visibility {
  background: var(--bg);
  border-color: var(--border);
}

/* ============ Responsive ============ */

/* Mobile small (< 375px) */
@media (max-width: 374px) {
  .checklist-statuses {
    gap: 4px;
  }

  .status-badge {
    padding: 5px 8px;
    font-size: 0.625rem;
  }

  .checklist-footer {
    grid-template-columns: 1fr;
  }
}

/* Tablet */
@media (min-width: 768px) {
  .checklist-page {
    padding: 20px;
  }

  .checklist-cta {
    padding: 20px 24px;
  }

  .checklist-cta__title {
    font-size: 1.0625rem;
  }

  .checklist-header__title {
    font-size: 1.375rem;
  }

  .checklist-category__header {
    padding: 16px 20px;
  }

  .checklist-item {
    padding: 16px 14px;
  }

  .status-badge {
    padding: 7px 14px;
    font-size: 0.75rem;
  }

  .checklist-footer {
    grid-template-columns: repeat(4, 1fr);
  }

  .strumenti-hero h2 {
    font-size: 1.75rem;
  }

  .admin-table {
    font-size: 0.875rem;
  }

  .calculator-card {
    padding: 28px;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .checklist-page {
    padding: 24px;
  }

  .strumenti-hero h2 {
    font-size: 2rem;
    max-width: 600px;
    margin: 0 auto;
  }

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

  .checklist-item:hover {
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    border-color: var(--border);
  }
}
