/* ==========================================================================
   Beauty Tracker — Componenti UI
   ========================================================================== */

/* --- Bottoni --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: var(--touch-target-min);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  border: var(--border-width) solid transparent;
  font-weight: var(--font-weight-medium);
  transition: transform var(--transition-fast), background var(--transition-fast), opacity var(--transition-fast);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-ghost {
  background: transparent;
  color: var(--color-primary-dark);
}

.btn-danger {
  background: var(--color-negative-bg);
  color: var(--color-negative-text);
  border-color: var(--color-negative-border);
}

.btn-block { width: 100%; }

.btn-icon {
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  padding: 0;
  border-radius: var(--radius-full);
  background: transparent;
  border: none;
  color: var(--color-text);
}
.btn-icon:hover { background: var(--color-surface-alt); }

.fab {
  position: fixed;
  right: var(--space-lg);
  bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--space-lg));
  z-index: 25;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Card --- */
.card {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.stat-card {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
}
.stat-card .stat-value {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary-dark);
  display: block;
}
.stat-card .stat-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  text-align: center;
}
.quick-action .icon { width: 26px; height: 26px; color: var(--color-primary-dark); }

/* --- Product card --- */
.product-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  min-height: var(--touch-target-min);
}
.product-card .product-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}
.product-card .product-name {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-md);
}
.product-card .product-meta {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-sm);
}
.product-card .product-notes-preview {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.product-card .product-tags {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-top: var(--space-sm);
}
.tag {
  display: inline-flex;
  align-items: center;
  font-size: var(--font-size-xs);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
}

/* --- Badge "consigliato" --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  border: var(--border-width) solid;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.badge-si {
  background: var(--color-positive-bg);
  color: var(--color-positive-text);
  border-color: var(--color-positive-border);
}
.badge-cosi-cosi {
  background: var(--color-neutral-bg);
  color: var(--color-neutral-text);
  border-color: var(--color-neutral-border);
}
.badge-no {
  background: var(--color-negative-bg);
  color: var(--color-negative-text);
  border-color: var(--color-negative-border);
}
.badge-unset {
  background: var(--color-unset-bg);
  color: var(--color-unset-text);
  border-color: var(--color-unset-border);
}

.priority-badge {
  display: inline-flex;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
}
.priority-alta { background: var(--color-negative-bg); color: var(--color-negative-text); }
.priority-media { background: var(--color-neutral-bg); color: var(--color-neutral-text); }
.priority-bassa { background: var(--color-surface-alt); color: var(--color-text-muted); }

/* --- Form --- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}
.field label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
}
.field .required::after {
  content: " *";
  color: var(--color-error);
}
.field input[type="text"],
.field input[type="search"],
.field input[type="email"],
.field input[type="password"],
.field select,
.field textarea {
  min-height: var(--touch-target-min);
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
}
.field textarea {
  min-height: 90px;
  resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--color-primary);
}
.field-error {
  color: var(--color-error);
  font-size: var(--font-size-xs);
}
.field-hint {
  color: var(--color-text-faint);
  font-size: var(--font-size-xs);
}
.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--color-error);
}

.form-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-xl);
}
.form-actions .btn { flex: 1; }

/* --- Ricerca e filtri --- */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 0 var(--space-lg);
  min-height: var(--touch-target-min);
  margin-bottom: var(--space-md);
}
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  min-height: var(--touch-target-min);
}
.search-bar input:focus { outline: none; }
.search-bar .icon { color: var(--color-text-faint); }

.filter-chips {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
  margin-bottom: var(--space-md);
  -webkit-overflow-scrolling: touch;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  white-space: nowrap;
  flex-shrink: 0;
}
.chip.active {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
  font-weight: var(--font-weight-medium);
}

.results-count {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-md);
}

.filters-panel {
  background: var(--color-surface-alt);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}
.filters-panel .field { margin-bottom: var(--space-md); }
.filters-panel .field:last-child { margin-bottom: 0; }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(47, 42, 40, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}
.modal-overlay.centered {
  align-items: center;
  padding: var(--space-lg);
}
.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: var(--max-content-width);
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--space-xl) var(--space-lg) calc(var(--space-xl) + var(--safe-bottom));
  box-shadow: var(--shadow-lg);
}
.modal-overlay.centered .modal-box {
  border-radius: var(--radius-lg);
  max-height: 90vh;
}
.modal-title {
  margin-bottom: var(--space-md);
}
.modal-body {
  margin-bottom: var(--space-lg);
  color: var(--color-text-muted);
}
.modal-actions {
  display: flex;
  gap: var(--space-md);
}
.modal-actions .btn { flex: 1; }

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: calc(var(--safe-top) + var(--space-md));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: calc(100% - var(--space-xl));
  max-width: var(--max-content-width);
  align-items: center;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  max-width: 100%;
  animation: toast-in var(--transition-base);
}
.toast-success { background: var(--color-positive-bg); color: var(--color-positive-text); }
.toast-error { background: var(--color-negative-bg); color: var(--color-negative-text); }
.toast-info { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Loader --- */
.loader-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) var(--space-lg);
  color: var(--color-text-muted);
  gap: var(--space-md);
}
.spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Empty state --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
  color: var(--color-text-muted);
  gap: var(--space-md);
}
.empty-state .icon { width: 40px; height: 40px; color: var(--color-text-faint); }
.empty-state h3 { color: var(--color-text); }

/* --- Autocomplete --- */
.autocomplete-list {
  position: relative;
}
.autocomplete-list datalist { display: none; }

/* --- Detail rows --- */
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: var(--border-width) solid var(--color-border);
}
.detail-row:last-child { border-bottom: none; }
.detail-row .detail-label {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}
.detail-row .detail-value {
  font-weight: var(--font-weight-medium);
  text-align: right;
}
.detail-notes {
  white-space: pre-wrap;
  color: var(--color-text);
}

/* --- Auth screen --- */
.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-xl);
  background: var(--color-bg);
}
.auth-logo {
  text-align: center;
  margin-bottom: var(--space-2xl);
}
.auth-logo .icon {
  width: 44px;
  height: 44px;
  margin: 0 auto var(--space-md);
  color: var(--color-primary-dark);
}
.auth-card {
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
}
.auth-switch {
  text-align: center;
  margin-top: var(--space-lg);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}
.auth-switch button {
  background: none;
  border: none;
  color: var(--color-primary-dark);
  font-weight: var(--font-weight-medium);
  padding: var(--space-sm);
}
.auth-error {
  background: var(--color-negative-bg);
  color: var(--color-negative-text);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-md);
}

/* --- Swipe actions lista acquisti --- */
.shopping-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}
.shopping-item.completed {
  opacity: 0.6;
}
.shopping-item .check-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}
.shopping-item.completed .check-btn {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}
.shopping-item .shopping-content { flex: 1; min-width: 0; }
.shopping-item .shopping-title {
  font-weight: var(--font-weight-medium);
  text-decoration: none;
}
.shopping-item.completed .shopping-title {
  text-decoration: line-through;
  color: var(--color-text-muted);
}
.shopping-item .shopping-notes {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
}
.shopping-item .shopping-meta {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  align-items: center;
}

/* --- Danger zone --- */
.danger-zone {
  border: var(--border-width) solid var(--color-negative-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  background: var(--color-negative-bg);
}
.danger-zone h3 { color: var(--color-negative-text); margin-bottom: var(--space-sm); }

/* --- Install guide steps --- */
.steps-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}
.step-item {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
}
.step-number {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
}

.settings-list .settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) 0;
  border-bottom: var(--border-width) solid var(--color-border);
}
.settings-list .settings-row:last-child { border-bottom: none; }
.settings-list .settings-label { color: var(--color-text-muted); font-size: var(--font-size-sm); }
