/* =====================================================================
   Intestazione, ricerca, tema, intestazione di pagina
   Modulo estratto da components.css. L'ordine di caricamento conta (alcune
   regole devono stare dopo altre con la stessa specificità) ed è fissato in
   templates/_stylesheets.html: non riordinare i moduli.
   ===================================================================== */

/* ===== TOPBAR ===== */
.topbar {
  background: linear-gradient(135deg, var(--topbar-start), var(--topbar-end));
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  padding-top: env(safe-area-inset-top, 0px);
}

.topbar-inner {
  display: grid;
  grid-template-columns: auto minmax(15rem, 30rem) auto;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  padding: 0.55rem max(1.5rem, env(safe-area-inset-right)) 0.55rem max(1.5rem, env(safe-area-inset-left));
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-user-name {
  color: rgba(255,255,255,0.85);
  font-size: var(--text-sm);
  font-weight: 500;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
}

.topbar-logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.25);
}

.topbar-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: white;
  letter-spacing: 0.3px;
}

/* NB: le classi .topbar-tabs e .topbar-tabs-inner non esistono più nei
   template (le sezioni stanno in .nav-sections, vedi in fondo al file). */
.report-bar {
  position: static;
  transform: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
  padding: 0;
  border-left: 1px solid rgba(255,255,255,0.2);
  padding-left: 0.75rem;
}

.report-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.8rem;
  border-radius: 2rem;
  border: none;
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.topbar-action-icon,
.nav-icon,
.section-title-icon,
.button-inline-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-icon { width: 17px; height: 17px; }
.section-title-icon { width: 24px; height: 24px; }
.button-inline-icon { width: 17px; height: 17px; }

.mobile-bottom-nav { display: none; }
.mobile-card-open-link { display: none; }

.report-mobile-label,
.topbar-theme-label {
  display: none;
}

.report-pill-team {
  background: var(--success-solid);
  color: var(--on-success);
  min-height: 42px;
  padding: 0.55rem 1.05rem;
  border: 1px solid rgba(255,255,255,0.24);
  box-shadow: 0 3px 10px rgba(4, 120, 87, 0.28);
  font-size: var(--text-sm);
  font-weight: 750;
}

.report-pill-team .topbar-action-icon { width: 20px; height: 20px; }

.report-pill-team:hover {
  background: var(--success-solid-hover);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.32);
  transform: translateY(-1px);
}

@media (min-width: 601px) and (max-width: 1100px) {
  .topbar-inner { gap: .75rem; padding-inline: 1rem; }
  .topbar-user-name { display: none; }
  .report-desktop-label { display: none; }
  .report-mobile-label { display: inline; }
  .report-pill-team { min-height: 38px; padding: .4rem .75rem; font-size: var(--text-xs); }
}

.report-pill-self {
  background: var(--info-solid);
  color: var(--on-info);
}

.report-pill-self:hover {
  background: var(--info-solid-hover);
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.2);
}

.report-pill-obsidian {
  background: #7c3aed;
  color: white;
}
.report-pill-obsidian:hover {
  background: #6d28d9;
  box-shadow: 0 0 14px rgba(124, 58, 237, 0.3);
}

.report-pill:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.report-pill:disabled:hover {
  background: none;
  box-shadow: none;
}

.hamburger-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 10px;
  margin-left: auto;
}
.hamburger-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: rgba(255,255,255,0.85);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.hamburger-toggle.is-active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger-toggle.is-active span:nth-child(2) { opacity: 0; }
.hamburger-toggle.is-active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* NB: l'adattamento delle voci alle finestre strette è ora nel blocco
   "INTESTAZIONE A DUE PIANI" in fondo al file, insieme al resto dell'header.
   Le vecchie regole a gradini (con .topbar-tabs / .tab-link, classi che non
   esistono più nei template) sono state rimosse: erano codice morto. */

@media (max-width: 768px) {
  .report-bar { position: static; transform: none; }
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-bottom-nav);
    display: grid;
    width: 100%;
    box-sizing: border-box;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: 68px;
    padding: 0.35rem max(0.35rem, env(safe-area-inset-right)) calc(0.35rem + env(safe-area-inset-bottom)) max(0.35rem, env(safe-area-inset-left));
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -8px 24px rgba(0,0,0,0.12);
    backdrop-filter: blur(14px);
  }
  .mobile-bottom-link {
    display: flex;
    min-width: 0;
    min-height: 56px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.25rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.65rem;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
  }
  .mobile-bottom-link .nav-icon { width: 21px; height: 21px; }
  .mobile-bottom-link.active { color: var(--green-700); background: var(--green-50); }
  .mobile-more-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-nav-backdrop);
    background: var(--modal-overlay);
  }
  .mobile-more-menu {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-nav-menu);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.6rem 1rem calc(0.9rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--gray-200);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--surface);
    box-shadow: 0 -12px 28px rgba(0,0,0,0.2);
    max-height: min(78dvh, 34rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sheet-handle {
    display: block;
    width: 2.75rem;
    height: 0.3rem;
    margin: 0 auto 0.4rem;
    border-radius: var(--radius-full);
    background: var(--gray-300);
    flex: 0 0 auto;
  }
  .sheet-title {
    margin: 0 0 0.25rem;
    color: var(--text);
    font-size: var(--text-xl);
    font-weight: 800;
  }
  .sheet-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.4rem 0 0.15rem;
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  .sheet-section::after {
    height: 1px;
    flex: 1;
    background: var(--gray-200);
    content: '';
  }
  .sheet-row {
    display: flex;
    min-height: 54px;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    background: var(--gray-50);
    color: var(--text);
    text-decoration: none;
    transition: background 0.18s ease, transform 0.18s ease;
  }
  .sheet-row:hover { background: var(--gray-100); }
  .sheet-row:active { transform: scale(0.99); }
  .sheet-row-button { width: 100%; border: 0; font: inherit; cursor: pointer; text-align: left; }
  .sheet-row-form { margin: 0; }
  .sheet-row-icon {
    display: inline-flex;
    width: 2.25rem;
    height: 2.25rem;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--green-50);
    color: var(--green-700);
  }
  .sheet-row-icon .nav-icon { width: 20px; height: 20px; }
  .sheet-row-text {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: column;
    line-height: 1.25;
  }
  .sheet-row-text strong { color: var(--text); font-size: var(--text-sm); font-weight: 700; }
  .sheet-row-text small { overflow: hidden; color: var(--text-secondary); font-size: 0.7rem; text-overflow: ellipsis; white-space: nowrap; }
  .sheet-row-arrow { flex: 0 0 auto; color: var(--gray-400); font-size: 0.8rem; }
  .sheet-enter, .sheet-leave, .sheet-enter-end, .sheet-leave-end { transform: translateY(0); }
  .sheet-enter-start, .sheet-leave-start { transform: translateY(100%); }
  .sheet-enter, .sheet-leave { scroll-behavior: auto; }
  .mobile-more-menu .nav-icon { width: 20px; height: 20px; color: var(--green-600); }

  .mobile-card-wrap,
  .table-wrap.mobile-card-wrap {
    overflow: visible;
    margin: 0;
    padding: 0;
  }
  table.mobile-card-table,
  .job-table.mobile-card-table,
  .settings-table.mobile-card-table {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .mobile-card-table thead { display: none; }
  .mobile-card-table tbody {
    display: grid;
    gap: 0.75rem;
  }
  .mobile-card-table tbody tr {
    display: block;
    overflow: hidden;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .mobile-card-table tbody tr:hover { background: var(--surface); box-shadow: var(--shadow-md); }
  .mobile-card-table tbody tr td {
    display: grid;
    grid-template-columns: minmax(86px, 0.38fr) minmax(0, 1fr);
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 0;
    border-bottom: 1px solid var(--gray-200);
    text-align: left;
    box-shadow: none;
  }
  .mobile-card-table tbody tr td:last-child { border-bottom: 0; }
  .mobile-card-table tbody tr td::before {
    content: attr(data-label);
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  .mobile-card-table tbody tr td.mobile-card-title {
    display: flex;
    min-height: 52px;
    align-items: center;
    gap: 0.45rem;
    background: var(--green-50);
    border-bottom-color: var(--green-100);
    font-size: var(--text-base);
  }
  .mobile-card-table tbody tr td.mobile-card-title::before { display: none; }
  .mobile-card-table tbody tr td.mobile-card-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .mobile-card-table tbody tr td.mobile-card-actions::before { margin-right: auto; }
  .mobile-card-table .mobile-card-actions form { margin: 0; }
  .mobile-card-open-link { display: inline-flex; }
  .mobile-card-table input:not([type="checkbox"]),
  .mobile-card-table select { min-width: 0; width: 100%; }
  .settings-user-card-table td > form {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
  }
  .settings-user-card-table td > form > input:not([type="hidden"]),
  .settings-user-card-table td > form > select { flex: 1 1 150px; width: auto; }
  .mobile-card-table td.mobile-card-empty {
    display: block;
    text-align: center;
  }
  .mobile-card-table td.mobile-card-empty::before { display: none; }
  .mobile-sticky-actions {
    position: sticky;
    bottom: calc(var(--bottom-nav-h) + 0.5rem);
    z-index: var(--z-sticky-actions);
    padding: 0.65rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
  }
  .mobile-sticky-actions .btn-primary { width: 100%; }
}

/* NB: le voci di sezione non usano piu' .tab-link ne' .tab-icon-box.
   Ora sono .section-link / .section-icon, definite nel blocco
   "INTESTAZIONE A DUE PIANI" in fondo al file, dove vivono anche le regole
   per le finestre strette. */

/* ===== SEARCH BAR IN TOPBAR ===== */
.topbar-search {
  flex: 1;
  min-width: 0;
  max-width: 280px;
  margin: 0 1rem;
}

.topbar-search-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4rem 0.6rem 0.4rem 2rem;
  border-radius: 999px;
  border: 1.5px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.75);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.topbar-search-button:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.4);
}

/* Il testo del pulsante e' l'unica parte comprimibile: su schermi stretti
   resta solo la lente, che da sola dice gia' "qui si cerca". */
.topbar-search-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* La scorciatoia scritta dentro il pulsante: e' la notizia che da sola fa
   scoprire la funzione, quindi ha il contrasto pieno e non e' decorazione. */
.topbar-search-kbd {
  flex-shrink: 0;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.15);
  color: white;
  font-family: var(--font-mono, monospace);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
}

/* ===== THEME TOGGLE IN TOPBAR ===== */
.topbar-theme-btn {
  background: rgba(255,255,255,0.1);
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,0.8);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.topbar-theme-btn:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.4);
  transform: scale(1.05);
}

.topbar-settings-link {
  text-decoration: none;
}

.topbar-settings-gear {
  fill: currentColor;
  stroke: none;
}

.topbar-settings-link.is-active {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.55);
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.page-header-left {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.page-header-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--green-800);
  margin: 0;
  line-height: 1.2;
}

.page-header-btn {
  flex-shrink: 0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 3px solid var(--green-200);
}

.app-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--green-800);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.2;
}

.app-section-title :is(.lucide, svg, i) { color: var(--green-600); }

/* Icone dei titoli uniformi: stesso verde e stesso allineamento in entrambi
   i sistemi di intestazione (uomini e pagine delle sezioni). */
.page-header-title :is(.lucide, svg, i) {
  color: var(--green-600);
  display: inline-flex;
  flex-shrink: 0;
}

.app-section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dashboard-page-header {
  align-items: flex-end;
  margin-bottom: 1rem;
  padding: 0.2rem 0 0.9rem;
  border-bottom: 1px solid var(--green-200);
}

.dashboard-page-header .page-header-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--text-2xl);
}

.dashboard-page-header .page-header-title .icon-xl { color: var(--green-600); }

/* Telefono: in alto restano logo, "Report" e notifiche. "Test report", "Obsidian"
   e Impostazioni sono nel menu "Altro" (con nome e spiegazione), cosi' la barra
   non e' una fila di icone senza testo. */
@media (max-width: 768px) {
  .topbar-inner .report-pill-self,
  .topbar-inner .report-pill-obsidian,
  .topbar-inner .topbar-settings-link { display: none; }
}
