/* ==========================================================================
   Variabili globali
   --------------------------------------------------------------------------
   Token visuali condivisi da tutta l'app. I componenti possono usarli, ma non
   devono aggiungere qui regole specifiche di pagina o componente.
   ========================================================================== */
:root {
  --app_color_text: #1f2933;
  --app_color_muted: #5f6f7d;
  --app_color_surface: #ffffff;
  --app_color_background: #f6f8fb;
  --app_color_border: #d9e2ec;
  --app_color_primary: #1f6f68;
  --app_color_primary_hover: #185a55;
  --app_color_focus: #2f80ed;
  --app_color_error: #b42318;
  --app_color_error_bg: #fff1f0;
  --app_color_success: #157347;
  --app_color_success_bg: #edf9f1;
  --app_shadow_soft: 0 12px 30px rgba(15, 23, 42, 0.08);
  --app_radius: 8px;
  --app_container_max: 1120px;
  --app_space_1: 0.25rem;
  --app_space_2: 0.5rem;
  --app_space_3: 0.75rem;
  --app_space_4: 1rem;
  --app_space_5: 1.5rem;
  --app_space_6: 2rem;
  --app_space_7: 3rem;
  --app_font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ==========================================================================
   Reset base
   --------------------------------------------------------------------------
   Normalizza box model e comportamento media senza invadere i componenti.
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--app_color_text);
  background: var(--app_color_background);
  font-family: var(--app_font);
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
}

/* ==========================================================================
   Tipografia base
   --------------------------------------------------------------------------
   Regole comuni per testo e link. Le dimensioni specifiche stanno nei CSS dei
   singoli componenti.
   ========================================================================== */
h1,
h2,
h3,
p {
  margin-top: 0;
}

a {
  color: var(--app_color_primary);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--app_color_primary_hover);
}

/* ==========================================================================
   Layout globale
   --------------------------------------------------------------------------
   Shell e contenitori condivisi. Le pagine montate dal loader entrano in
   #app_main e possono usare .app_container per allinearsi al layout.
   ========================================================================== */
.app_shell {
  min-height: 100vh;
}

.app_root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app_main {
  flex: 1;
  width: 100%;
}

.app_container {
  width: min(100% - 2rem, var(--app_container_max));
  margin-inline: auto;
}

/* ==========================================================================
   Bottoni comuni
   --------------------------------------------------------------------------
   Classi button condivise. Varianti o gruppi specifici restano nei componenti.
   ========================================================================== */
.app_button {
  display: inline-flex;
  min-height: 2.5rem;
  align-items: center;
  justify-content: center;
  gap: var(--app_space_2);
  border: 1px solid var(--app_color_border);
  border-radius: var(--app_radius);
  padding: 0.6rem 1rem;
  color: var(--app_color_text);
  background: var(--app_color_surface);
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.app_button:hover {
  border-color: var(--app_color_primary);
  color: var(--app_color_primary);
}

.app_button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--app_color_focus) 35%, transparent);
  outline-offset: 2px;
}

.app_button:active {
  transform: translateY(1px);
}

.app_button_primary {
  border-color: var(--app_color_primary);
  color: #ffffff;
  background: var(--app_color_primary);
}

.app_button_primary:hover {
  border-color: var(--app_color_primary_hover);
  color: #ffffff;
  background: var(--app_color_primary_hover);
}

/* ==========================================================================
   Form comuni
   --------------------------------------------------------------------------
   Stili condivisi per label, campi e input. Layout complessi restano nei CSS
   dei componenti che li usano.
   ========================================================================== */
.app_field {
  display: grid;
  gap: var(--app_space_2);
}

.app_label {
  color: var(--app_color_text);
  font-weight: 650;
}

.app_input {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--app_color_border);
  border-radius: var(--app_radius);
  padding: 0.65rem 0.8rem;
  color: var(--app_color_text);
  background: var(--app_color_surface);
}

.app_input:focus {
  border-color: var(--app_color_focus);
  outline: 3px solid color-mix(in srgb, var(--app_color_focus) 25%, transparent);
}

/* ==========================================================================
   Stato e feedback
   --------------------------------------------------------------------------
   Utility visuali usate da loader, permessi, form e componenti.
   ========================================================================== */
.app_hidden {
  display: none !important;
}

.app_disabled {
  pointer-events: none;
  opacity: 0.45;
}

.app_loading {
  padding-block: var(--app_space_7);
  color: var(--app_color_muted);
}

.app_error,
.app_success {
  border-radius: var(--app_radius);
  padding: var(--app_space_4);
}

.app_error {
  border: 1px solid color-mix(in srgb, var(--app_color_error) 30%, transparent);
  color: var(--app_color_error);
  background: var(--app_color_error_bg);
}

.app_success {
  border: 1px solid color-mix(in srgb, var(--app_color_success) 30%, transparent);
  color: var(--app_color_success);
  background: var(--app_color_success_bg);
}

/* ==========================================================================
   Utility accessibilita'
   --------------------------------------------------------------------------
   Classi condivise per testo solo screen reader e focus prevedibile.
   ========================================================================== */
.app_sr_only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

:focus-visible {
  outline-color: var(--app_color_focus);
}
