/* ============================================
   BUTTONS
   ============================================ */

/* ============================================
   BUTTONS — con ripple e micro-interazioni (#13)
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  transition:
    background 200ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 150ms cubic-bezier(0.4, 0, 0.2, 1),
    opacity 150ms ease;
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
}

/* Ripple effect */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0);
  transition: background 400ms ease;
  pointer-events: none;
}

.btn:active::after {
  background: rgba(255, 255, 255, 0.18);
  transition: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 3px solid rgba(26, 95, 122, 0.4);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(26, 95, 122, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-light);
  box-shadow: 0 6px 18px rgba(26, 95, 122, 0.35);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 2px 6px rgba(26, 95, 122, 0.2);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
  box-shadow: none;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(26, 95, 122, 0.05);
  box-shadow: 0 4px 12px rgba(26, 95, 122, 0.15);
  transform: translateY(-1px);
}

.btn-secondary:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
}

.btn-accent {
  background: var(--color-accent);
  color: #fff;
}

.btn-accent:hover:not(:disabled) {
  opacity: 0.88;
}

.btn-whatsapp {
  background: #25D366;
  color: #fff;
  font-weight: var(--font-weight-semibold);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.btn-whatsapp:hover:not(:disabled) {
  background: #1ebe5d;
  box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
  transform: translateY(-1px);
}

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

.btn-ghost:hover:not(:disabled) {
  color: var(--color-text);
  background: var(--color-bg);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-full {
  width: 100%;
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--font-size-md);
}

.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
}

/* ============================================
   INPUTS
   ============================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.form-error {
  font-size: var(--font-size-xs);
  color: var(--color-danger);
  display: none;
}

.form-group.has-error .form-error {
  display: block;
}

.form-group.has-error .input {
  border-color: var(--color-danger);
}

.input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26, 95, 122, 0.15);
}

.input::placeholder {
  color: var(--color-text-muted);
}

/* Input con prefisso (€) */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: var(--space-4);
  color: var(--color-text-muted);
  font-weight: var(--font-weight-medium);
  pointer-events: none;
}

.input-prefix + .input {
  padding-left: var(--space-8);
}

/* Select dropdown */
.input-select {
  appearance: none;
  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='%23718096' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: 40px;
  cursor: pointer;
}

/* ============================================
   SLIDER
   ============================================ */

.slider-wrapper {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.slider-value {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
}

.slider-unit {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-left: var(--space-1);
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  outline: none;
  cursor: pointer;
}

.slider:focus-visible {
  outline: 3px solid rgba(26, 95, 122, 0.5);
  outline-offset: 4px;
  border-radius: var(--radius-full);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(26, 95, 122, 0.35);
  transition: transform var(--transition-fast);
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(26, 95, 122, 0.35);
}

/* ============================================
   CARDS
   ============================================ */

.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}

.card-elevated {
  box-shadow: var(--shadow-elevated);
}

.card-bordered {
  border: 2px solid var(--color-border);
  box-shadow: none;
}

.card-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}

.card-value {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  line-height: var(--line-height-tight);
}

.card-value-lg {
  font-size: var(--font-size-2xl);
}

.card-sub {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* Colori semantici card */
.card-success .card-value { color: var(--color-success); }
.card-warning .card-value { color: var(--color-warning); }
.card-danger  .card-value { color: var(--color-danger); }
.card-info    .card-value { color: var(--color-info); }

.card-success { border-left: 4px solid var(--color-success); }
.card-warning { border-left: 4px solid var(--color-warning); }
.card-danger  { border-left: 4px solid var(--color-danger); }
.card-info    { border-left: 4px solid var(--color-info); }

/* ============================================
   PROGRESS BAR
   ============================================ */

.progress-bar-track {
  width: 100%;
  height: 10px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  transition: width var(--transition-slow);
}

.progress-bar-fill.success { background: var(--color-success); }
.progress-bar-fill.warning { background: var(--color-warning); }
.progress-bar-fill.danger  { background: var(--color-danger); }

/* ============================================
   BADGE
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.03em;
}

.badge-success  { background: #d1fae5; color: #065f46; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-info     { background: #dbeafe; color: #1e40af; }
.badge-primary  { background: #e0f2fe; color: #0c4a6e; }
.badge-purple   { background: #ede9fe; color: #5b21b6; }

/* ============================================
   TOOLTIP
   ============================================ */

.tooltip-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tooltip-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-border);
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  margin-left: var(--space-1);
  flex-shrink: 0;
}

.tooltip-text {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: #fff;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-normal);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  max-width: 220px;
  white-space: normal;
  text-align: center;
  z-index: var(--z-tooltip);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  box-shadow: var(--shadow-elevated);
}

.tooltip-wrapper:hover .tooltip-text,
.tooltip-wrapper:focus-within .tooltip-text {
  opacity: 1;
}

.tooltip-icon:focus-visible {
  outline: 3px solid rgba(26, 95, 122, 0.5);
  outline-offset: 2px;
  border-radius: 50%;
}

/* ============================================
   DIVIDER
   ============================================ */

.divider {
  width: 100%;
  height: 1px;
  background: var(--color-border);
  margin: var(--space-6) 0;
}

/* ============================================
   TABLE
   ============================================ */

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr.highlight td {
  background: rgba(87, 197, 182, 0.08);
  font-weight: var(--font-weight-semibold);
}

.table .col-best {
  background: rgba(45, 155, 110, 0.06);
}
