/* ============================================
   MASTER CONSTRUCTIONS - CSS UNIFICATO
   Mobile-First Responsive Design
   by Renzo Di Chio - 2025
   ============================================ */

/* ---------- VARIABILI CSS ---------- */
:root {
  /* Colori primari */
  --color-primary: #653988;
  --color-primary-light: #9A65CB;
  --color-primary-lighter: #C19FDF;
  --color-primary-lightest: #F3E9FB;
  
  /* Colori secondari */
  --color-secondary: #336699;
  --color-secondary-light: #39396A;
  --color-text: #333;
  --color-text-light: #666;
  --color-text-lighter: #999;
  --color-muted: #6c757d;
  
  /* Colori di stato */
  --color-success: #28a745;
  --color-warning: #ffc107;
  --color-danger: #dc3545;
  --color-info: #17a2b8;
  
  /* Colori neutri */
  --color-white: #ffffff;
  --color-background: #f8f9fa;
  --color-border: #ddd;
  --color-border-light: #eee;
  
  /* Dimensioni base */
  --spacing-xs: 0.25em;
  --spacing-sm: 0.5em;
  --spacing-md: 1em;
  --spacing-lg: 1.5em;
  --spacing-xl: 2em;
  
  /* Border radius */
  --radius-sm: 0.25em;
  --radius-md: 0.5em;
  --radius-lg: 0.75em;
  
  /* Altezze minime touch */
  --touch-target: 3em;
  --touch-target-large: 3.5em;
  
  /* Transizioni */
  --transition-fast: all 0.15s ease;
  --transition-normal: all 0.3s ease;
  
  /* Ombre */
  --shadow-sm: 0 0.125em 0.25em rgba(0,0,0,0.1);
  --shadow-md: 0 0.25em 0.5em rgba(0,0,0,0.1);
  --shadow-lg: 0 0.25em 1em rgba(0,0,0,0.15);
}

/* ---------- RESET E BASE ---------- */
* {
  box-sizing: border-box;
}

html {
  /* Default GRANDE per smartphone */
  font-size: 22px;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

/* Riduci su tablet */
@media (min-width: 768px) {
  html {
    font-size: 17px;
  }
}

/* Riduci ancora su desktop */
@media (min-width: 1024px) {
  html {
    font-size: 15px;
  }
}

body {
  font-size: 1rem;
  /* font-family: "Arial", "Helvetica Neue", Helvetica, Arial, sans-serif; */
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.6;
  color: var(--color-secondary);
  text-align: center;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- HEADER ---------- */
.header-image {
  position: relative;
  overflow: visible;
  z-index: 1;
  width: 100%;
}

.header-image img {
  margin: auto;
  width: 100%;
  height: auto;
  max-height: 120px;
  object-fit: fill;
  display: block;
}

/* Barra di navigazione */
.nav-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.5em;
  background: transparent;
  z-index: 10;
}

.nav-left,
.nav-center,
.nav-right {
  display: flex;
  align-items: center;
}

.nav-left {
  flex: 1;
}

.nav-center {
  flex: 2;
  justify-content: center;
}

.nav-right {
  flex: 1;
  justify-content: flex-end;
  margin-right: 0.5em;
}

.nav-left img {
  width: 30px;
  height: 40px;
  cursor: pointer;
  transition: var(--transition-normal);
}

.nav-left img:hover {
  transform: scale(1.1);
}

/* ---------- USER MENU ---------- */
.user-menu {
  position: relative;
  display: inline-block;
}

.user-menu-btn {
  background: transparent;
  border: none;
  color: var(--color-white);
  font-weight: bold;
  cursor: pointer;
  font-size: 0.95em;
  padding: 0.4em 0.6em;
  border-radius: 0;
  transition: var(--transition-normal);
  min-height: auto;
  box-shadow: none;
}

.user-menu-btn:hover,
.user-menu-btn:active {
  background: transparent;
  color: #FFD700;
  border: none;
  transform: none;
}

.user-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background-color: var(--color-white);
  min-width: 250px; /* PIÙ LARGO */
  border: 2px solid var(--color-primary); /* Bordo più visibile */
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  margin-top: 0.5em;
}

.user-menu:hover .user-menu-dropdown,
.user-menu.active .user-menu-dropdown {
  display: block;
}

.user-menu-dropdown a {
  color: var(--color-primary);
  padding: 1em 1.2em; /* PIÙ PADDING */
  text-decoration: none;
  display: flex;
  align-items: center;
  font-size: 1.05em; /* PIÙ GRANDE */
  transition: var(--transition-fast);
  min-height: var(--touch-target-large);
  border-bottom: 1px solid var(--color-border-light);
}

.user-menu-dropdown a:last-child {
  border-bottom: none;
}

.user-menu-dropdown a:hover,
.user-menu-dropdown a:active {
  background-color: var(--color-primary);
  color: var(--color-white);
  padding-left: 1.5em;
  font-weight: bold;
}

.user-info {
  padding: 1em;
  background: var(--color-background);
  border-bottom: 1px solid var(--color-border-light);
}

.user-role {
  font-weight: 600;
  color: var(--color-primary);
  font-size: 0.95em;
  margin-bottom: 0.3em;
}

.user-company {
  color: var(--color-text-light);
  font-size: 0.9em;
}

.menu-separator {
  height: 1px;
  background: var(--color-border-light);
  margin: 0;
}

/* ---------- CONTAINER E LAYOUT ---------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75em; /* RIDOTTO per mobile */
  width: 100%;
}

.main-content {
  flex: 1;
  padding: 0 0.75em 0.75em 0.75em; /* padding-top: 0 per ridurre spazio totale */
  width: 100%;
}

/* ---------- CARDS ---------- */
.card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  margin-bottom: 1.25em;
  overflow: hidden;
  transition: var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-0.125em);
}

.card-header {
  background: var(--color-background);
  padding: 0.75em 1em; /* RIDOTTO */
  border-bottom: 1px solid var(--color-border);
}

.card-header h2, 
.card-header h3 {
  margin: 0;
  color: var(--color-text);
  font-size: 1.4em;
  line-height: 1.3;
}

.card-body {
  padding: 1em; /* RIDOTTO */
}

/* ---------- TITOLI - Mobile First (PIÙ GRANDI) ---------- */
h2.c1 {
  color: #A0A0CC;
  font-size: 2em;
  font-weight: lighter;
  padding: 0.3em 0.5em; /* RIDOTTO padding verticale */
  line-height: 1.3;
  margin: 0.3em 0; /* RIDOTTO margine */
}

p.c2 {
  color: #6c6c99;
  font-size: 1.6em;
  font-weight: lighter;
  padding: 0.3em 0.5em; /* RIDOTTO padding verticale */
  line-height: 1.3;
  margin: 0.3em 0; /* RIDOTTO margine */
}

p.c3 {
  color: #A0A0CC;
  font-size: 2em;
  font-weight: lighter;
  padding: 0.3em 0.5em; /* RIDOTTO padding verticale */
  line-height: 1.4;
  margin: 0.3em 0; /* RIDOTTO margine */
}

.cantiere-title {
  margin: 0.5em 0 0; /* RIDOTTO */
  font-size: 1.5em;
  color: var(--color-primary);
  font-weight: bold;
  padding: 0.3em 0.5em; /* RIDOTTO padding verticale */
}

.page-title {
  margin: 0.25em 0 0.5em; /* RIDOTTO */
  font-size: 1.2em;
  color: var(--color-secondary-light);
  font-weight: lighter;
  padding: 0.3em 0.5em; /* RIDOTTO padding verticale */
}

.testi {
  color: var(--color-secondary-light);
  font-weight: lighter;
  font-size: 1.15em; /* BASE: Grande per mobile */
  line-height: 1.6;
  text-align: justify;
  padding: 0.5em;
}

.text-muted {
  color: var(--color-muted);
  font-size: 0.9em;
  margin-top: 0.3em;
}

.text-center {
  text-align: center;
}

/* ---------- FORMS ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1em;
  margin-bottom: 1em;
}

.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.75em; /* RIDOTTO */
}

.form-group label {
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.4em;
  font-size: 1em;
}

.form-control {
  padding: 1em 1.2em;
  border: 2px solid var(--color-border); /* Bordo più visibile */
  border-radius: var(--radius-md);
  font-size: 1.1em; /* PIÙ GRANDE su mobile */
  transition: border-color 0.3s ease;
  min-height: 3.5em; /* PIÙ ALTO su mobile */
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 0.15em rgba(154, 101, 203, 0.2);
}

.form-actions {
  display: flex;
  gap: 0.75em;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1em;
}

/* ---------- BOTTONI - Mobile First ---------- */
.btn {
  padding: 0.75em 1.5em; /* RIDOTTO padding verticale */
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: 1.3em; /* MOLTO PIÙ GRANDE su mobile */
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  transition: var(--transition-normal);
  min-height: 3.2em; /* RIDOTTO */
  line-height: 1.3;
  width: 100%; /* Full width su mobile */
}

.btn-primary {
  background: var(--color-primary-light);
  color: var(--color-white);
}

.btn-primary:hover {
  background: var(--color-primary);
  transform: translateY(-0.125em);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--color-muted);
  color: var(--color-white);
}

.btn-secondary:hover {
  background: #545b62;
}

.btn-success {
  background: var(--color-success);
  color: var(--color-white);
}

.btn-success:hover {
  background: #218838;
}

.btn-warning {
  background: var(--color-warning);
  color: #212529;
}

.btn-warning:hover {
  background: #e0a800;
}

.btn-danger {
  background: var(--color-danger);
  color: var(--color-white);
}

.btn-danger:hover {
  background: #c82333;
}

.btn-info {
  background: var(--color-info);
  color: var(--color-white);
}

.btn-info:hover {
  background: #138496;
}

.btn-sm {
  padding: 0.5em 1em;
  font-size: 0.9em;
  min-height: 2.5em;
}

.btn:disabled, 
.btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Pulsanti stile legacy - Mobile First */
p.button,
p.button_select,
p.button_log {
  padding: 0.85em 1em; /* RIDOTTO padding verticale */
  width: 95%;
  margin: 0.5em auto; /* RIDOTTO margine */
  text-align: center;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4em; /* MOLTO PIÙ GRANDE su mobile */
  font-weight: normal;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-normal);
  border: 2px solid var(--color-primary-light);
  min-height: 3.5em; /* RIDOTTO */
  line-height: 1.4;
}

p.button {
  background-color: var(--color-white);
  color: var(--color-text-light);
}

p.button:hover {
  background-color: var(--color-primary-lighter);
  color: var(--color-white);
  font-weight: bold;
  box-shadow: var(--shadow-md);
  transform: translateY(-0.125em);
}

p.button_select {
  background-color: var(--color-primary-lighter);
  color: var(--color-primary);
  font-weight: bold;
}

p.button_log {
  background-color: var(--color-primary-lighter);
  color: var(--color-primary);
  width: auto;
  padding: 0.75em 1.5em;
}

p.button_log:hover {
  background-color: var(--color-primary-light);
  color: var(--color-white);
  font-weight: bold;
  box-shadow: var(--shadow-md);
  transform: translateY(-0.125em);
}

.submit-link {
  background-color: var(--color-primary);
  border: 2px solid var(--color-primary-light);
  color: var(--color-white);
  padding: 0.75em 2em; /* RIDOTTO padding verticale */
  font-size: 1.3em;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-normal);
  min-height: 3.2em; /* RIDOTTO */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.submit-link:hover {
  background-color: var(--color-primary-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-0.125em);
}

.submit-light {
  background-color: var(--color-white);
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-primary-light);
  color: var(--color-primary-light);
  padding: 0.7em 1.8em; /* RIDOTTO padding verticale */
  font-size: 1.2em;
  cursor: pointer;
  transition: var(--transition-normal);
  min-height: 3em; /* RIDOTTO */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.submit-light:hover {
  background-color: var(--color-primary-lightest);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-0.0625em);
}

/* ---------- MENU DINAMICO - Mobile First ---------- */
.menu-container {
  width: 100%;
  max-width: 100%;
  margin: 0.75em auto;
  padding: 0 0.5em;
  display: flex;
  flex-direction: column; /* SEMPRE colonna su mobile */
  gap: 0.75em; /* RIDOTTO gap tra pulsanti */
}

button.menu-btn,
.menu-btn {
  /* Reset completo button HTML */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  font-family: inherit;
  
  /* Stili personalizzati - MOBILE FIRST */
  background-color: var(--color-white);
  border: 3px solid var(--color-primary);
  color: var(--color-primary);
  padding: 0.6em 1em; /* ULTERIORMENTE RIDOTTO */
  font-size: 1.6em;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-normal);
  width: 100%;
  min-height: auto; /* Altezza automatica basata sul contenuto */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
  flex-grow: 0;
  box-sizing: border-box;
}

.menu-btn .menu-icons-wrapper {
  display: block;
  margin-bottom: 0.35em;
  line-height: 1.2;
  min-height: 1.5em;
}

.menu-btn .menu-icons-wrapper i,
.menu-btn > i[class*="fa-"] {
  display: inline-block !important;
  font-size: 0.95em;
  margin-right: 0.25em;
  vertical-align: middle;
  line-height: 1;
  font-style: normal;
}

.menu-btn strong {
  font-size: 1.3em;
  display: block;
  margin-bottom: 0.15em; /* RIDOTTO spazio tra titolo e sottotitolo */
  font-weight: bold;
  line-height: 1.2;
}

.menu-btn small {
  font-size: 0.7em;
  opacity: 0.85;
  font-weight: normal;
  line-height: 1.2;
  margin-top: 0; /* Nessuno spazio extra */
}

.menu-btn:hover,
.menu-btn:active {
  background-color: var(--color-primary);
  color: var(--color-white);
  box-shadow: var(--shadow-lg);
  transform: scale(1.02);
  border-color: var(--color-primary);
}

/* ---------- TABLES ---------- */
.table-container {
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  max-height: none; /* Altezza automatica */
  -webkit-overflow-scrolling: touch;
}

/* Classe stile-Bootstrap usata in molte pagine: senza overflow-x la tabella
   resta width:100% e su schermi stretti le colonne si comprimono (pulsanti fuori vista). */
.table-responsive {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-responsive > .table {
  width: max-content;
  min-width: 100%;
  box-sizing: border-box;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-white);
  font-size: 1em;
}

.table thead {
  position: sticky;
  top: 0;
  background: var(--color-background);
  z-index: 10;
}

.table th {
  padding: 0.9em 0.6em;
  text-align: left;
  font-weight: 600;
  color: var(--color-text);
  border-bottom: 2px solid var(--color-border);
  font-size: 0.95em;
  white-space: nowrap;
}

/* Intestazioni tabella centrate: singola colonna (th.text-center) o intera tabella (.table-head-center) */
.table th.text-center,
.table.table-head-center thead th {
  text-align: center;
}

.table td {
  padding: 0.8em 0.6em;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 0.95em;
  vertical-align: middle;
}

.table tbody tr:hover {
  background: var(--color-background);
}

.table-striped tbody tr:nth-child(even) {
  background: #f9f9f9;
}

/* Stili per stato attivo/inattivo */
.status-active {
  color: var(--color-success);
  font-size: 1.3em;
}

.status-inactive {
  color: var(--color-danger);
  font-size: 1.3em;
}

/* ---------- ALERTS E MESSAGGI ---------- */
.alert {
  padding: 1em;
  border-radius: var(--radius-md);
  margin-bottom: 1em;
  border-left: 4px solid;
  font-size: 1em;
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.alert-info {
  background: #d1ecf1;
  border-color: var(--color-info);
  color: #0c5460;
}

.alert-success {
  background: #d4edda;
  border-color: var(--color-success);
  color: #155724;
}

.alert-warning {
  background: #fff3cd;
  border-color: var(--color-warning);
  color: #856404;
}

.alert-danger {
  background: #f8d7da;
  border-color: var(--color-danger);
  color: #721c24;
}

.error-message {
  background: #ffe0e0;
  border: 1px solid #cc0000;
  color: #cc0000;
  padding: 1em;
  margin: 1em auto;
  border-radius: var(--radius-md);
  font-weight: bold;
}

.success-message {
  background: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
  padding: 1em;
  margin: 1em auto;
  border-radius: var(--radius-md);
  font-weight: bold;
}

.login-error {
  background: #ffe0e0;
  border: 1px solid #cc0000;
  padding: 1em;
  margin: 1.25em auto;
  width: 90%;
  max-width: 600px;
  color: #cc0000;
  font-weight: bold;
  border-radius: var(--radius-md);
}

.login-error a {
  color: var(--color-primary);
  text-decoration: none;
  border: 1px solid var(--color-primary-light);
  border-radius: var(--radius-sm);
  padding: 0.4em 0.75em;
  background: var(--color-white);
  margin: 0 0.4em;
  display: inline-block;
  transition: var(--transition-fast);
}

.login-error a:hover {
  background: var(--color-primary-lighter);
  color: var(--color-white);
}

/* ---------- BADGE ---------- */
.badge {
  padding: 0.3em 0.6em;
  border-radius: 1em;
  font-size: 0.85em;
  font-weight: 500;
  display: inline-block;
}

.badge-info {
  background: var(--color-info);
  color: var(--color-white);
}

/* ---------- FOOTER ---------- */
.footer-block {
  margin: 0;
  padding: 1em 0;
  background-color: var(--color-primary);
  color: #EEEEEE;
  text-align: center;
  margin-top: auto;
  flex-shrink: 0;
}

.footer-block a {
  color: #CCCCCC;
  text-decoration: none;
  transition: var(--transition-fast);
}

.footer-block a:hover {
  color: var(--color-white);
}

/* ---------- UTILITY CLASSES ---------- */
.mt-1 { margin-top: 0.5em; }
.mt-2 { margin-top: 1em; }
.mt-3 { margin-top: 1.5em; }
.mt-4 { margin-top: 2em; }

.mb-1 { margin-bottom: 0.5em; }
.mb-2 { margin-bottom: 1em; }
.mb-3 { margin-bottom: 1.5em; }

.hidden { display: none; }
.visible { display: block; }

/* ============================================
   MEDIA QUERIES - TABLET E DESKTOP
   Prima TABLET/DESKTOP, poi SMARTPHONE con !important
   ============================================ */

/* ---------- TABLET: 768px-1023px ---------- */
@media (min-width: 768px) {
  .container {
    padding: 1.5em;
  }
  
  .main-content {
    padding: 0 1.5em 1.5em 1.5em; /* padding-top: 0 per ridurre spazio totale */
  }
  
  .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25em;
  }
  
  /* Menu passa a GRID solo su tablet landscape/desktop */
  .menu-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 colonne su tablet */
    gap: 1.2em;
    padding: 0 1em;
    max-width: 800px;
  }
  
  .menu-btn {
    font-size: 1.15em; /* Ancora grande */
    padding: 1.5em;
    min-height: 4.2em;
  }
  
  p.button,
  p.button_select {
    font-size: 1.15em;
    min-height: 3.5em;
    width: 80%;
  }
  
  .login-error {
    width: 70%;
  }
  
  .btn {
    width: auto; /* Non più full-width */
    font-size: 1em;
    min-height: 3em;
  }
  
  .form-actions {
    flex-direction: row;
  }
  
  .form-control {
    font-size: 1em;
    min-height: 3em;
    padding: 0.85em 1em;
  }
  
  .nav-bar {
    flex-direction: row;
    padding: 0 1em;
  }
  
  /* TESTI: riduzione progressiva su tablet */
  .testi {
    font-size: 1.05em;
  }
  
  p.c3 {
    font-size: 1.8em;
  }
  
  /* Mostra colonna azienda su tablet/desktop */
  .table th:nth-child(1),
  .table td:nth-child(1) {
    display: table-cell !important;
  }
  
  /* Mostra colonna permesso su tablet/desktop */
  .table th:nth-child(5),
  .table td:nth-child(5) {
    display: table-cell !important;
  }
}


/* ---------- DESKTOP: 1024px+ ---------- */
@media (min-width: 1024px) {
  .container {
    padding: 2em;
  }
  
  .menu-container {
    grid-template-columns: repeat(3, 1fr); /* 3 colonne su desktop */
    gap: 1.25em;
    max-width: 1100px;
  }
  
  .menu-btn {
    font-size: 0.95em; /* PIÙ PICCOLO su desktop */
    padding: 1em;
    min-height: 3em;
    border: 2px solid var(--color-primary);
  }
  
  .menu-btn strong {
    font-size: 1.1em;
  }
  
  .menu-btn small {
    font-size: 0.75em;
  }
  
  p.button,
  p.button_select {
    width: 70%; /* Più stretto su desktop */
    font-size: 1em;
    min-height: 2.8em;
  }
  
  p.button_log {
    font-size: 0.95em;
    padding: 0.75em 1.5em;
  }
  
  .submit-link {
    font-size: 1em;
    min-height: 2.8em;
    padding: 0.8em 1.5em;
  }
  
  .submit-light {
    font-size: 0.95em;
    min-height: 2.8em;
    padding: 0.75em 1.5em;
  }
  
  .form-grid {
    gap: 1.5em;
  }
  
  .btn {
    font-size: 0.95em; /* Ancora più piccolo su desktop */
    padding: 0.75em 1.5em;
    min-height: 2.75em;
  }
  
  .form-control {
    font-size: 0.95em;
    min-height: 2.75em;
    padding: 0.75em 0.95em;
    border: 1px solid var(--color-border); /* Bordo più sottile */
  }
  
  p.c2 {
    font-size: 1.5em; /* Più piccolo su desktop */
  }
  
  p.c3 {
    font-size: 1.5em;
  }
  
  h2.c1 {
    font-size: 2em; /* Più piccolo su desktop */
  }
  
  .testi {
    font-size: 0.95em; /* PIÙ PICCOLO su desktop */
  }
}

/* ---------- LARGE DESKTOP: 1200px+ ---------- */
@media (min-width: 1200px) {
  .container {
    max-width: 1200px;
  }
  
  .menu-container {
    max-width: 1100px;
  }
}

/* ============================================
   STAMPA
   ============================================ */
@media print {
  .header-image,
  .nav-bar,
  .footer-block,
  .btn,
  .form-actions {
    display: none;
  }
  
  .main-content {
    padding: 0;
  }
  
  .card {
    box-shadow: none;
    border: 1px solid var(--color-border);
    page-break-inside: avoid;
  }
  
  body {
    font-size: 12pt;
  }
}

/* ============================================
   DEVICE TOUCH (tablets e smartphones)
   ============================================ */
@media (hover: none) and (pointer: coarse) {
  /* Aumenta area touch su dispositivi touch */
  .btn {
    min-height: var(--touch-target-large);
  }
  
  .form-control {
    min-height: var(--touch-target-large);
  }
  
  .menu-btn {
    min-height: 4em;
  }
  
  /* Menu dropdown deve funzionare con tap */
  .user-menu-dropdown {
    display: none;
  }
  
  .user-menu.active .user-menu-dropdown {
    display: block;
  }
}

/* ============================================
   SMARTPHONE OVERRIDE - MASSIMA PRIORITÀ
   Questa regola DEVE essere l'ultima!
   ============================================ */
@media only screen and (max-width: 767px) {
  /* FORZA layout verticale su TUTTI gli smartphone */
  .menu-container {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 0.75em !important;
  }
  
  .menu-btn {
    font-size: 1.5em !important;
    min-height: 5.5em !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 1.8em 1em !important;
  }
  
  .menu-btn strong {
    font-size: 1.25em !important;
  }
  
  .menu-btn small {
    font-size: 0.8em !important;
  }
  
  .btn {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 1.2em !important;
    min-height: 3.8em !important;
  }
  
  .form-control {
    font-size: 1.15em !important;
    min-height: 3.8em !important;
  }
}

/* ============================================
   SMARTPHONE ULTRA-PRIORITY
   Cattura TUTTI gli smartphone indipendentemente
   da orientamento, risoluzione, ecc.
   ============================================ */
@media only screen and (max-width: 767px),
       only screen and (max-device-width: 767px) {
  
  /* FONT-SIZE BASE: GRANDE */
  html {
    font-size: 22px !important;
  }
  
  body {
    font-size: 1rem !important;
  }
  
  /* LAYOUT MENU: 1 colonna SEMPRE */
  .menu-container {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 0.75em !important;
    gap: 0.75em !important; /* RIDOTTO gap */
    margin: 0.5em auto !important; /* RIDOTTO margine */
  }
  
  /* BOTTONI MENU: ENORMI */
  .menu-btn {
    font-size: 1.6em !important;
    min-height: auto !important; /* Altezza automatica */
    width: 100% !important;
    max-width: 100% !important;
    padding: 0.6em 1em !important; /* COMPATTO */
    flex: 0 0 auto !important;
    line-height: 1.2 !important;
  }
  
  .menu-btn strong {
    font-size: 1.3em !important;
    margin-bottom: 0.15em !important; /* MINIMO spazio */
    line-height: 1.2 !important;
  }
  
  .menu-btn small {
    font-size: 0.7em !important;
    line-height: 1.2 !important;
    margin-top: 0 !important;
  }
  
  /* BOTTONI GENERICI: full-width */
  .btn {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 1.3em !important;
    min-height: 3.2em !important; /* RIDOTTO */
    padding: 0.75em 1.5em !important; /* RIDOTTO */
  }
  
  /* SUBMIT BUTTONS: grandi */
  .submit-link {
    font-size: 1.3em !important;
    min-height: 3.2em !important; /* RIDOTTO */
    padding: 0.75em 2em !important; /* RIDOTTO */
  }
  
  .submit-light {
    font-size: 1.2em !important;
    min-height: 3em !important; /* RIDOTTO */
    padding: 0.7em 1.8em !important; /* RIDOTTO */
  }
  
  p.button,
  p.button_select,
  p.button_log {
    font-size: 1.4em !important;
    min-height: 3.5em !important; /* RIDOTTO */
    padding: 0.85em 1em !important; /* RIDOTTO */
  }
  
  /* INPUT: grandi */
  .form-control {
    font-size: 1.1em !important;
    min-height: 3.5em !important;
  }
  
  /* FORM ACTIONS: verticale */
  .form-actions {
    flex-direction: column !important;
    gap: 0.75em !important;
  }
  
  /* TITOLI: grandi e leggibili su SMARTPHONE */
  p.c2 {
    font-size: 1.6em !important;
  }
  
  p.c3 {
    font-size: 1.2em !important;
  }
  
  .testi {
    font-size: 1.15em !important;
  }
  
  .cantiere-title {
    font-size: 1.5em !important;
  }
  
  .page-title {
    font-size: 1.2em !important;
  }
  
  .card-header h2, 
  .card-header h3 {
    font-size: 1.3em !important;
  }
  
  /* TABELLE: compatte su smartphone */
  .table {
    font-size: 0.9em !important;
  }
  
  .table th,
  .table td {
    padding: 0.5em 0.3em !important;
    font-size: 1em !important;
    vertical-align: middle !important;
  }
  
  /* Nascondi colonna azienda su smartphone */
  .table th:nth-child(1),
  .table td:nth-child(1) {
    display: none !important;
  }
  
  /* Nascondi colonna permesso su smartphone molto piccolo */
  .table th:nth-child(5),
  .table td:nth-child(5) {
    display: none !important;
  }
  
  /* Bottoni tabella compatti */
  .btn-sm {
    font-size: 0.95em !important;
    padding: 0.5em 0.7em !important;
    min-height: 2.5em !important;
  }
  
  .btn-sm i {
    margin-right: 0.2em;
  }
}

/* Stili per visualizzazione compatta anagrafica - Box */
.info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  margin-bottom: 1em;
}

.info-item {
  padding: 0.8em;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.375em;
  border-left: 4px solid #007bff;
  flex: 1;
  min-width: 0;
}

.info-item.full-width {
  flex-basis: 100%;
}

.info-item.half-width {
  flex-basis: calc(50% - 0.5em);
}

.info-item.address {
  flex-basis: 100%;
}

.info-item.cap {
  flex-basis: calc(30% - 0.5em);
}

.info-item.city {
  flex-basis: calc(40% - 0.5em);
}

.info-item.province {
  flex-basis: calc(30% - 0.5em);
}

.info-item label {
  font-weight: bold;
  color: #495057;
  margin-right: 0.5em;
  font-size: 0.9em;
}

.info-item span {
  color: #212529;
}

.info-item a {
  color: #007bff;
  text-decoration: none;
}

.info-item a:hover {
  text-decoration: underline;
}

/* Responsive per info-row */
@media (max-width: 768px) {
  .info-item.half-width,
  .info-item.cap,
  .info-item.city,
  .info-item.province {
    flex-basis: 100%;
  }
  
  .info-item {
    padding: 0.6em;
  }
}

/* =====================================================
   MENU IMPOSTAZIONI - Stili specifici
   ===================================================== */

/* Override colore per pulsanti menu impostazioni - Grigio molto chiaro */
.menu-impostazioni-btn {
  background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

.menu-impostazioni-btn:hover,
.menu-impostazioni-btn:active {
  background: var(--color-primary) !important;
  color: var(--color-white);
  box-shadow: var(--shadow-lg);
  transform: scale(1.02);
  border-color: var(--color-primary);
}

/* Voci con URL menu_*.php (sottomenu / hub annidato) — sfondo lavanda + bordo primario */
button.menu-btn.menu-hub-btn,
.menu-btn.menu-hub-btn {
  background: linear-gradient(
    145deg,
    var(--color-primary-lightest) 0%,
    #eadcf8 55%,
    var(--color-primary-lighter) 160%
  );
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: 0 0.2em 0.55em rgba(101, 57, 136, 0.22);
}

.menu-btn.menu-hub-btn:hover,
.menu-btn.menu-hub-btn:active,
button.menu-btn.menu-hub-btn:hover,
button.menu-btn.menu-hub-btn:active {
  background: var(--color-primary) !important;
  color: var(--color-white) !important;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-lg);
  transform: scale(1.02);
}

/* Badge livello utente */
.user-level-badge {
  display: inline-block;
  background: #28a745;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9em;
  margin-bottom: 2rem;
}

/* Link ritorno */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #6c757d;
  text-decoration: none;
  margin-bottom: 2rem;
  transition: color 0.3s;
}

.back-link:hover {
  color: #343a40;
}

