/* ═══════════════════════════════════════════════════════════
   GESTIONALE AEROPORTO DEI MARMI – Stile Principale
   ═══════════════════════════════════════════════════════════ */

:root {
  --primary:      #0d4f8c;
  --primary-dark: #083a69;
  --primary-light:#1a6bb0;
  --accent:       #f0a500;
  --accent-dark:  #d4920a;
  --success:      #28a745;
  --danger:       #dc3545;
  --warning:      #ffc107;
  --info:         #17a2b8;
  --dark:         #1e2530;
  --sidebar-bg:   #1e2530;
  --sidebar-width:260px;
  --topbar-h:     58px;
  --text:         #2c3e50;
  --text-muted:   #6c757d;
  --border:       #dee2e6;
  --bg:           #f4f6fa;
  --card-bg:      #ffffff;
  --radius:       8px;
  --shadow:       0 2px 8px rgba(0,0,0,.10);
  --shadow-md:    0 4px 16px rgba(0,0,0,.15);
  --transition:   0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }

/* ── Utility ────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex   { display: flex; }
.gap-1  { gap: .5rem; }
.gap-2  { gap: 1rem; }
.mt-1   { margin-top: .5rem; }
.mt-2   { margin-top: 1rem; }
.mb-2   { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.font-bold  { font-weight: 600; }
.w-100  { width: 100%; }
.pointer { cursor: pointer; }

/* ── Badges / Status ────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.badge-success  { background:#d4edda; color:#155724; }
.badge-danger   { background:#f8d7da; color:#721c24; }
.badge-warning  { background:#fff3cd; color:#856404; }
.badge-info     { background:#d1ecf1; color:#0c5460; }
.badge-primary  { background:#cce5ff; color:#004085; }
.badge-secondary{ background:#e2e3e5; color:#383d41; }

/* ── Alerts ─────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 13px; }
.alert-danger   { background:#f8d7da; color:#721c24; border:1px solid #f5c6cb; }
.alert-success  { background:#d4edda; color:#155724; border:1px solid #c3e6cb; }
.alert-warning  { background:#fff3cd; color:#856404; border:1px solid #ffeeba; }
.alert-info     { background:#d1ecf1; color:#0c5460; border:1px solid #bee5eb; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border: none; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all var(--transition); text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent    { background: var(--accent); color: #fff; }
.btn-accent:hover  { background: var(--accent-dark); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #218838; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #c82333; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5a6268; }
.btn-outline   { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm  { padding: 4px 10px; font-size: 12px; }
.btn-lg  { padding: 10px 22px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 6px 10px; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: .9rem; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.form-control {
  width: 100%; padding: 8px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 14px; color: var(--text); background: #fff;
  transition: border-color var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,79,140,.12); }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; gap: 1rem; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.input-with-icon { position: relative; }
.input-with-icon .form-control { padding-right: 40px; }
.toggle-pwd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text-muted); }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
  padding: .9rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 14px;
}
.card-body { padding: 1.2rem; }
.card-footer { padding: .9rem 1.2rem; border-top: 1px solid var(--border); background: #fafafa; }

/* ── Tables ─────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.table th {
  padding: 10px 12px; text-align: left;
  background: #f8f9fa; border-bottom: 2px solid var(--border);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted);
  white-space: nowrap;
}
.table td {
  padding: 10px 12px; border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.table tbody tr:hover { background: #f8fbff; }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Login ──────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  padding: 1rem;
}
.login-box {
  background: #fff; border-radius: 16px;
  padding: 2.5rem 2rem; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  text-align: center;
}
.login-logo { font-size: 3rem; color: var(--primary); margin-bottom: 1rem; }
.login-box h1 { font-size: 1.5rem; color: var(--primary-dark); margin-bottom: .2rem; }
.login-subtitle { color: var(--text-muted); font-size: 12px; margin-bottom: 2rem; }
.login-box .form-group { text-align: left; }
.login-footer { margin-top: 1.5rem; font-size: 11px; color: var(--text-muted); }

/* ── Layout App ─────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width); background: var(--sidebar-bg); color: #fff;
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: transform var(--transition);
  z-index: 200;
}
.sidebar-header {
  padding: 1rem; display: flex; align-items: center; gap: .75rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: var(--topbar-h);
}
.sidebar-logo-icon { font-size: 1.6rem; color: var(--accent); flex-shrink: 0; }
.sidebar-title { flex: 1; }
.sidebar-title-main { display: block; font-size: 13px; font-weight: 700; }
.sidebar-title-sub  { display: block; font-size: 11px; color: rgba(255,255,255,.5); }
.sidebar-close-btn  { display: none; background: none; border: none; color: #fff; cursor: pointer; font-size: 1.1rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .5rem 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.nav-section {
  padding: .6rem 1rem .3rem; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,.35);
}
.nav-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1.2rem; color: rgba(255,255,255,.75); text-decoration: none;
  font-size: 13.5px; transition: all var(--transition); border-left: 3px solid transparent;
}
.nav-item:hover  { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.1); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.nav-item i { width: 18px; text-align: center; font-size: 14px; }

.sidebar-user {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem; border-top: 1px solid rgba(255,255,255,.08);
}
.user-avatar { font-size: 1.8rem; color: rgba(255,255,255,.5); }
.user-info { flex: 1; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: rgba(255,255,255,.45); text-transform: uppercase; }
.btn-logout { background: none; border: none; color: rgba(255,255,255,.5); cursor: pointer; font-size: 1rem; padding: 6px; border-radius: 6px; transition: all var(--transition); }
.btn-logout:hover { color: var(--danger); background: rgba(220,53,69,.15); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 199; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem; padding: 0 1.2rem;
  position: sticky; top: 0; z-index: 100; box-shadow: 0 1px 4px rgba(0,0,0,.06);
  flex-shrink: 0;
}
.topbar-menu-btn { display: none; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text); padding: 4px 8px; }
.topbar-breadcrumb { font-size: 16px; font-weight: 700; color: var(--primary-dark); flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.cisterne-status { display: flex; gap: .4rem; }
.cisterne-badge {
  padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 600;
  background: #f0f4ff; color: var(--primary); cursor: default;
}
.cisterne-badge.low  { background: #fff3cd; color: #856404; }
.cisterne-badge.critical { background: #f8d7da; color: #721c24; }
.current-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ── Main / Page Content ────────────────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.page-content { flex: 1; overflow-y: auto; padding: 1.5rem; }
.page-content::-webkit-scrollbar { width: 6px; }
.page-content::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* ── Page Header ────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem;
}
.page-header h2 { font-size: 1.3rem; color: var(--primary-dark); display: flex; align-items: center; gap: .5rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Stats Cards ────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: #fff; border-radius: var(--radius); padding: 1.2rem;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 1rem;
}
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-icon.blue   { background: #e3f0ff; color: var(--primary); }
.stat-icon.green  { background: #d4edda; color: var(--success); }
.stat-icon.orange { background: #fff3cd; color: var(--accent); }
.stat-icon.red    { background: #f8d7da; color: var(--danger); }
.stat-icon.purple { background: #e8d5f5; color: #6f42c1; }
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 3px; text-transform: uppercase; letter-spacing: .5px; }

/* ── Progress Bar (cisterne) ────────────────────────────── */
.progress-bar-wrap { width: 100%; background: #e9ecef; border-radius: 10px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 10px; transition: width .5s ease; }
.progress-bar.high    { background: var(--success); }
.progress-bar.medium  { background: var(--warning); }
.progress-bar.low     { background: var(--danger); }
.cisterna-card { padding: 1.2rem; }
.cisterna-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.cisterna-tipo { font-weight: 700; font-size: 15px; }
.cisterna-litri { font-size: 1.4rem; font-weight: 700; }
.cisterna-dettaglio { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Toolbar / Filtri ───────────────────────────────────── */
.toolbar {
  display: flex; gap: .75rem; margin-bottom: 1.2rem;
  flex-wrap: wrap; align-items: center;
}
.toolbar .form-control { margin-bottom: 0; max-width: 220px; }
.search-input { max-width: 280px !important; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: #fff; border-radius: 12px; width: 100%; max-width: 700px;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-md);
}
.modal-box.modal-lg { max-width: 900px; }
.modal-box.modal-sm { max-width: 450px; }
.modal-header {
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--primary-dark); }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--text-muted); padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: #f0f0f0; color: var(--text); }
.modal-body { padding: 1.2rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 1rem 1.2rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; flex-shrink: 0; }

/* ── Toast ──────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  padding: .75rem 1.2rem; border-radius: var(--radius);
  box-shadow: var(--shadow-md); font-size: 13px; font-weight: 500;
  min-width: 240px; max-width: 360px; display: flex; align-items: center; gap: .6rem;
  animation: slideIn .3s ease;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error   { background: var(--danger);  color: #fff; }
.toast-warning { background: var(--warning); color: #333; }
.toast-info    { background: var(--info);    color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Mappa Pista ────────────────────────────────────────── */
.mappa-container {
  position: relative; background: #2d5a27;
  border-radius: var(--radius); overflow: hidden;
  border: 3px solid #4a7a42;
}
.mappa-pista {
  width: 100%; display: block;
  min-height: 400px; max-height: 600px;
}
.mappa-aeromobile {
  position: absolute; cursor: pointer;
  transform: translate(-50%, -50%);
  transition: all .2s ease;
}
.mappa-aeromobile:hover { z-index: 10; }
.mappa-aeromobile .icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.4);
  border: 2px solid rgba(255,255,255,.6);
}
.mappa-aeromobile .icon.aereo      { background: #1a6bb0; color: #fff; }
.mappa-aeromobile .icon.elicottero { background: #dc3545; color: #fff; }
.mappa-aeromobile .icon.ultraleggero { background: #ffc107; color: #333; }
.mappa-aeromobile .label {
  background: rgba(0,0,0,.7); color: #fff;
  font-size: 10px; padding: 2px 5px; border-radius: 4px;
  margin-top: 2px; text-align: center; white-space: nowrap;
}
.mappa-controls {
  position: absolute; top: 10px; right: 10px;
  display: flex; flex-direction: column; gap: 5px;
}
.mappa-btn {
  width: 32px; height: 32px; background: rgba(255,255,255,.9);
  border: none; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; box-shadow: var(--shadow);
}
.mappa-btn:hover { background: #fff; }

/* ── Checklist ──────────────────────────────────────────── */
.checklist-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .4rem; border-radius: 6px; transition: background var(--transition);
}
.checklist-item:hover { background: #f8f9fa; }
.checklist-item input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; accent-color: var(--primary); }
.checklist-item label { cursor: pointer; flex: 1; font-size: 13px; }
.checklist-item.checked label { text-decoration: line-through; color: var(--text-muted); }

/* ── Firma Canvas ───────────────────────────────────────── */
.firma-canvas {
  border: 2px dashed var(--border); border-radius: var(--radius);
  cursor: crosshair; display: block; touch-action: none;
  background: #fafafa; width: 100%; height: 200px;
}
.firma-canvas.firmato { border-color: var(--success); border-style: solid; background: #fff; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .sidebar-close-btn { display: block; }
  .topbar-menu-btn { display: block; }

  .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 1rem; }
  .toolbar .form-control { max-width: 100%; }
  .toolbar { gap: .5rem; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal-box { border-radius: 0; max-height: 100vh; }
  .modal-overlay { padding: 0; align-items: flex-end; }
}

/* ── Loader ─────────────────────────────────────────────── */
.loader {
  display: flex; align-items: center; justify-content: center;
  padding: 3rem; flex-direction: column; gap: 1rem; color: var(--text-muted);
}
.spinner {
  width: 36px; height: 36px; border: 3px solid #dee2e6;
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ── Pagination ─────────────────────────────────────────── */
.pagination { display: flex; gap: .4rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.page-btn {
  padding: 5px 11px; border: 1.5px solid var(--border);
  border-radius: 6px; background: #fff; cursor: pointer;
  font-size: 13px; transition: all var(--transition);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Tabs ───────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 1.2rem; gap: 0; }
.tab-btn {
  padding: .6rem 1.2rem; background: none; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-muted);
  transition: all var(--transition); white-space: nowrap;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Detail View ────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.detail-item label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; display: block; margin-bottom: 2px; }
.detail-item .value { font-size: 14px; }
@media (max-width: 500px) { .detail-grid { grid-template-columns: 1fr; } }
