* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #22263a;
  --border: #2a2e3f;
  --text: #e4e6ef;
  --text-secondary: #a8acbf;
  --text-muted: #8b8fa3;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --red: #e05555;
  --orange: #e89b3a;
  --green: #45b358;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ========== HEADER ========== */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.2rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }
header h1 span { color: var(--accent-light); }

.main-nav { display: flex; gap: 0.3rem; }
.nav-link {
  color: var(--text-muted); text-decoration: none;
  font-size: 0.8rem; padding: 0.35rem 0.8rem;
  border-radius: 6px; transition: all 0.2s;
}
.nav-link:hover { color: var(--text); background: var(--surface-hover); }
.nav-link.active { color: #fff; background: var(--accent); }

.header-info { font-size: 0.8rem; color: var(--text-muted); }

/* ========== CONTAINER ========== */
.container { max-width: 900px; margin: 0 auto; padding: 1.5rem; }

/* ========== HOME ========== */
.hero {
  text-align: center; padding: 3.5rem 1rem 2.5rem;
}
.hero h2 {
  font-size: 2.6rem; font-weight: 700; margin-bottom: 0.6rem;
  letter-spacing: -0.03em;
}
.hero h2 span { color: var(--accent-light); }
.hero p {
  color: var(--text-secondary); font-size: 1rem; line-height: 1.7;
  max-width: 600px; margin: 0 auto;
}

.apps-grid {
  display: flex; flex-direction: column; gap: 0.75rem;
  max-width: 600px; margin: 0 auto;
}
.app-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.3rem 1.5rem;
  display: flex; align-items: center; gap: 1.2rem;
  text-decoration: none; color: inherit;
  transition: all 0.2s; cursor: pointer;
}
.app-card:hover {
  background: var(--surface-hover); border-color: var(--accent);
  transform: translateY(-1px);
}
.app-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.app-icon svg { width: 26px; height: 26px; }
.app-info { flex: 1; }
.app-info h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.25rem; }
.app-info p { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5; }
.app-arrow {
  font-size: 1.2rem; color: var(--text-muted);
  transition: color 0.2s; flex-shrink: 0;
}
.app-card:hover .app-arrow { color: var(--accent-light); }

/* ========== CTA BUTTON (home) ========== */
.cta-btn {
  display: inline-block;
  padding: 0.8rem 2rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  transition: opacity 0.2s;
}
.cta-btn:hover { opacity: 0.85; }

/* ========== SELETTORE DATE ========== */
.date-selector {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.date-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s;
}

.date-btn:hover { border-color: var(--accent); color: var(--text); }
.date-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ========== FILTRI CATEGORIA ========== */
.filters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1.2rem; }

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ========== LISTA PILLOLE (card) ========== */
.pills-list { display: flex; flex-direction: column; gap: 0.75rem; }

.pill-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.2rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.pill-card:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.pill-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; }

.pill-category {
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 0.2rem 0.6rem; border-radius: 4px;
  background: var(--accent); color: #fff; white-space: nowrap;
}
.pill-category[data-cat="Cronaca"] { background: var(--red); }
.pill-category[data-cat="Sport"] { background: #27a854; }
.pill-category[data-cat="Politica"] { background: #2e86c1; }
.pill-category[data-cat="Cultura"] { background: #8e44ad; }
.pill-category[data-cat="Economia"] { background: var(--orange); }
.pill-category[data-cat="Ambiente"] { background: #17a589; }

.pill-relevance { font-size: 0.65rem; color: var(--text-muted); margin-left: auto; }
.pill-relevance[data-rel="alta"] { color: var(--green); }
.pill-relevance[data-rel="media"] { color: var(--orange); }

.pill-title { font-size: 1.05rem; font-weight: 600; line-height: 1.4; margin-bottom: 0.5rem; }
.pill-summary { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.6; }

.pill-meta {
  display: flex; gap: 1rem; margin-top: 0.8rem;
  font-size: 0.75rem; color: var(--text-muted);
  align-items: center;
}

.pill-sources {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}
.pill-sources-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pill-source-link {
  font-size: 0.7rem;
  color: var(--accent-light);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
}
.pill-source-link:hover { color: #fff; }

/* ========== DETAIL VIEW ========== */
.back-btn {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  padding: 0.5rem 1rem; border-radius: 8px; cursor: pointer;
  font-size: 0.8rem; margin-bottom: 1.5rem; transition: all 0.2s;
  text-decoration: none; display: inline-block;
}
.back-btn:hover { border-color: var(--accent); color: var(--text); }

.detail-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 2rem;
}
.detail-card .pill-title { font-size: 1.4rem; margin-bottom: 1rem; }
.detail-card .pill-summary { font-size: 1rem; color: var(--text-secondary); line-height: 1.8; }

.sources-section {
  margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
}
.sources-section h3 {
  font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.8rem;
}

.source-link {
  display: block; color: var(--accent-light); text-decoration: none;
  font-size: 0.8rem; padding: 0.4rem 0; transition: color 0.2s;
}
.source-link:hover { color: #fff; }
.source-domain { color: var(--text-muted); font-size: 0.75rem; display: block; }

/* ========== SHARE LINKS ========== */
.share-links {
  display: flex; align-items: center; gap: 0.6rem;
  margin-top: 1.5rem; padding-top: 1.2rem; border-top: 1px solid var(--border);
}
.share-links span {
  font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.05em;
}
.share-links a {
  color: var(--text-muted); transition: color 0.2s;
  display: flex; align-items: center;
}
.share-links a:hover { color: var(--accent-light); }
.share-links svg { width: 16px; height: 16px; }

/* ========== AUDIO BUTTON (lista) ========== */
.audio-btn {
  background: none; border: 1px solid var(--accent); color: var(--accent-light);
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; margin-left: auto; transition: all 0.2s; flex-shrink: 0;
}
.audio-btn:hover { background: var(--accent); color: #fff; }
.audio-btn.playing { background: var(--accent); color: #fff; }
.audio-btn svg { width: 16px; height: 16px; }

/* ========== AUDIO PLAYER (dettaglio) ========== */
.audio-player {
  display: flex; align-items: center; gap: 0.8rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.6rem 1rem; margin-bottom: 1.2rem;
}
.audio-player-btn {
  background: var(--accent); border: none; color: #fff;
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; flex-shrink: 0; transition: opacity 0.2s;
}
.audio-player-btn:hover { opacity: 0.85; }
.audio-player-btn.playing { background: var(--accent-light); }
.audio-player-btn svg { width: 18px; height: 18px; }

.audio-progress {
  flex: 1; height: 4px; background: var(--border);
  border-radius: 2px; cursor: pointer; position: relative;
}
.audio-progress-bar {
  height: 100%; background: var(--accent-light);
  border-radius: 2px; width: 0%; transition: width 0.1s linear;
}
.audio-time {
  font-size: 0.75rem; color: var(--text-muted);
  min-width: 3.2rem; text-align: right; font-variant-numeric: tabular-nums;
}

/* ========== EVENTI ========== */
.events-list { display: flex; flex-direction: column; gap: 0.75rem; }

.event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.2rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
  display: flex;
  gap: 1.2rem;
  align-items: flex-start;
}
.event-card:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.event-date-badge {
  background: var(--accent);
  border-radius: 10px;
  min-width: 48px;
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}
.event-date-day {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}
.event-date-month {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.85);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.event-body { flex: 1; min-width: 0; }

.event-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.event-category {
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 0.15rem 0.5rem; border-radius: 4px;
  background: var(--accent); color: #fff; white-space: nowrap;
}
.event-category[data-cat="Cultura"] { background: #8e44ad; }
.event-category[data-cat="Musica"] { background: #c0392b; }
.event-category[data-cat="Festival"] { background: #d4881c; }
.event-category[data-cat="Sport"] { background: #27a854; }
.event-category[data-cat="Teatro"] { background: #c0692b; }
.event-category[data-cat="Mostre"] { background: #17a589; }
.event-category[data-cat="Conferenze"] { background: #2e86c1; }
.event-category[data-cat="Sagre"] { background: #a84327; }
.event-category[data-cat="Altro"] { background: #636e83; }

.event-price {
  font-size: 0.65rem;
  color: var(--green);
  margin-left: auto;
  white-space: nowrap;
}
.event-price[data-price="a_pagamento"] { color: var(--orange); }
.event-price[data-price="offerta_libera"] { color: var(--accent-light); }

.event-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.4rem;
}

.event-info {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.event-date-label { font-weight: 500; }

/* Detail meta */
.event-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1.2rem 0;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.event-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.event-detail-row svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.event-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 1.2rem;
}
.event-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
}

/* ========== FORM SUBMIT EVENTO ========== */
.form-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.form-error {
  background: rgba(224, 85, 85, 0.12);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 0.8rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1.2rem;
}

.submit-form fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}

.submit-form legend {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-light);
  padding: 0 0.4rem;
}

.form-group {
  margin-bottom: 0.8rem;
  flex: 1;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.form-group label.required::after {
  content: ' *';
  color: var(--red);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group textarea { resize: vertical; min-height: 80px; }
.form-group select { cursor: pointer; }

.form-row {
  display: flex;
  gap: 0.8rem;
}

.form-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  display: block;
}

.image-upload {
  position: relative;
}
.image-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.image-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem;
  border: 2px dashed var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  text-align: center;
  transition: border-color 0.2s;
}
.image-upload:hover .image-upload-label {
  border-color: var(--accent);
}
.image-upload-label svg {
  width: 32px;
  height: 32px;
}
.image-upload-label span:first-of-type {
  font-size: 0.85rem;
}
.image-preview {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.image-preview img {
  display: block;
  width: 100%;
  max-height: 250px;
  object-fit: cover;
}
.image-remove {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: background 0.2s;
}
.image-remove:hover { background: var(--red); }

.submit-btn {
  display: block;
  width: 100%;
  padding: 0.9rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 0.5rem;
}
.submit-btn:hover { opacity: 0.85; }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== FOOTER ========== */
footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}
footer a {
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 600;
}
footer a:hover { color: #fff; }

/* ========== STATI: LOADING e VUOTO ========== */
.loading { text-align: center; padding: 3rem; color: var(--text-muted); }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 3rem; color: var(--text-secondary); }

/* ========== RESPONSIVE ========== */
@media (max-width: 600px) {
  header {
    padding: 0.8rem 1rem;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  header h1 { font-size: 1.1rem; }
  .main-nav { order: 3; width: 100%; }
  .nav-link { font-size: 0.75rem; padding: 0.3rem 0.6rem; }
  .header-info { font-size: 0.7rem; margin-left: auto; }

  .hero { padding: 2rem 0.5rem 1.5rem; }
  .hero h2 { font-size: 1.8rem; }
  .hero p { font-size: 0.9rem; }
  .app-card { padding: 1rem 1.2rem; gap: 1rem; }
  .app-icon { width: 40px; height: 40px; border-radius: 10px; }
  .app-icon svg { width: 22px; height: 22px; }
  .app-info h3 { font-size: 0.95rem; }
  .app-info p { font-size: 0.75rem; }

  .container { padding: 0.8rem; }

  .date-selector { gap: 0.35rem; padding-bottom: 0.8rem; margin-bottom: 0.8rem; }
  .date-btn { padding: 0.4rem 0.7rem; font-size: 0.75rem; }

  .filters { gap: 0.3rem; margin-bottom: 1rem; }
  .filter-btn { padding: 0.25rem 0.6rem; font-size: 0.7rem; }

  .pill-card { padding: 1rem; }
  .pill-title { font-size: 0.95rem; }
  .pill-summary { font-size: 0.8rem; }
  .pill-meta { gap: 0.6rem; font-size: 0.65rem; }

  .detail-card { padding: 1.2rem; }
  .detail-card .pill-title { font-size: 1.2rem; }
  .detail-card .pill-summary { font-size: 0.9rem; line-height: 1.7; }

  .source-link { font-size: 0.8rem; }
  .source-domain { font-size: 0.7rem; }

  .audio-btn { width: 32px; height: 32px; }
  .audio-btn svg { width: 14px; height: 14px; }
  .audio-player { padding: 0.5rem 0.8rem; gap: 0.6rem; }
  .audio-player-btn { width: 32px; height: 32px; }
  .audio-player-btn svg { width: 16px; height: 16px; }
  .audio-time { font-size: 0.65rem; min-width: 2.8rem; }

  .event-card { padding: 1rem; gap: 0.8rem; }
  .event-date-badge { min-width: 42px; padding: 0.4rem 0.5rem; }
  .event-date-day { font-size: 1rem; }
  .event-title { font-size: 0.95rem; }
  .event-info { gap: 0.5rem; font-size: 0.7rem; }
  .event-detail-meta { padding: 0.8rem; }
  .event-detail-row { font-size: 0.8rem; }

  .submit-form fieldset { padding: 0.8rem 1rem; }
  .form-row { flex-direction: column; gap: 0.4rem; }
  .form-subtitle { font-size: 0.85rem; }
}
