/* VideoBonding Dashboard — Stili */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:       #0f1117;
  --bg-surface:    #1a1d27;
  --bg-elevated:   #21253a;
  --border:        #2d3148;
  --text-primary:  #e2e8f0;
  --text-secondary:#94a3b8;
  --text-muted:    #475569;
  --accent:        #7c8cff;
  --accent-hover:  #6b7cf7;
  --success:       #22c55e;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #38bdf8;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     14px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Navbar ── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.navbar-brand span { font-size: 1.4rem; }

.navbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-user {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.btn-logout {
  padding: 0.4rem 0.9rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Layout principale ── */
.layout {
  display: flex;
  min-height: calc(100vh - 56px);
}

.sidebar {
  width: 220px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  flex-shrink: 0;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.sidebar-item.active {
  background: rgba(124, 140, 255, 0.12);
  color: var(--accent);
  border-left: 3px solid var(--accent);
}

.sidebar-icon { font-size: 1.1rem; width: 1.4rem; text-align: center; }

.main-content {
  flex: 1;
  padding: 1.75rem 2rem;
  overflow-x: auto;
}

/* ── Pagina header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.1rem;
}

/* ── Bottoni ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg-elevated); color: var(--text-primary); }

/* ── Statistiche riassuntive ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  font-size: 1.8rem;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.stat-icon.blue   { background: rgba(56, 189, 248, 0.12); }
.stat-icon.green  { background: rgba(34, 197, 94, 0.12); }
.stat-icon.orange { background: rgba(245, 158, 11, 0.12); }
.stat-icon.purple { background: rgba(124, 140, 255, 0.12); }

.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.2rem; }

/* ── Grid modem ── */
.modems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

/* ── Card modem ── */
.modem-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: border-color 0.2s, transform 0.15s;
  cursor: pointer;
}

.modem-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.modem-card.online  { border-left: 3px solid var(--success); }
.modem-card.warning { border-left: 3px solid var(--warning); }
.modem-card.offline { border-left: 3px solid var(--danger);  }

.modem-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modem-name {
  font-size: 1.05rem;
  font-weight: 600;
}

.modem-id {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: monospace;
  margin-top: 0.1rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.online  { background: rgba(34,197,94,0.12);  color: var(--success); }
.status-badge.warning { background: rgba(245,158,11,0.12); color: var(--warning); }
.status-badge.offline { background: rgba(239,68,68,0.12);  color: var(--danger);  }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.online  .status-dot { animation: pulse-green 2s infinite; }

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Griglia dati modem ── */
.modem-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.metric {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
}

.metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.metric-value {
  font-size: 0.9rem;
  font-weight: 600;
}

/* ── SIM bars ── */
.sim-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.sim-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
}

.sim-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sim-dot.up   { background: var(--success); }
.sim-dot.down { background: var(--danger); }

.sim-signal-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}

.sim-signal-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--success);
  transition: width 0.5s;
}

.sim-signal-fill.poor    { background: var(--danger); }
.sim-signal-fill.fair    { background: var(--warning); }
.sim-signal-fill.good    { background: var(--success); }

/* ── Card footer ── */
.modem-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.modem-card-footer-info {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.modem-actions {
  display: flex;
  gap: 0.4rem;
}

/* ── Stato vuoto ── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}

.empty-state-icon { font-size: 3.5rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3   { font-size: 1.1rem; margin-bottom: 0.4rem; }
.empty-state p    { font-size: 0.88rem; }

/* ── Loading spinner ── */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 3rem auto;
}

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

.loading-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

/* ── Dettaglio modem (pannello) ── */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: flex-end;
}

.detail-overlay.open { display: flex; }

.detail-panel {
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  width: 500px;
  max-width: 95vw;
  height: 100vh;
  overflow-y: auto;
  padding: 1.5rem;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.detail-overlay.open .detail-panel { transform: translateX(0); }

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.detail-title { font-size: 1.15rem; font-weight: 700; }

.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 1.25rem 0 0.75rem;
}

/* ── Tabelle ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(45,49,72,0.5);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-elevated); }

/* ── Toast notifiche ── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  font-size: 0.88rem;
  max-width: 320px;
  animation: slide-up 0.25s ease;
  box-shadow: var(--shadow);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }

@keyframes slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modal aggiunta modem ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 480px;
  max-width: 95vw;
  box-shadow: var(--shadow);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.form-input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus { border-color: var(--accent); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 1rem; }
  .modems-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
