/* G.E.M. plus — tema applicazione (ispirato all'originale: sidebar scura, pagina chiara, header a gradiente) */
:root {
    --primary: #6b9e3a;
    --bg: hsl(220 20% 97%);
    --fg: hsl(222 47% 11%);
    --sidebar-bg: hsl(222 47% 10%);
    --sidebar-fg: hsl(210 40% 90%);
    --sidebar-muted: #64748b;
    --card-border: hsl(220 14% 92%);
    --radius: 12px;
    --sidebar-w: 240px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
html, body { height: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 14px;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
.min-w-0 { min-width: 0; }

/* ── Sidebar ── */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-fg);
    z-index: 1030; overflow: hidden;
}
.sidebar-offcanvas { width: var(--sidebar-w) !important; background: var(--sidebar-bg); color: var(--sidebar-fg); border-right: 1px solid #1e293b; }
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 18px 16px; border-bottom: 1px solid #1e293b; }
.sb-logo { width: 40px; height: 40px; border-radius: 10px; overflow: hidden; background: rgba(255,255,255,.1); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.sb-logo img { width: 100%; height: 100%; object-fit: contain; }
.sb-logo-empty i { font-size: 18px; }
.sb-app { font-size: 11px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; line-height: 1; }
.sb-company { font-size: 13px; font-weight: 600; color: #fff; margin-top: 3px; line-height: 1.2; }
.sb-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.sb-group { margin-bottom: 18px; }
.sb-group-label { font-size: 10px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; color: #475569; padding: 0 12px; margin-bottom: 6px; }
.sb-link {
    display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 500;
    color: #94a3b8; text-decoration: none; position: relative; margin-bottom: 2px; transition: background .15s, color .15s;
}
.sb-link:hover { color: #f1f5f9; background: rgba(30,41,59,.7); }
.sb-link i.bi { font-size: 16px; width: 18px; text-align: center; }
.sb-active-bar { position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 20px; border-radius: 0 4px 4px 0; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid #1e293b; }
.sb-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.sb-user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; line-height: 1.2; }
.sb-user-role { font-size: 11px; color: #64748b; }
.sb-logout { background: none; border: 0; color: #64748b; padding: 6px; border-radius: 6px; }
.sb-logout:hover { color: #f87171; background: rgba(239,68,68,.1); }

/* ── Header mobile ── */
.mobile-header { position: sticky; top: 0; z-index: 1020; height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 16px; background: var(--sidebar-bg); border-bottom: 1px solid #1e293b; }
.mh-logo { height: 32px; width: auto; object-fit: contain; }

/* ── Contenuto ── */
.main-content { min-height: 100vh; padding: 16px; }
@media (min-width: 640px) { .main-content { padding: 24px; } }
@media (min-width: 992px) { .main-content { margin-left: var(--sidebar-w); padding: 32px; } }
.page-container { max-width: 1152px; margin: 0 auto; }

/* ── Header di pagina ── */
.page-header {
    border-radius: 16px; overflow: hidden; margin-bottom: 24px; color: #fff;
    background: linear-gradient(135deg, hsl(222 47% 11%) 0%, hsl(222 40% 18%) 100%);
    padding: 18px 20px;
}
.page-header .ph-icon { border-radius: 12px; padding: 10px; display: inline-flex; margin-top: 2px; }
.page-header .ph-icon i { font-size: 20px; }
.page-header h1 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-header p { margin: 2px 0 0; font-size: 13px; color: #94a3b8; }

/* ── Card e tabelle ── */
.card { border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card-header { background: #fff; border-bottom: 1px solid var(--card-border); font-weight: 600; }
.stat-card { border-radius: 14px; padding: 18px; background: #fff; border: 1px solid var(--card-border); }
.stat-card .stat-label { font-size: 12px; color: #64748b; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #64748b; font-weight: 600; background: #f8fafc; }
.table-hover tbody tr:hover { background: #f8fafc; }
.btn { border-radius: 8px; font-weight: 500; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: color-mix(in srgb, var(--primary) 85%, black); border-color: color-mix(in srgb, var(--primary) 85%, black); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.text-primary { color: var(--primary) !important; }
.form-control, .form-select { border-radius: 8px; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--primary) 20%, transparent); }
.badge { font-weight: 600; }
.badge-soft { background: color-mix(in srgb, var(--badge-color, #64748b) 15%, white); color: var(--badge-color, #475569); }
.modal-content { border-radius: 14px; border: 0; }
.modal-header { border-bottom: 1px solid var(--card-border); }
.dropdown-menu { border-radius: 10px; border: 1px solid var(--card-border); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.empty-state { text-align: center; padding: 48px 16px; color: #64748b; }
.empty-state i { font-size: 40px; opacity: .4; display: block; margin-bottom: 8px; }
.cursor-pointer { cursor: pointer; }
.loading-overlay { display: flex; align-items: center; justify-content: center; padding: 48px; color: #64748b; gap: 10px; }
.avatar-sm { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #e2e8f0; }
.avatar-initials { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; background: color-mix(in srgb, var(--primary) 15%, white); color: var(--primary); }

/* Stati scadenze */
.status-ok { color: #16a34a; } .status-warn { color: #d97706; } .status-expired { color: #dc2626; }
.bg-status-ok { background: #dcfce7; color: #166534; } .bg-status-warn { background: #fef3c7; color: #92400e; } .bg-status-expired { background: #fee2e2; color: #991b1b; } .bg-status-none { background: #f1f5f9; color: #475569; }

/* Colonne ridimensionabili */
.col-resize-handle { position: absolute; right: 0; top: 0; bottom: 0; width: 12px; cursor: col-resize; display: flex; align-items: center; justify-content: center; user-select: none; z-index: 2; }
.col-resize-handle span { width: 2px; height: 20px; border-radius: 2px; background: #e2e8f0; transition: background .15s; }
.col-resize-handle:hover span { background: #60a5fa; }
@media print { .col-resize-handle { display: none; } }

/* Select2 nel tema */
.select2-container--bootstrap-5 .select2-selection { border-radius: 8px; }
.dt-container .dt-search input { border-radius: 8px; }
.dt-container .dt-info, .dt-container .dt-length label { color: #64748b; font-size: 13px; }

/* Login */
.login-bg { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(135deg, #1e293b 0%, #334155 100%); }
.company-card { background: #fff; border-radius: 14px; padding: 24px; text-align: center; border: 0; box-shadow: 0 10px 30px rgba(0,0,0,.25); transition: transform .15s, box-shadow .15s; position: relative; overflow: hidden; width: 100%; }
.company-card:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(0,0,0,.3); }
.company-card img { height: 80px; width: auto; object-fit: contain; }
.company-card .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; opacity: 0; transition: opacity .15s; }
.company-card:hover .bar { opacity: 1; }

/* Stampa */
@media print {
    .sidebar, .mobile-header, .no-print, .toast-container, .btn, .dt-search, .dt-length, .dt-paging, .dt-info { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    .print-header { display: flex !important; justify-content: space-between; align-items: center; padding-bottom: 12px; margin-bottom: 20px; border-bottom: 3px solid #E87722; }
    .page-header { background: none !important; color: #000 !important; padding: 0 !important; margin-bottom: 12px !important; }
    .page-header p { color: #444 !important; }
    body { background: #fff; }
    .card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
}
