@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* ============================================================
   VARIABILI
   ============================================================ */
:root {
  --bg:          #f5f6f8;
  --surface:     #ffffff;
  --border:      #e4e7ec;
  --border-soft: #f0f2f5;

  --text:        #101828;
  --text-sec:    #475467;
  --text-muted:  #98a2b3;

  --primary:       #1e40af;
  --primary-mid:   #2563eb;
  --primary-light: #eff4ff;
  --primary-hover: #1d3fa0;

  --success:       #12b76a;
  --success-light: #ecfdf3;
  --danger:        #f04438;
  --danger-light:  #fef3f2;
  --info-light:    #eff8ff;
  --info-border:   #b9d9ff;
  --info-text:     #1e4fad;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;

  --shadow:    0 2px 8px rgba(16,24,40,0.08);
  --shadow-lg: 0 8px 24px rgba(16,24,40,0.1);

  --font: 'Plus Jakarta Sans', -apple-system, sans-serif;
}

/* ============================================================
   RESET BASE — mobile first
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary-mid); text-decoration: none; }

/* ============================================================
   HEADER — mobile first
   ============================================================ */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  height: 56px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 1px 3px rgba(16,24,40,0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  min-width: 0;
}

.header-logo {
  width: 175px;
  height: auto;
  flex-shrink: 0;
  object-fit: contain;
}

.header-name {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}


.header-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

/* Colonna centrale — navigazione */
.header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.header-nav-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sec);
  padding: 0.35rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 6px;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.header-nav-link:hover {
  color: var(--primary-mid);
  background: var(--primary-light);
  border-color: var(--primary-mid);
}

.header-nav-esci {
  color: var(--text-muted);
}

.header-nav-esci:hover {
  color: var(--danger);
  background: var(--danger-light);
  border-color: #fecdc9;
}

.header-nav-accedi {
  color: var(--primary-mid);
  border-color: var(--primary-mid);
  background: var(--primary-light);
}

.header-nav-accedi:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Colonna destra — nominativo */
.header-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}

.header-user-badge {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-sec);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

@media (max-width: 600px) {
  .header-name { display: none; }
  .header-user-badge { display: none; }
  .header-nav-link { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
}

@media (min-width: 480px) {
  .header { padding: 0 1.75rem; height: 60px; }
  .header-logo { width: 175px; height: auto; }
}

/* ============================================================
   WRAPPER PAGINA
   ============================================================ */
.page-wrap {
  flex: 1;
  padding: 1.5rem 1rem 4rem;
  width: 100%;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.box {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.box-wide {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
}

@media (min-width: 640px) {
  .page-wrap { padding: 2rem 1.5rem 5rem; }
}

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-top  { padding: 1.5rem 1.5rem 0; }
.card-body { padding: 1.5rem; }

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
  line-height: 1.3;
}

.card-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.annuncio-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #c7d7fd;
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.annuncio-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ============================================================
   FORM
   ============================================================ */
.form-group { margin-bottom: 1.1rem; }

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sec);
  margin-bottom: 0.45rem;
}

.form-required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;        /* 1rem evita zoom su iOS */
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-mid);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

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

.form-hint {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================================
   UPLOAD FILE — pulsante semplice
   ============================================================ */
.file-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 52px;
}

.file-field:focus-within {
  border-color: var(--primary-mid);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.file-field input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-btn {
  flex-shrink: 0;
  background: var(--bg);
  border-right: 1.5px solid var(--border);
  padding: 0 1rem;
  height: 50px;
  display: flex;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-sec);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.file-btn:hover {
  background: var(--primary-light);
  color: var(--primary-mid);
}

.file-name {
  flex: 1;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name.selected {
  color: var(--success);
  font-weight: 500;
}

/* ============================================================
   PULSANTI
   ============================================================ */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.85rem 1.25rem;   /* target touch generoso */
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(30,64,175,0.25);
}

.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 3px 10px rgba(30,64,175,0.3);
}

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

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

.btn-secondary:hover, .btn-secondary:focus {
  background: var(--bg);
  border-color: var(--text-muted);
  color: var(--text);
}

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

/* ============================================================
   ALERT
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
}

.alert-error   { background: var(--danger-light); border-color: #fecdc9; color: #b42318; }
.alert-success { background: var(--success-light); border-color: #a9efc5; color: #027a48; }
.alert-info    { background: var(--info-light); border-color: var(--info-border); color: var(--info-text); }

.alert::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  margin-top: 0.5rem;
}

/* ============================================================
   LISTA ANNUNCI — pagina pubblica
   ============================================================ */
.offers-header {
  margin-bottom: 1.5rem;
}

.offers-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.offers-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.offers-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .offers-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

.offer-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  transition: all 0.15s;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}

.offer-card:hover, .offer-card:focus {
  border-color: var(--primary-mid);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1), var(--shadow);
  transform: translateY(-1px);
}

.offer-card:active { transform: scale(0.99); }

.offer-card-expired {
  background: var(--surface);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.offer-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.offer-ref {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary-mid);
  background: var(--primary-light);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
}

.offer-card-expired .offer-ref {
  color: var(--text-muted);
  background: var(--border-soft);
}

.offer-meta {
  text-align: right;
  flex-shrink: 0;
}

.offer-meta-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: block;
}

.offer-meta-date {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.offer-card-expired .offer-meta-date { color: var(--text-muted); }

.offer-desc {
  font-size: 0.875rem;
  color: var(--text-sec);
  line-height: 1.55;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.offer-card-expired .offer-desc { color: var(--text-muted); }

.offer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 0.75rem;
}

.badge-open {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--success-light);
  color: #027a48;
  border-radius: 20px;
  padding: 0.18rem 0.6rem;
}

.badge-open::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-expired {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
}

.offer-arrow {
  font-size: 1rem;
  color: var(--primary-mid);
}

.btn-dettagli {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 20px;
  padding: 0.18rem 0.65rem;
  text-decoration: none;
  white-space: nowrap;
}
.btn-dettagli:hover {
  background: var(--primary);
  color: #fff;
}

/* ============================================================
   FOOTER PAGINA PUBBLICA
   ============================================================ */
.page-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.page-footer a { color: var(--text-muted); text-decoration: underline; }
.page-footer a:hover { color: var(--primary-mid); }

/* ============================================================
   CONFERMA INVIO
   ============================================================ */
.success-wrap {
  text-align: center;
  padding: 2rem 1.5rem;
}

.success-icon {
  width: 60px;
  height: 60px;
  background: var(--success-light);
  border: 2px solid #a9efc5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  font-size: 1.6rem;
  color: var(--success);
}

.success-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.success-msg {
  font-size: 0.9rem;
  color: var(--text-sec);
  line-height: 1.7;
  max-width: 320px;
  margin: 0 auto;
}

/* ============================================================
   DIVIDER
   ============================================================ */
.divider {
  height: 1px;
  background: var(--border-soft);
  margin: 1.25rem 0;
}

/* ============================================================
   DESCRIZIONE ANNUNCIO
   ============================================================ */
.annuncio-desc {
  font-size: 0.9rem;
  color: var(--text-sec);
  line-height: 1.8;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  margin-bottom: 1.25rem;
}

/* ============================================================
   DESKTOP ENHANCEMENTS
   ============================================================ */
@media (min-width: 640px) {
  .card-title { font-size: 1.25rem; }
  .btn { font-size: 0.9rem; padding: 0.75rem 1.25rem; }
  .offers-title { font-size: 1.5rem; }
  .box, .box-wide { padding: 0; }
}

/* ============================================================
   DASHBOARD STUDENTE
   ============================================================ */
.dash-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.dash-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}

.dash-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.dash-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dash-badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 20px;
  padding: 0.2rem 0.65rem;
  white-space: nowrap;
}

.badge-valutazione {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-selezionato {
  background: var(--success-light);
  color: #027a48;
  border: 1px solid #a9efc5;
}

.badge-rifiutato {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Spinner caricamento login */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

#login-loading {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1.2rem;
  color: #888;
  font-size: 0.95rem;
}

.spinner {
  display: inline-block;
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid rgba(0,0,0,0.15);
  border-top-color: var(--primary, #1a6fc4);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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