@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

/* --- CUSTOM VARIABLES & DESIGN SYSTEM --- */
:root {
  --font-main: 'Inter', sans-serif;
  --font-display: 'Outfit', sans-serif;
  
  /* Color Palette (Dark Theme by Default for Premium Tech Feel) */
  --bg-main: #0b1329;
  --bg-card: #1c2541;
  --bg-sidebar: #0f172a;
  --bg-input: #151d35;
  --border-color: rgba(255, 255, 255, 0.08);
  
  --primary: #0284c7;
  --primary-glow: rgba(2, 132, 199, 0.4);
  --primary-hover: #0369a1;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-on-primary: #ffffff;
  
  /* Curated UNI EN 15635 Damage Level Colors */
  --status-verde-bg: rgba(16, 185, 129, 0.15);
  --status-verde-border: #10b981;
  --status-verde-text: #34d399;
  
  --status-giallo-bg: rgba(245, 158, 11, 0.15);
  --status-giallo-border: #f59e0b;
  --status-giallo-text: #fbbf24;
  
  --status-rosso-bg: rgba(239, 68, 68, 0.15);
  --status-rosso-border: #ef4444;
  --status-rosso-text: #f87171;
  
  --status-nonconforme-bg: rgba(139, 92, 246, 0.15);
  --status-nonconforme-border: #8b5cf6;
  --status-nonconforme-text: #a78bfa;

  --status-chiuso-bg: rgba(148, 163, 184, 0.15);
  --status-chiuso-border: #94a3b8;
  --status-chiuso-text: #cbd5e1;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  
  --border-radius: 12px;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

/* --- APP LAYOUT --- */
#app-container {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  position: relative;
}

/* Navigation Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.logo-icon {
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--primary-glow);
}

.logo-icon i {
  color: var(--text-on-primary);
  font-size: 20px;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-subtext {
  font-size: 10px;
  color: var(--primary);
  font-weight: 600;
  display: block;
  margin-top: -2px;
  letter-spacing: 1px;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--border-radius);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
  background-color: rgba(2, 132, 199, 0.1);
  color: var(--text-main);
  border-left: 3px solid var(--primary);
  padding-left: 13px;
}

.nav-link i {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.user-profile-section {
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
  margin-top: auto;
}

.user-info-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.user-name {
  font-weight: 600;
  font-size: 14px;
}

.user-role {
  font-size: 11px;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.user-company {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-logout {
  width: 100%;
  padding: 8px 12px;
  background-color: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.btn-logout:hover {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
}

/* Header bar */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.page-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.5px;
}

/* Connection / Sync Status Indicator */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 16px;
  background-color: var(--bg-card);
  padding: 8px 16px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
  font-size: 13px;
}

.conn-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot.online {
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.dot.offline {
  background-color: #94a3b8;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.sync-status.pending {
  color: var(--status-giallo-text);
  font-weight: 600;
}

.btn-sync {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 50%;
  transition: background var(--transition-fast);
}

.btn-sync:hover {
  background-color: rgba(2, 132, 199, 0.1);
}

.btn-sync.spinning i {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* --- LOGIN SCREEN (FULL PAGE OVERLAY) --- */
#login-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 100%;
  max-width: 440px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.login-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  text-align: center;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  margin-top: -12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: var(--border-radius);
  color: var(--text-main);
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: var(--text-on-primary);
  border: none;
  padding: 14px;
  border-radius: var(--border-radius);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.4);
}

.btn-primary:active {
  transform: translateY(1px);
}

.login-error {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--status-rosso-border);
  color: var(--status-rosso-text);
  padding: 12px;
  border-radius: var(--border-radius);
  font-size: 13px;
  text-align: center;
  display: none;
}

/* --- DASHBOARD / STATS CARDS --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.stat-card.primary::before { background-color: var(--primary); }
.stat-card.verde::before { background-color: var(--status-verde-border); }
.stat-card.giallo::before { background-color: var(--status-giallo-border); }
.stat-card.rosso::before { 
  background-color: var(--status-rosso-border); 
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-val {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
}

/* --- SECTIONS / SPA VIEWS --- */
.app-view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.app-view.active {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- LIST TABLES & CARDS --- */
.data-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
}

.btn-action {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--text-muted);
}

/* Grid of Cards (es: Aziende, Magazzini) */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.item-card {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.15);
}

.item-card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
}

.item-card-detail {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.item-card-badge {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 20px;
  text-transform: uppercase;
}

/* --- DAMAGE CARDS & BADGES --- */
.damage-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.damage-card {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px;
  display: grid;
  grid-template-columns: 100px 1fr 180px;
  gap: 20px;
  align-items: center;
  transition: transform var(--transition-fast);
}

.damage-card:hover {
  transform: scale(1.005);
}

.damage-photo-placeholder {
  width: 100px;
  height: 100px;
  border-radius: 8px;
  background-color: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-color);
}

.damage-photo-img {
  width: 100px;
  height: 100px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-color);
}

.damage-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.damage-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.damage-location {
  font-weight: 600;
  font-size: 15px;
}

.damage-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.damage-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.damage-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.badge-status {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
}

.badge-status.verde {
  background-color: var(--status-verde-bg);
  border-color: var(--status-verde-border);
  color: var(--status-verde-text);
}

.badge-status.giallo {
  background-color: var(--status-giallo-bg);
  border-color: var(--status-giallo-border);
  color: var(--status-giallo-text);
}

.badge-status.rosso {
  background-color: var(--status-rosso-bg);
  border-color: var(--status-rosso-border);
  color: var(--status-rosso-text);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.badge-status.nonconforme {
  background-color: var(--status-nonconforme-bg);
  border-color: var(--status-nonconforme-border);
  color: var(--status-nonconforme-text);
}

.badge-status.chiuso {
  background-color: var(--status-chiuso-bg);
  border-color: var(--status-chiuso-border);
  color: var(--status-chiuso-text);
}

.badge-offline-tag {
  background-color: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--status-giallo-border);
  color: var(--status-giallo-text);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

/* --- MODAL POPUPS --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(11, 19, 41, 0.85);
  backdrop-filter: blur(5px);
  z-index: 100001;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-container {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 100%;
  max-width: 680px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScale {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 20px 24px;
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Compatta e forza in colonna tutti i campi nei form dei modal */
.modal-body .form-group {
  margin-bottom: 6px !important;
}

.modal-body .form-input {
  padding: 8px 12px !important;
  font-size: 13.5px !important;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-secondary {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 10px 20px;
  border-radius: var(--border-radius);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

/* --- PHOTO CAPTURE / PREVIEW IN MODAL --- */
.photo-picker-box {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius);
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  text-align: center;
  background-color: var(--bg-input);
  transition: border-color var(--transition-fast);
}

.photo-picker-box:hover {
  border-color: var(--primary);
}

.photo-picker-box i {
  font-size: 32px;
  color: var(--text-muted);
}

.photo-preview-container {
  display: none;
  position: relative;
  width: 100%;
  max-height: 250px;
  border-radius: var(--border-radius);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.photo-preview-img {
  width: 100%;
  height: 250px;
  object-fit: cover;
}

.btn-remove-photo {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* Responsive Table */
.responsive-table-container {
  overflow-x: auto;
  margin-top: 10px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th, .data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 13px;
  background-color: rgba(255, 255, 255, 0.02);
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Compact Table */
.data-table.compact-table th, .data-table.compact-table td {
  padding: 6px 12px !important;
  font-size: 13px;
}
.data-table.compact-table .btn-action {
  padding: 3px 6px !important;
  font-size: 11px;
}

/* Substantial Modification Box */
.substantial-mod-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
  grid-column: span 2;
  padding: 12px 16px;
  border: 1px dashed var(--primary);
  border-radius: 6px;
  background: rgba(224, 86, 36, 0.08);
}
.substantial-mod-box input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.substantial-mod-box label {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  margin: 0;
}

/* --- MOBILE RESPONSIVE STYLES --- */
.mobile-top-actions,
.mobile-bottom-nav,
.mobile-drawer-overlay,
#mobile-user-drawer {
  display: none !important;
}

@media (max-width: 900px) {
  .mobile-top-actions {
    display: flex !important;
  }
  #app-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 16px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: 54px;
    background: var(--bg-sidebar);
    position: sticky;
    top: 0;
    z-index: 300;
  }
  
  .logo-container {
    margin-bottom: 0;
    gap: 8px;
  }

  .logo-container .logo-text {
    font-size: 14px;
    font-weight: 700;
  }

  .logo-container .logo-subtext {
    font-size: 9px;
  }

  .nav-links {
    display: none !important;
  }

  .desktop-profile-section {
    display: none !important;
  }

  .mobile-top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .mobile-sync-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    font-size: 11px;
    cursor: pointer;
    color: var(--text-muted);
  }

  .btn-mobile-menu-trigger {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.2) 0%, rgba(3, 105, 161, 0.3) 100%);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #38bdf8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    cursor: pointer;
    transition: transform 0.15s ease;
  }
  .btn-mobile-menu-trigger:active {
    transform: scale(0.92);
  }

  .main-content {
    padding: 12px 14px;
    height: calc(100vh - 54px);
    padding-bottom: 85px; /* Spazio per la bottom nav fissa */
    overflow-y: auto;
  }

  .top-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
  }

  /* Bottom Navigation Bar for Mobile */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 62px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    justify-content: space-around;
    align-items: center;
    padding: 4px 6px;
    z-index: 500;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
  }

  .mobile-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 10px;
    transition: all 0.2s ease;
    flex: 1;
    text-align: center;
  }

  .mobile-nav-link i {
    font-size: 18px;
    transition: transform 0.2s ease;
  }

  .mobile-nav-link.active {
    color: var(--primary);
    background: rgba(2, 132, 199, 0.12);
  }

  .mobile-nav-link.active i {
    transform: translateY(-2px);
  }

  /* Mobile Drawer Overlay and Content */
  .mobile-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
    animation: fadeInOverlay 0.2s ease forwards;
  }

  .mobile-drawer-content {
    width: 85%;
    max-width: 340px;
    height: 100%;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 25px rgba(0, 0, 0, 0.5);
    animation: slideInDrawer 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .mobile-drawer-header {
    padding: 18px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.6);
  }

  .drawer-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .drawer-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(2, 132, 199, 0.2);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: #38bdf8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
  }

  .drawer-user-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .drawer-user-role {
    font-size: 11px;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .drawer-user-company {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .drawer-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 26px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
  }

  .mobile-drawer-body {
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .drawer-conn-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 10px;
  }

  .drawer-actions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .drawer-btn {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(30, 41, 59, 0.4);
    color: var(--text-main);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
  }

  .drawer-btn:active {
    background: rgba(2, 132, 199, 0.15);
    border-color: var(--primary);
  }

  .drawer-btn-primary {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    border-color: #0284c7;
    color: #ffffff;
    font-weight: 600;
  }

  .drawer-btn-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fbbf24;
  }

  .drawer-btn-danger {
    background: rgba(244, 63, 94, 0.1);
    border-color: rgba(244, 63, 94, 0.3);
    color: #fda4af;
  }

  .damage-card {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .damage-photo-placeholder, .damage-photo-img {
    width: 100%;
    height: 150px;
  }

  .damage-actions {
    align-items: flex-start;
    width: 100%;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
  }

  /* Adattamento Modale Form per Dispositivi Mobili / Telefoni */
  .modal-container {
    max-width: 95vw !important;
    border-radius: 12px !important;
  }
}

@keyframes slideInDrawer {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

  .modal-body {
    padding: 16px !important;
    max-height: 80vh !important;
  }

  .modal-body div[style*="display:grid"],
  .modal-body div[style*="display: grid"] {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .modal-body div[style*="grid-column: span 2"] {
    grid-column: span 1 !important;
  }
}

/* Fallback hidden style for bottom nav on desktop */
.mobile-bottom-nav {
  display: none;
}

/* --- ADDIZIONALI DASHBOARD PER RUOLO --- */
.progress-container {
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  height: 10px;
  width: 100%;
  overflow: hidden;
  position: relative;
  margin: 6px 0;
}

.progress-bar {
  background: linear-gradient(90deg, var(--primary), #3b82f6);
  height: 100%;
  border-radius: 6px;
  transition: width var(--transition-normal);
}

.progress-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.dashboard-section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--primary);
  margin-top: 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
}

.dashboard-meta-info {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.compliance-status-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background-color: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

/* --- STYLES FOR PUBLIC ANONYMOUS REPORT --- */
#public-report-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 10% 20%, rgb(15, 23, 42) 0%, rgb(9, 13, 26) 90.1%);
  overflow-y: auto;
  z-index: 10000;
  box-sizing: border-box;
}

.public-report-card {
  width: 100%;
  max-width: 550px;
  background: rgba(28, 37, 65, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 32px 24px;
  box-shadow: var(--shadow-lg);
  margin: 40px auto;
}

.pub-description {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.6;
}

.form-row.flex-row {
  display: flex;
  gap: 16px;
  width: 100%;
}

.flex-1 {
  flex: 1;
}

/* Damage Slider Custom Styles */
.damage-slider-container {
  margin-top: 10px;
  margin-bottom: 10px;
}

.damage-slider {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.damage-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 0 10px var(--primary-glow);
  transition: transform var(--transition-fast);
}

.damage-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.damage-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* QR Code Modal Styles */
.qr-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px;
}

.qr-code-img {
  background: white;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  max-width: 220px;
  max-height: 220px;
}

.qr-info-text {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* UI Lists / Badges for Segnalazioni */
.segnalazione-card {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 16px;
  margin-bottom: 16px;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.segnalazione-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.segnalazione-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.segnalazione-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.segnalazione-date {
  font-size: 12px;
  color: var(--text-muted);
}

.segnalazione-pos {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--text-main);
}

.segnalazione-badges {
  display: flex;
  gap: 8px;
}

.badge-urgente {
  background-color: var(--status-rosso-bg);
  border: 1px solid var(--status-rosso-border);
  color: var(--status-rosso-text);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-stato {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.badge-stato.pendente {
  background-color: var(--status-giallo-bg);
  border: 1px solid var(--status-giallo-border);
  color: var(--status-giallo-text);
}

.badge-stato.visionata {
  background-color: var(--status-verde-bg);
  border: 1px solid var(--status-verde-border);
  color: var(--status-verde-text);
}

.badge-stato.archiviata {
  background-color: var(--status-chiuso-bg);
  border: 1px solid var(--status-chiuso-border);
  color: var(--status-chiuso-text);
}

.segnalazione-body {
  font-size: 14px;
  color: var(--text-main);
  background-color: rgba(0, 0, 0, 0.15);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.segnalazione-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* --- PRINT RULES --- */
@media print {
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .sidebar, .top-header, .btn-action, button, input, select, textarea, .modal-overlay {
    display: none !important;
  }
  .main-content {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }
  .data-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
}


/* ============================================================
   ZONA CARD — Premium Glassmorphism Style
   Usato nella vista Magazzino (colonna destra griglia zone)
   ============================================================ */

.zona-card {
  position: relative;
  background: linear-gradient(145deg, rgba(28, 37, 65, 0.85) 0%, rgba(15, 23, 42, 0.95) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 18px 16px 14px;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease,
              border-color 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

/* Linea decorativa superiore rimossa per layout solo bordo sinistro marcato */
.zona-card::before {
  display: none;
}

/* Alone luminoso in basso a destra */
.zona-card::after {
  content: '';
  position: absolute;
  bottom: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--zona-color, var(--primary));
  opacity: 0.06;
  filter: blur(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.zona-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45),
              0 0 0 1px var(--zona-color, var(--primary)),
              0 0 20px -4px var(--zona-color, var(--primary));
  border-color: var(--zona-color, var(--primary));
}

.zona-card:hover::after {
  opacity: 0.14;
  transform: scale(1.5);
}

.zona-card:active {
  transform: translateY(-1px) scale(0.99);
}

/* Header della card: nome zona + pulsante modifica */
.zona-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.zona-card-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--text-main);
  line-height: 1.2;
  flex: 1;
}

.zona-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--zona-color, var(--primary));
  box-shadow: 0 0 6px var(--zona-color, var(--primary));
}

.zona-readonly-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  white-space: nowrap;
}

.zona-card .zona-edit-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
  z-index: 10;
  position: relative;
}

.zona-card:hover .zona-edit-btn {
  background: rgba(2, 132, 199, 0.15);
  border-color: var(--primary);
  color: var(--primary);
}

.zona-card-prses {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.zona-card-prses i {
  color: var(--primary);
  opacity: 0.7;
  font-size: 11px;
}

/* Stats row: filari e danni */
.zona-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.zona-stat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.zona-stat-pill i {
  font-size: 10px;
  opacity: 0.7;
}

.zona-stat-pill span {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-main);
}

/* Badge stato danni */
.zona-status-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  width: 100%;
  box-sizing: border-box;
  letter-spacing: 0.03em;
  transition: box-shadow 0.25s ease;
}

.zona-card:hover .zona-status-badge {
  box-shadow: 0 0 12px -2px var(--zona-color, var(--primary));
}

/* Titolo colonna zone (header) */
.zona-col-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.zona-col-header-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.35);
  flex-shrink: 0;
}

.zona-col-header-icon i {
  font-size: 14px;
  color: white;
}

.zona-col-header-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-main);
}

.zona-col-header-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(2, 132, 199, 0.12);
  border: 1px solid rgba(2, 132, 199, 0.3);
  color: var(--primary);
}

@keyframes zonaCardIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.zona-card {
  animation: zonaCardIn 0.35s ease both;
}

.zona-card:nth-child(1)  { animation-delay: 0.04s; }
.zona-card:nth-child(2)  { animation-delay: 0.08s; }
.zona-card:nth-child(3)  { animation-delay: 0.12s; }
.zona-card:nth-child(4)  { animation-delay: 0.16s; }
.zona-card:nth-child(5)  { animation-delay: 0.20s; }
.zona-card:nth-child(6)  { animation-delay: 0.24s; }
.zona-card:nth-child(7)  { animation-delay: 0.28s; }
.zona-card:nth-child(8)  { animation-delay: 0.32s; }
