/*
 * AssoFacile Plugin – Stile base
 *
 * Il plugin usa CSS Custom Properties per adattarsi al tema del cliente.
 * I valori di default vengono sovrascritti dal pannello admin (via PHP inline style).
 *
 * Variabili disponibili per override nel tema / CSS personalizzato:
 *   --af-primary        Colore principale (bottoni, link, highlights)
 *   --af-primary-hover  Hover del colore principale
 *   --af-bg             Sfondo card e pannelli
 *   --af-bg-alt         Sfondo alternativo (righe zebrate, header tab)
 *   --af-text           Colore testo principale
 *   --af-text-muted     Testo secondario
 *   --af-border         Colore bordi
 *   --af-radius         Raggio bordi
 *   --af-shadow         Ombra card
 *   --af-font           Font family
 */

/* ---------------------------------------------------------------- Variabili default */
.af-block {
  --af-primary:       #007bff;
  --af-primary-hover: #0056b3;
  --af-bg:            #ffffff;
  --af-bg-alt:        #f8f9fa;
  --af-text:          #333333;
  --af-text-muted:    #6c757d;
  --af-border:        #dee2e6;
  --af-radius:        8px;
  --af-shadow:        0 2px 8px rgba(0,0,0,.08);
  --af-font:          inherit;  /* eredita dal tema */

  font-family: var(--af-font);
  color: var(--af-text);
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: inherit;
}

/* ---------------------------------------------------------------- Layout base */
.af-block {
  width: 100%;
  padding: 0;
}

/* ---------------------------------------------------------------- Loading */
.af-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
  color: var(--af-text-muted);
  font-size: .9rem;
}

.af-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--af-border);
  border-top-color: var(--af-primary);
  border-radius: 50%;
  animation: af-spin .7s linear infinite;
}

@keyframes af-spin {
  to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------- Errori */
.af-error {
  padding: 12px 16px;
  background: #fff3f3;
  border: 1px solid #f5c6cb;
  border-radius: var(--af-radius);
  color: #721c24;
  font-size: .9rem;
}

.af-error-inline {
  color: #dc3545;
  font-size: .85rem;
  margin-top: 4px;
}

/* ---------------------------------------------------------------- Card */
.af-card {
  background: var(--af-bg);
  border: 1px solid var(--af-border);
  border-radius: var(--af-radius);
  box-shadow: var(--af-shadow);
  padding: 24px;
  margin-bottom: 16px;
}

.af-card__title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--af-text);
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--af-border);
}

/* ---------------------------------------------------------------- Bottoni */
.af-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: .9rem;
  font-weight: 500;
  border-radius: var(--af-radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s, opacity .2s;
  line-height: 1;
}

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

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

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

.af-btn--outline {
  background: transparent;
  color: var(--af-primary);
  border: 1px solid var(--af-primary);
}

.af-btn--outline:hover:not(:disabled) {
  background: var(--af-primary);
  color: #fff;
}

.af-btn--sm {
  padding: 5px 12px;
  font-size: .8rem;
}

.af-btn--danger {
  background: #dc3545;
  color: #fff;
}

/* ---------------------------------------------------------------- Form */
.af-form-group {
  margin-bottom: 16px;
}

.af-label {
  display: block;
  margin-bottom: 5px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--af-text);
}

.af-input {
  width: 100%;
  padding: 9px 12px;
  font-size: .95rem;
  border: 1px solid var(--af-border);
  border-radius: var(--af-radius);
  background: var(--af-bg);
  color: var(--af-text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  font-family: var(--af-font);
}

.af-input:focus {
  border-color: var(--af-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--af-primary) 20%, transparent);
}

.af-input--error {
  border-color: #dc3545;
}

.af-textarea {
  min-height: 100px;
  resize: vertical;
}

/* ---------------------------------------------------------------- Tabs navigazione */
.af-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 2px solid var(--af-border);
  margin-bottom: 20px;
  padding: 0;
  list-style: none;
}

.af-tab {
  padding: 10px 16px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--af-text-muted);
  cursor: pointer;
  border-radius: var(--af-radius) var(--af-radius) 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -2px;
  background: transparent;
  transition: color .2s, background .2s;
}

.af-tab:hover {
  color: var(--af-primary);
  background: var(--af-bg-alt);
}

.af-tab--active {
  color: var(--af-primary);
  background: var(--af-bg);
  border-color: var(--af-border);
  border-bottom-color: var(--af-bg);
}

.af-tab-content {
  display: none;
}

.af-tab-content--active {
  display: block;
}

/* ---------------------------------------------------------------- Area riservata: Login */
.af-login {
  max-width: 420px;
  margin: 0 auto;
}

.af-login__logo {
  text-align: center;
  margin-bottom: 20px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--af-primary);
}

/* ---------------------------------------------------------------- Profilo */
.af-profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--af-border);
  cursor: pointer;
}

.af-profile-avatar:hover {
  border-color: var(--af-primary);
}

.af-profile-name {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 8px 0 4px;
}

.af-profile-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

@media (max-width: 480px) {
  .af-profile-fields { grid-template-columns: 1fr; }
}

.af-profile-field__label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--af-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 2px;
}

.af-profile-field__value {
  font-size: .95rem;
  color: var(--af-text);
}

/* ---------------------------------------------------------------- Quote / Ricevute */
.af-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.af-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  color: var(--af-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--af-bg-alt);
  border-bottom: 1px solid var(--af-border);
}

.af-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--af-border);
  color: var(--af-text);
}

.af-table tr:hover td {
  background: var(--af-bg-alt);
}

/* ---------------------------------------------------------------- Badge stato */
.af-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: .75rem;
  font-weight: 600;
  border-radius: 20px;
}

.af-badge--success {
  background: #d4edda;
  color: #155724;
}

.af-badge--warning {
  background: #fff3cd;
  color: #856404;
}

.af-badge--danger {
  background: #f8d7da;
  color: #721c24;
}

/* ---------------------------------------------------------------- Messaggistica */
.af-message-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.af-message-item {
  padding: 12px 16px;
  border: 1px solid var(--af-border);
  border-radius: var(--af-radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}

.af-message-item:hover {
  border-color: var(--af-primary);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--af-primary) 15%, transparent);
}

.af-message-item__subject {
  font-weight: 600;
  margin-bottom: 4px;
}

.af-message-item__meta {
  font-size: .8rem;
  color: var(--af-text-muted);
}

.af-message-thread {
  border: 1px solid var(--af-border);
  border-radius: var(--af-radius);
  overflow: hidden;
}

.af-message-bubble {
  padding: 12px 16px;
  border-bottom: 1px solid var(--af-border);
}

.af-message-bubble:last-child {
  border-bottom: none;
}

.af-message-bubble--mine {
  background: color-mix(in srgb, var(--af-primary) 8%, transparent);
}

/* ---------------------------------------------------------------- Calendario */
.af-calendar-wrapper {
  width: 100%;
}

/* Override minimal per EvoCalendar (se si usa) o calendario custom */
.af-event-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.af-event-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--af-border);
}

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

.af-event-date {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  background: var(--af-primary);
  color: #fff;
  border-radius: var(--af-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.2;
}

.af-event-date__day {
  font-size: 1.2rem;
}

.af-event-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.af-event-time {
  font-size: .8rem;
  color: var(--af-text-muted);
}

/* ---------------------------------------------------------------- Modal evento */
.af-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.af-modal-overlay--visible {
  opacity: 1;
  pointer-events: all;
}

.af-modal {
  background: var(--af-bg);
  border-radius: var(--af-radius);
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.af-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--af-border);
}

.af-modal__title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.af-modal__close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--af-text-muted);
  padding: 4px;
  line-height: 1;
}

.af-modal__close:hover {
  color: var(--af-text);
}

.af-modal__body {
  padding: 20px;
}

.af-modal__image {
  width: 100%;
  height: auto;
  border-radius: var(--af-radius);
  margin-bottom: 16px;
}

/* ---------------------------------------------------------------- Documenti */
.af-doc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.af-doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--af-border);
  gap: 12px;
}

.af-doc-item__name {
  font-weight: 500;
  flex: 1;
}

.af-doc-item__meta {
  font-size: .8rem;
  color: var(--af-text-muted);
}

/* ---------------------------------------------------------------- Registrazione wizard */

/* Gruppo di radio button (es: tipo iscrizione, tipo candidato) */
.af-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.af-radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--af-border);
  border-radius: var(--af-radius);
  cursor: pointer;
  font-size: .9rem;
  transition: border-color .2s, background .2s;
}

.af-radio-option:hover {
  border-color: var(--af-primary);
  background: var(--af-bg-alt);
}

.af-radio-option input[type="radio"] {
  accent-color: var(--af-primary);
  cursor: pointer;
}

.af-radio-option:has(input:checked) {
  border-color: var(--af-primary);
  background: color-mix(in srgb, var(--af-primary) 6%, transparent);
  font-weight: 500;
}

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 600px) {
  .af-card { padding: 16px; }
  .af-table { font-size: .8rem; }
  .af-table th, .af-table td { padding: 8px 6px; }
  .af-tabs { gap: 2px; }
  .af-tab { padding: 8px 10px; font-size: .8rem; }
}

/* ---------------------------------------------------------------- WebApp card mobile */

/* Su desktop nascosta — visibile solo su schermi mobile */
.af-webapp-card {
  display: none;
}

@media (max-width: 767px) {
  .af-webapp-card {
    display: block;
    background: var(--af-bg-alt, #fff);
    border: 1px solid var(--af-border);
    border-left: 4px solid var(--af-primary);
    border-radius: var(--af-radius);
    padding: 16px;
    margin-bottom: 16px;
  }
}

.af-wab__top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.af-wab__icon {
  font-size: 2rem;
  flex-shrink: 0;
  line-height: 1;
}

.af-wab__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.af-wab__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--af-text);
  line-height: 1.3;
}

.af-wab__sub {
  font-size: .82rem;
  color: var(--af-text-muted, #6b7a8d);
}

.af-wab__cta {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  margin-bottom: 12px;
}

.af-wab__instructions {
  border-top: 1px solid var(--af-border);
  padding-top: 10px;
}

.af-wab__instructions summary {
  cursor: pointer;
  font-size: .85rem;
  color: var(--af-primary);
  font-weight: 500;
  user-select: none;
  list-style: none;
  padding: 4px 0;
}
.af-wab__instructions summary::-webkit-details-marker { display: none; }
.af-wab__instructions summary::before { content: '\25B8  '; }
.af-wab__instructions[open] summary::before { content: '\25BE  '; }

.af-wab__steps {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.af-wab__steps-col {
  flex: 1;
  min-width: 140px;
  font-size: .82rem;
}

.af-wab__steps-col strong {
  display: block;
  margin-bottom: 6px;
  font-size: .85rem;
  color: var(--af-text);
}

.af-wab__steps-col ol {
  padding-left: 18px;
  margin: 0;
  line-height: 1.7;
  color: var(--af-text);
}
