/* =============================================
   🔥 Fiamma Admin - Membrane Panel
   Tema: Dark, ispirato Fiamma
   ============================================= */

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --border-color: #30363d;
  --border-hover: #484f58;
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #ff6b35;
  --accent-hover: #e55a28;
  --accent-dim: rgba(255, 107, 53, 0.15);
  --success: #3fb950;
  --warning: #d29922;
  --error: #f85149;
  --info: #58a6ff;
  --sidebar-width: 240px;
  --sidebar-collapsed: 60px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --transition: 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
}

body {
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
pre, code { font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace; }

/* ============ Sidebar ============ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border-color);
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.logo span { color: var(--accent); }

.sidebar-sub {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}
.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
  text-decoration: none;
}
.nav-item.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-left-color: var(--accent);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}
.ws-indicator { font-size: 12px; }
.ws-indicator.online { color: var(--success); }
.ws-indicator.offline { color: var(--error); }

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1100;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}

/* ============ Main Content ============ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 24px 32px;
  max-width: 1400px;
  width: 100%;
  transition: margin var(--transition);
}

#page-content h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
}
#page-content h2 .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 8px;
}

/* ============ Cards ============ */
.card, .card-grid {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card h3 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}
.card .value.accent { color: var(--accent); }
.card .value.success { color: var(--success); }
.card .value.error { color: var(--error); }
.card p { color: var(--text-secondary); font-size: 12px; margin-top: 4px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ============ Node Cards ============ */
.node-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  transition: border-color var(--transition);
}
.node-card:hover { border-color: var(--border-hover); }
.node-card .node-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.node-card .node-name {
  font-size: 16px;
  font-weight: 600;
}
.node-card .node-status {
  font-size: 20px;
}
.node-card .node-detail {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 4px;
}
.node-card .node-detail strong { color: var(--text-primary); }

/* ============ Tables ============ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}
.data-table th {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.data-table tr:hover td { background: var(--accent-dim); }
.data-table td.clickable {
  cursor: pointer;
  color: var(--accent);
}
.data-table td.clickable:hover { text-decoration: underline; }

/* ============ Forms & Inputs ============ */
input[type="text"], input[type="search"], textarea, select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}
input[type="text"]:focus, input[type="search"]:focus, textarea:focus {
  border-color: var(--accent);
}
textarea {
  min-height: 80px;
  resize: vertical;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}
textarea.mono-lg {
  min-height: 120px;
  font-size: 13px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn:hover { background: var(--border-color); }
.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-accent:hover { background: var(--accent-hover); }
.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-danger {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-group {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

/* ============ Log viewer ============ */
.log-box {
  background: #000;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  max-height: 500px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #abb2bf;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-box .timestamp { color: #528bff; }
.log-box .error-line { color: var(--error); }
.log-box .warn-line { color: var(--warning); }
.log-box .info-line { color: var(--success); }

/* ============ Modale ============ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
}
.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  z-index: 2001;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px; }
.modal-body .field {
  margin-bottom: 12px;
}
.modal-body .field-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.modal-body .field-value {
  font-size: 14px;
  color: var(--text-primary);
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 13px;
  box-shadow: var(--shadow);
  max-width: 400px;
  animation: toast-in 0.3s ease;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }
.toast.warning { border-color: var(--warning); }

@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ============ Loading ============ */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============ Tags ============ */
.tag {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  margin: 1px 2px;
}

/* ============ Query result ============ */
.query-result { overflow-x: auto; }
.query-result .data-table { font-size: 12px; }
.query-result .data-table th, .query-result .data-table td {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ Responsive ============ */
@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); width:280px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .sidebar-toggle { display: flex; font-size:26px; top:8px; left:8px; z-index:1101; background:var(--accent); color:#fff; border:none; border-radius:8px; width:40px; height:40px; align-items:center; justify-content:center; }
  .main-content {
    margin-left: 0;
    padding: 12px;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .node-card { padding:12px; }
  .node-detail { font-size:12px; }
  .btn-sm { font-size:11px; padding:4px 8px; }
}

@media (min-width: 768px) {
  .sidebar-toggle { display: none; }
  .sidebar.open { transform: translateX(0); }


/* Mobile top bar */
@media (max-width: 767px) {
  .sidebar { top:48px; }
  .main-content { margin-top:48px; }
}

}
/* === Chiamate — Call History === */
.info-badge {
  cursor: pointer;
  opacity: 0.6;
  margin-left: auto;
  font-size: 0.85em;
  transition: opacity 0.2s;
}
.info-badge:hover { opacity: 1; color: var(--warning, #f59e0b); }

/* Warning Modal — Etico */
.warning-modal .modal-content {
  border: 2px solid #ef4444;
  max-width: 560px;
}
.warning-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.warning-icon {
  font-size: 2.5rem;
  line-height: 1;
}
.warning-title {
  color: #ef4444;
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
}
.warning-body {
  background: rgba(239,68,68,0.08);
  border-left: 3px solid #ef4444;
  padding: 16px;
  border-radius: 6px;
  margin: 12px 0;
  line-height: 1.7;
  font-size: 0.95rem;
}
.warning-body strong {
  color: #fbbf24;
}
.warning-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.warning-stat {
  background: var(--bg-secondary);
  padding: 12px;
  border-radius: 8px;
  text-align: center;
}
.warning-stat .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}
.warning-stat .label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.call-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.call-table th {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
}
.call-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border-color);
}
.call-table tr:hover td {
  background: var(--bg-secondary);
}
.badge-esito {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-risposta { background: rgba(34,197,94,0.2); color: #22c55e; }
.badge-occupato { background: rgba(234,179,8,0.2); color: #eab308; }
.badge-non_risposto { background: rgba(239,68,68,0.2); color: #ef4444; }
.badge-fallito { background: rgba(239,68,68,0.3); color: #ef4444; }
.badge-squilla { background: rgba(59,130,246,0.2); color: #3b82f6; }
.call-cost { font-family: monospace; text-align: right; }
.call-duration { font-family: monospace; text-align: right; }
