/* portal.css — struttura e componenti del portale TaskForger */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--tf-bg); color: var(--tf-navy);
  font: 15px/1.5 var(--font-text); -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--font-title); font-weight: 600; margin: 0; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--tf-blue); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -48px; z-index: 100; padding: 8px 12px; background: var(--tf-surface); border: 1px solid var(--tf-border); border-radius: var(--radius-control); }
.skip-link:focus { top: 8px; }
svg { flex: none; }

/* ---------- struttura ---------- */
.tf-shell { display: flex; min-height: 100%; }
.tf-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.tf-content { flex: 1 1 auto; min-width: 0; outline: none; }

/* ---------- barra laterale navy ---------- */
.tf-sidebar {
  flex: none; width: var(--sidebar-w); background: var(--tf-navy); color: #fff;
  display: flex; flex-direction: column; padding: var(--space-2) 12px;
  position: sticky; top: 0; height: 100vh;
}
.tf-sidebar .brand-space { height: 32px; }
.tf-sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.tf-sidebar .nav-item {
  display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px;
  border: 0; border-radius: var(--radius-control); background: transparent; color: rgba(255, 255, 255, 0.82);
  font-weight: 500; font-size: 14px; text-align: left; width: 100%; position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}
.tf-sidebar .nav-item:hover { background: var(--tf-navy-2); color: #fff; }
.tf-sidebar .nav-item[aria-current="page"] { background: var(--tf-blue); color: #fff; }
.tf-sidebar .nav-item[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: #fff;
}
.tf-sidebar .nav-item svg { width: 20px; height: 20px; }
.tf-sidebar .nav-item .count { margin-left: auto; font-size: 12px; font-weight: 600; background: rgba(255, 255, 255, 0.16); border-radius: 999px; padding: 1px 8px; }
.tf-sidebar .nav-item[aria-current="page"] .count { background: rgba(255, 255, 255, 0.28); }
.tf-sidebar .spacer { flex: 1 1 auto; }
.tf-sidebar .sidebar-foot { border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 12px; margin-top: 12px; }
.tf-sidebar-backdrop { position: fixed; inset: 0; background: rgba(8, 21, 52, 0.45); z-index: 29; }

/* ---------- header ---------- */
.tf-header {
  height: var(--header-h); background: var(--tf-surface); border-bottom: 1px solid var(--tf-border);
  display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-3);
  position: sticky; top: 0; z-index: 20; box-shadow: 0 1px 0 rgba(8, 21, 52, 0.04);
}
.tf-header .menu-btn { display: none; }
.tf-header .logo { display: inline-flex; align-items: center; height: 44px; padding: 0 4px; border: 0; background: transparent; border-radius: var(--radius-control); }
.tf-header .logo img { height: 36px; width: auto; display: block; }
.tf-header .logo:hover { background: var(--tf-selection); }
.tf-header .divider { width: 1px; height: 28px; background: var(--tf-border); }
.tf-header .section { font-family: var(--font-title); font-weight: 600; font-size: 16px; }
.tf-header .section small { display: block; font: 400 12px/1.2 var(--font-text); color: var(--tf-muted); }
.tf-header .header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ---------- bottoni e campi ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--control-h-sm); padding: 0 14px; border-radius: var(--radius-control);
  background: var(--tf-surface); color: var(--tf-navy); border: 1px solid var(--tf-border);
  font-weight: 500; font-size: 14px; box-shadow: var(--shadow-1); white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.btn:hover { background: var(--tf-selection); border-color: var(--tf-border-strong); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--tf-blue); border-color: var(--tf-blue); color: #fff; }
.btn.primary:hover { background: var(--tf-blue-dark); border-color: var(--tf-blue-dark); }
.btn.link { background: transparent; border-color: transparent; box-shadow: none; color: var(--tf-blue); font-weight: 600; }
.btn.link:hover { background: var(--tf-selection); }
.btn.lg { height: var(--control-h); padding: 0 20px; font-size: 15px; }
.btn.icon { width: var(--control-h-sm); padding: 0; }
.btn svg { width: 18px; height: 18px; }

.field { position: relative; display: flex; align-items: center; }
.field > svg { position: absolute; left: 16px; width: 20px; height: 20px; color: var(--tf-muted); pointer-events: none; }
.field input {
  width: 100%; height: var(--control-h); padding: 0 44px 0 48px;
  background: var(--tf-surface); border: 1px solid var(--tf-border); border-radius: var(--radius-control);
  font-size: 15px; color: var(--tf-navy); box-shadow: var(--shadow-1);
}
.field input::placeholder { color: var(--tf-muted); }
.field input:focus { outline: none; border-color: var(--tf-blue); box-shadow: var(--tf-focus); }
.field .clear { position: absolute; right: 6px; width: 32px; height: 32px; border: 0; background: transparent; border-radius: 8px; color: var(--tf-muted); display: inline-flex; align-items: center; justify-content: center; }
.field .clear:hover { background: var(--tf-selection); color: var(--tf-navy); }
.field .clear svg { width: 16px; height: 16px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 999px;
  background: var(--tf-bg); border: 1px solid var(--tf-border); color: var(--tf-muted); font-size: 12.5px; font-weight: 500;
}
.badge.ok { background: #E3F6EC; border-color: #B7E4CB; color: #136A3C; }
.badge.warn { background: #FFF3D6; border-color: #F1DCA3; color: #7A5300; }
.badge.info { background: var(--tf-selection); border-color: #C9D5EE; color: var(--tf-blue); }
.badge svg { width: 14px; height: 14px; }

/* interruttore (impostazioni) */
.switch { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 0; background: transparent; border: 0; text-align: left; color: inherit; border-radius: 8px; }
.switch .track { flex: none; width: 36px; height: 20px; border-radius: 999px; background: rgba(255, 255, 255, 0.25); position: relative; transition: background var(--t-fast); }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--t-fast); }
.switch[aria-checked="true"] .track { background: var(--tf-blue); }
.switch[aria-checked="true"] .track::after { transform: translateX(16px); }
.switch .lbl { font-size: 13px; line-height: 1.3; color: rgba(255, 255, 255, 0.9); }
.switch .lbl small { display: block; color: rgba(255, 255, 255, 0.6); font-size: 11.5px; }
.sidebar-foot .foot-title { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: rgba(255, 255, 255, 0.55); margin: 4px 0 6px 12px; font-weight: 600; }
.sidebar-foot .link-btn { background: transparent; border: 0; color: rgba(255, 255, 255, 0.75); font-size: 13px; padding: 8px 12px; border-radius: 8px; width: 100%; text-align: left; display: flex; gap: 10px; align-items: center; }
.sidebar-foot .link-btn:hover { background: var(--tf-navy-2); color: #fff; }
.sidebar-foot .link-btn svg { width: 16px; height: 16px; }
.sidebar-foot .note { font-size: 11.5px; color: rgba(255, 255, 255, 0.55); padding: 6px 12px 0; line-height: 1.4; }

/* ---------- introduzione ---------- */
.hero {
  position: relative; overflow: hidden; background: var(--tf-surface); border-bottom: 1px solid var(--tf-border);
  min-height: 300px;
}
.hero .art {
  position: absolute; inset: 0 0 0 38%; background: url("../assets/sfondo.jpg") right center / cover no-repeat;
  pointer-events: none;
}
.hero .art::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, #fff 0%, rgba(255, 255, 255, 0.92) 22%, rgba(255, 255, 255, 0.35) 55%, rgba(255, 255, 255, 0) 100%);
}
.hero .hero-inner { position: relative; padding: var(--space-5) var(--space-4) var(--space-4); max-width: 760px; }
.hero h1 { font-size: 46px; line-height: 1.08; letter-spacing: -0.01em; font-weight: 700; }
.hero h1 .accent { color: var(--tf-blue); }
.hero .sub { margin-top: 12px; font-size: 18px; color: var(--tf-muted); }
.hero .search { margin-top: var(--space-3); max-width: 640px; }
.hero .filters { margin-top: var(--space-2); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters .pill {
  height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--tf-border); background: var(--tf-surface);
  color: var(--tf-navy); font-size: 14px; font-weight: 500; box-shadow: var(--shadow-1);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.filters .pill:hover { background: var(--tf-selection); border-color: var(--tf-border-strong); }
.filters .pill[aria-pressed="true"] { background: var(--tf-blue); border-color: var(--tf-blue); color: #fff; }

/* ---------- sezione catalogo ---------- */
.section-block { padding: var(--space-3) var(--space-4) var(--space-5); }
.section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: var(--space-2); }
.section-head h2 { font-size: 24px; }
.section-head .count { color: var(--tf-muted); font-size: 14px; }
.section-head .actions { margin-left: auto; display: flex; gap: 8px; }
.section-head .search { flex: 1 1 320px; max-width: 480px; }

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
@media (max-width: 1500px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid { grid-template-columns: minmax(0, 1fr); } }

/* scheda applicazione */
.app-card {
  position: relative; display: flex; flex-direction: column; gap: 14px; padding: var(--space-3);
  background: var(--tf-surface); border: 1px solid var(--tf-border); border-radius: var(--radius-panel);
  box-shadow: var(--shadow-1); transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.app-card:hover { border-color: var(--tf-border-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.app-card:focus-within { border-color: var(--tf-blue); box-shadow: 0 0 0 1px var(--tf-blue) inset, var(--shadow-2); }
.app-card.unavailable .icon-tile { opacity: 0.6; }
.app-card .top { display: flex; gap: 16px; align-items: flex-start; }
.app-card .icon-tile { flex: none; width: 60px; height: 60px; border-radius: 12px; background: var(--tf-selection); color: var(--tf-blue); display: flex; align-items: center; justify-content: center; }
.app-card .icon-tile svg { width: 30px; height: 30px; }
.app-card .icon-tile img { width: 100%; height: 100%; object-fit: contain; border-radius: 12px; }
.app-card .title { min-width: 0; flex: 1 1 auto; }
.app-card h3 { font-size: 19px; line-height: 1.25; padding-right: 36px; }
.app-card .desc { margin-top: 6px; color: var(--tf-muted); font-size: 14px; line-height: 1.5; }
.app-card .fav {
  position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--tf-muted); display: inline-flex; align-items: center; justify-content: center;
}
.app-card .fav:hover { background: var(--tf-selection); color: var(--tf-navy); }
.app-card .fav[aria-pressed="true"] { color: var(--tf-blue); }
.app-card .fav svg { width: 20px; height: 20px; }
.app-card .fav[aria-pressed="true"] svg { fill: currentColor; }
.app-card .bottom { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.app-card .badges { display: flex; gap: 6px; flex-wrap: wrap; }
.app-card .open { height: var(--control-h-sm); padding: 0 12px; }
.app-card .open svg { width: 16px; height: 16px; }
.app-card .hint { font-size: 12px; color: var(--tf-muted); }

/* elenco recenti */
.recent-list { display: flex; flex-direction: column; gap: 12px; }
.recent-item {
  display: flex; align-items: center; gap: 16px; padding: 16px var(--space-3);
  background: var(--tf-surface); border: 1px solid var(--tf-border); border-radius: var(--radius-panel); box-shadow: var(--shadow-1);
}
.recent-item .icon-tile { flex: none; width: 48px; height: 48px; border-radius: 10px; background: var(--tf-selection); color: var(--tf-blue); display: flex; align-items: center; justify-content: center; }
.recent-item .icon-tile svg { width: 24px; height: 24px; }
.recent-item .txt { flex: 1 1 auto; min-width: 0; }
.recent-item h3 { font-size: 17px; }
.recent-item .when { color: var(--tf-muted); font-size: 13px; margin-top: 2px; }
.recent-item .acts { display: flex; gap: 8px; align-items: center; }

/* stato vuoto */
.empty {
  text-align: center; padding: var(--space-5) var(--space-3);
  background: var(--tf-surface); border: 1px dashed var(--tf-border-strong); border-radius: var(--radius-panel);
}
.empty .icon-tile { width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 12px; background: var(--tf-selection); color: var(--tf-blue); display: flex; align-items: center; justify-content: center; }
.empty .icon-tile svg { width: 28px; height: 28px; }
.empty h3 { font-size: 20px; }
.empty p { color: var(--tf-muted); margin-top: 6px; }
.empty .btn { margin-top: 16px; }

.notice { font-size: 12.5px; color: var(--tf-muted); margin-top: var(--space-2); }

/* ---------- finestra modale (motore locale) ---------- */
.tf-modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(8, 21, 52, 0.45); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.tf-modal { position: relative; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--tf-surface); border: 1px solid var(--tf-border); border-top: 2px solid var(--tf-blue); border-radius: var(--radius-panel); box-shadow: var(--shadow-3); padding: var(--space-3); }
.tf-modal .close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border: 0; background: transparent; border-radius: 8px; color: var(--tf-muted); display: inline-flex; align-items: center; justify-content: center; }
.tf-modal .close:hover { background: var(--tf-selection); color: var(--tf-navy); }
.tf-modal .icon-tile { width: 48px; height: 48px; border-radius: 12px; background: var(--tf-selection); color: var(--tf-blue); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.tf-modal h2 { font-size: 20px; margin: 0 36px 8px 0; }
.tf-modal p { color: var(--tf-muted); font-size: 14px; line-height: 1.5; }
.tf-modal p strong { color: var(--tf-navy); }
.tf-modal .steps { margin: 12px 0 0; padding-left: 20px; color: var(--tf-navy); font-size: 14px; line-height: 1.6; }
.tf-modal .note { margin-top: 12px; font-size: 12.5px; }
.tf-modal .note:empty { display: none; }
.tf-modal .buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: var(--space-2); }
.tf-modal .buttons .btn { height: var(--control-h); padding: 0 16px; text-decoration: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .hero h1 { font-size: 38px; }
  .hero .art { inset: 0 0 0 50%; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 240px; }
  .tf-sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 30; transform: translateX(-100%); transition: transform 160ms ease; box-shadow: none; }
  .tf-shell.menu-open .tf-sidebar { transform: none; box-shadow: var(--shadow-3); }
  .tf-header { padding: 0 var(--space-2); }
  .tf-header .menu-btn { display: inline-flex; }
  .hero .hero-inner { padding: var(--space-4) var(--space-2) var(--space-3); }
  .hero .art { inset: 0 0 0 55%; opacity: 0.55; }
  .section-block { padding: var(--space-2) var(--space-2) var(--space-4); }
}
@media (max-width: 640px) {
  .hero h1 { font-size: 30px; }
  .hero .sub { font-size: 16px; }
  .hero .art { inset: auto 0 0 45%; height: 50%; opacity: 0.4; }
  .tf-header .section small { display: none; }
  .section-head h2 { font-size: 22px; }
  .tf-modal .buttons { flex-direction: column-reverse; }
  .tf-modal .buttons .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
