/* ==========================================================================
   APP UI — pagina di ringraziamento, area studenti, pannello admin
   Riusa le variabili di design definite in css/style.css
   ========================================================================== */

:root {
  --app-navy: #1e3a8a;
  --app-navy-dark: #172554;
  --app-danger: #dc2626;
  --app-danger-bg: #fef2f2;
  --app-warning: #b45309;
  --app-warning-bg: #fffbeb;
  --app-info-bg: #eff6ff;
}

.app-body {
  background: var(--bg-secondary);
  font-family: var(--font-body);
  color: var(--text-dark);
  min-height: 100vh;
}

/* The panels below set an explicit `display`, which would otherwise beat the
   browser's own [hidden] rule and leave hidden elements visible. */
[hidden] { display: none !important; }

.app-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.app-shell--narrow { max-width: 620px; }

/* ---------- Card ---------- */

.app-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px;
}

.app-card + .app-card { margin-top: 20px; }
.app-card--center { text-align: center; }

.app-title {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 10px;
}

.app-lead {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 22px;
}

.app-section-title {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.app-section-sub {
  color: var(--text-light);
  font-size: 0.86rem;
  margin-bottom: 18px;
}

.app-help {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 18px;
}

.app-back { margin-top: 24px; font-size: 0.85rem; }
.app-back a, .app-help a { color: var(--app-navy); font-weight: 600; }

/* ---------- Pagina di ringraziamento ---------- */

.success-mark {
  width: 68px;
  height: 68px;
  margin: 0 auto 20px;
  border-radius: var(--radius-full);
  background: var(--success-bg);
  color: var(--success-color);
  font-size: 2rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.receipt {
  background: var(--bg-alt);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 24px;
  text-align: left;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.9rem;
  padding: 5px 0;
}

.receipt-row dt { color: var(--text-light); font-weight: 600; }
.receipt-row dd { font-weight: 700; word-break: break-all; }

.next-steps { text-align: left; margin-bottom: 26px; }

.next-steps h2 {
  font-family: var(--font-title);
  font-size: 1rem;
  margin-bottom: 12px;
}

.next-steps ol { padding-left: 20px; }

.next-steps li {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 10px;
}

/* ---------- Form ---------- */

.field { margin-bottom: 16px; text-align: left; }

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--bg-primary);
  color: var(--text-dark);
  transition: border-color var(--transition-fast);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--app-navy);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}

.field-hint { font-size: 0.76rem; color: var(--text-light); margin-top: 5px; }

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

/* ---------- Pulsanti ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter var(--transition-fast), background var(--transition-fast);
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:not(:disabled):hover { filter: brightness(0.94); }

.btn--primary { background: var(--app-navy); color: #fff; }
.btn--ghost { background: var(--bg-primary); color: var(--text-dark); border-color: var(--border-color); }
.btn--danger { background: var(--app-danger); color: #fff; }
.btn--full { width: 100%; }
.btn--sm { padding: 7px 12px; font-size: 0.8rem; }

/* ---------- Messaggi ---------- */

.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.87rem;
  line-height: 1.5;
  margin-bottom: 16px;
  text-align: left;
}

.alert--error { background: var(--app-danger-bg); color: var(--app-danger); }
.alert--success { background: var(--success-bg); color: var(--success-color); }
.alert--warning { background: var(--app-warning-bg); color: var(--app-warning); }
.alert--info { background: var(--app-info-bg); color: var(--app-navy); }
.alert a { color: inherit; font-weight: 700; }

.checkout-error {
  margin-top: 12px;
  color: var(--app-danger);
  background: var(--app-danger-bg);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

/* ---------- Intestazione app ---------- */

.app-header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.app-brand {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1rem;
  color: var(--app-navy);
  text-decoration: none;
}

.app-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.83rem;
  color: var(--text-light);
}

/* ---------- Griglia materiali ---------- */

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.asset-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.asset-badge {
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background: var(--bg-alt);
  color: var(--text-light);
}

.asset-badge--bonus { background: rgba(255, 220, 0, 0.22); color: var(--primary-shadow); }

.asset-card h3 { font-family: var(--font-title); font-size: 0.98rem; font-weight: 700; }
.asset-card p { font-size: 0.84rem; color: var(--text-muted); line-height: 1.5; flex: 1; }

.asset-card .btn { margin-top: 6px; }

.asset-unavailable {
  font-size: 0.8rem;
  color: var(--text-light);
  font-style: italic;
  margin-top: 6px;
}

/* ---------- Statistiche ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-light);
  font-weight: 700;
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--font-title);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.stat-sub { font-size: 0.76rem; color: var(--text-light); margin-top: 3px; }

/* ---------- Tabelle ---------- */

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 640px;
}

.data-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-light);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-secondary); }

.table-empty {
  text-align: center;
  color: var(--text-light);
  padding: 28px 12px;
  font-size: 0.87rem;
}

.pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
}

.pill--paid { background: var(--success-bg); color: var(--success-color); }
.pill--pending { background: var(--app-warning-bg); color: var(--app-warning); }
.pill--refunded { background: var(--app-danger-bg); color: var(--app-danger); }
.pill--neutral { background: var(--bg-alt); color: var(--text-light); }

/* ---------- Schede (tab) ---------- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 22px;
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 11px 16px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.tab-btn:hover { color: var(--text-dark); }
.tab-btn.active { color: var(--app-navy); border-bottom-color: var(--app-navy); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---------- Barra di ricerca / filtri ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.toolbar input,
.toolbar select {
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.86rem;
}

.toolbar input { flex: 1; min-width: 200px; }

/* ---------- Utilità ---------- */

.muted { color: var(--text-light); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.hidden { display: none !important; }

.copy-box {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 10px;
}

.copy-box input {
  flex: 1;
  border: none;
  background: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.copy-box input:focus { outline: none; }

@media (max-width: 640px) {
  .app-card { padding: 22px 18px; }
  .app-shell { padding: 20px 14px 48px; }
  .app-title { font-size: 1.45rem; }
}

/* ==========================================================================
   BOTTONE WHATSAPP - supporto nell'area studenti
   ========================================================================== */

.wa-support {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;

  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;

  background: #25d366;
  color: #ffffff;
  text-decoration: none;
  border-radius: var(--radius-full);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.35), 0 2px 6px rgba(0, 0, 0, 0.12);

  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.25;

  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.wa-support:hover,
.wa-support:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(37, 211, 102, 0.45), 0 3px 8px rgba(0, 0, 0, 0.16);
  color: #ffffff;
}

.wa-support:focus-visible {
  outline: 3px solid rgba(37, 211, 102, 0.45);
  outline-offset: 3px;
}

.wa-support:active { transform: translateY(0); }

.wa-support svg {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  fill: currentColor;
}

/* Su schermi stretti resta solo l'icona: il testo coprirebbe i contenuti. */
@media (max-width: 560px) {
  .wa-support {
    right: 14px;
    bottom: 14px;
    padding: 14px;
    gap: 0;
  }
  .wa-support .wa-support-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .wa-support { transition: none; }
  .wa-support:hover, .wa-support:focus-visible { transform: none; }
}
