/* ═══════════════════════════════════════════════════
   MikroTik Log Server - Enterprise UI
   Font: JetBrains Mono + Inter
   Theme: Industrial dark with neon accents
   ═══════════════════════════════════════════════════ */

:root {
  --bg-base:      #0a0c10;
  --bg-surface:   #0f1117;
  --bg-elevated:  #161b24;
  --bg-card:      #1a2030;
  --bg-hover:     #1f2840;

  --border:       #1e2a3a;
  --border-accent:#2a3a52;

  --text-primary: #e8edf5;
  --text-secondary:#8899b0;
  --text-muted:   #4a5a70;
  --text-code:    #7dd3fc;

  --accent:       #00d4ff;
  --accent-dim:   rgba(0,212,255,0.12);
  --accent-glow:  rgba(0,212,255,0.3);
  --green:        #00f5a0;
  --green-dim:    rgba(0,245,160,0.12);
  --red:          #ff4060;
  --red-dim:      rgba(255,64,96,0.12);
  --orange:       #ff9020;
  --orange-dim:   rgba(255,144,32,0.12);
  --yellow:       #ffd060;
  --purple:       #a855f7;
  --purple-dim:   rgba(168,85,247,0.12);

  --sidebar-w:    240px;
  --topbar-h:     56px;
  --radius:       8px;
  --radius-sm:    5px;
  --radius-lg:    12px;

  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;
  --font-ui:      'Inter', system-ui, sans-serif;

  --shadow:       0 4px 20px rgba(0,0,0,0.5);
  --shadow-glow:  0 0 20px rgba(0,212,255,0.15);
  --transition:   0.18s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="light"] {
  --bg-base:      #f0f4f8;
  --bg-surface:   #ffffff;
  --bg-elevated:  #f8fafc;
  --bg-card:      #ffffff;
  --bg-hover:     #f1f5f9;
  --border:       #e2e8f0;
  --border-accent:#cbd5e1;
  --text-primary: #0f172a;
  --text-secondary:#475569;
  --text-muted:   #94a3b8;
  --text-code:    #0369a1;
  --accent:       #0284c7;
  --accent-dim:   rgba(2,132,199,0.08);
  --accent-glow:  rgba(2,132,199,0.2);
}

/* ─── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font-ui);
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Sidebar ────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.logo-icon {
  font-size: 22px;
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-glow);
  filter: drop-shadow(0 0 6px var(--accent));
}
.logo-main { display: block; font-family: var(--font-mono); font-weight: 700; font-size: 0.95rem; color: var(--text-primary); letter-spacing: 0.05em; }
.logo-sub  { display: block; font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.15em; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  padding: 14px 20px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  position: relative;
  transition: all var(--transition);
  border-radius: 0;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-right: 2px solid var(--accent);
}
.nav-icon { font-size: 0.9rem; width: 18px; text-align: center; opacity: 0.7; }
.nav-item.active .nav-icon { opacity: 1; }

/* --- Sidebar System Info --- */
.sys-info-sidebar {
  padding: 10px 20px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.sys-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}
.sys-info-row span:first-child {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.sys-info-row span:last-child {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-size: 0.72rem;
}
.progress-bar.mini {
  flex: 1;
  height: 4px;
  background: var(--bg-elevated);
}
#sysInfoSidebar {
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  padding-bottom: 14px;
}

.badge-alert {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  animation: pulse 2s infinite;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.user-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-avatar {
  width: 30px; height: 30px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}
.user-name  { display: block; font-size: 0.78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { display: block; font-size: 0.62rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.sidebar-actions { display: flex; gap: 4px; }

/* ─── Layout ─────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin var(--transition);
}
.main-wrapper.full { margin-left: 0; }

.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 0.88rem; font-weight: 600; color: var(--text-secondary); flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-time  { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); }

.status-indicator { display: flex; align-items: center; gap: 6px; font-size: 0.72rem; color: var(--green); }
.status-dot {
  width: 7px; height: 7px;
  background: var(--green);
  border-radius: 50%;
}
.status-dot.pulse { animation: pulse 2s infinite; }

.content { flex: 1; padding: 24px; max-width: 1600px; }

/* ─── Cards ──────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.1em; }

/* ─── Stat Cards ─────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), border-color var(--transition);
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-accent); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.stat-card.accent::before  { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.stat-card.green::before   { background: var(--green); }
.stat-card.red::before     { background: var(--red); }
.stat-card.orange::before  { background: var(--orange); }
.stat-card.purple::before  { background: var(--purple); }

.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 8px; }
.stat-value { font-family: var(--font-mono); font-size: 1.8rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-value.accent  { color: var(--accent); text-shadow: 0 0 12px var(--accent-glow); }
.stat-value.green   { color: var(--green); }
.stat-value.red     { color: var(--red); }
.stat-value.orange  { color: var(--orange); }
.stat-sub { font-size: 0.7rem; color: var(--text-muted); margin-top: 6px; }

/* ─── Tables ─────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
thead th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:hover { background: var(--bg-hover); }
tbody td { padding: 10px 14px; color: var(--text-secondary); vertical-align: middle; }
tbody td:first-child { color: var(--text-primary); }

/* ─── Badges / Tags ──────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
}
.badge-info     { background: var(--accent-dim);  color: var(--accent); }
.badge-success  { background: var(--green-dim);   color: var(--green); }
.badge-warning  { background: var(--orange-dim);  color: var(--orange); }
.badge-error    { background: var(--red-dim);     color: var(--red); }
.badge-system   { background: var(--purple-dim);  color: var(--purple); }
.badge-online   { background: var(--green-dim);   color: var(--green); }
.badge-offline  { background: var(--red-dim);     color: var(--red); }

/* ─── Buttons ────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border: none; border-radius: var(--radius);
  font-size: 0.78rem; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  font-family: var(--font-ui);
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: #22e4ff; box-shadow: 0 0 16px var(--accent-glow); }
.btn-success { background: var(--green); color: #000; }
.btn-danger  { background: var(--red); color: #fff; }
.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-sm { padding: 5px 10px; font-size: 0.72rem; }
.btn-icon {
  background: none; border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.9rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Forms ──────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.72rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.08em; }
.form-control {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 0.82rem;
  font-family: var(--font-ui);
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ─── Alerts / Toasts ────────────────────────── */
.alert-box {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  border: 1px solid;
}
.alert-success { background: var(--green-dim);  color: var(--green);  border-color: var(--green); }
.alert-error   { background: var(--red-dim);    color: var(--red);    border-color: var(--red); }
.alert-warning { background: var(--orange-dim); color: var(--orange); border-color: var(--orange); }
.alert-info    { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* Toast notifications */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 0.8rem;
  min-width: 260px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  display: flex; gap: 10px; align-items: center;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.warning { border-left: 3px solid var(--orange); }

/* ─── Chart containers ───────────────────────── */
.chart-container { position: relative; height: 200px; }

/* ─── Grid layouts ───────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }

/* ─── Log colors ─────────────────────────────── */
.log-level-info     td:first-child { border-left: 3px solid var(--accent); }
.log-level-warning  td:first-child { border-left: 3px solid var(--orange); }
.log-level-error    td:first-child { border-left: 3px solid var(--red); }
.log-level-debug    td:first-child { border-left: 3px solid var(--text-muted); }

/* ─── IP address styling ─────────────────────── */
.ip-addr { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-code); }
.msg-cell { max-width: 380px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Pagination ─────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 16px; }
.page-btn {
  min-width: 30px; height: 30px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 700; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ─── Modal ──────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ─── Login page ─────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(0,212,255,0.04) 0%, transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 380px;
  position: relative;
  z-index: 1;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .icon { font-size: 2.5rem; color: var(--accent); filter: drop-shadow(0 0 12px var(--accent)); display: block; margin-bottom: 8px; }
.login-logo h1 { font-family: var(--font-mono); font-size: 1.1rem; color: var(--text-primary); font-weight: 700; letter-spacing: 0.1em; }
.login-logo p { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; }

/* ─── Terminal-style log view ────────────────── */
.log-terminal {
  background: #05080c;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 14px;
  max-height: 300px;
  overflow-y: auto;
  line-height: 1.8;
}
.log-line { display: flex; gap: 10px; }
.log-time  { color: var(--text-muted); flex-shrink: 0; }
.log-type  { flex-shrink: 0; min-width: 60px; }
.log-msg   { color: var(--text-primary); }

/* ─── Progress bars ──────────────────────────── */
.progress-bar { background: var(--bg-elevated); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.progress-fill.accent  { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.progress-fill.green   { background: var(--green); }
.progress-fill.orange  { background: var(--orange); }
.progress-fill.red     { background: var(--red); }

/* ─── Online users ───────────────────────────── */
.user-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.user-dot  { width: 8px; height: 8px; background: var(--green); border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 6px var(--green); }

/* ─── Animations ─────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeIn 0.3s ease forwards; }

/* ─── Scrollbar ──────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-accent); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Responsive ─────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

/* ─── Utility ────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.ml-auto { margin-left: auto; }
.mt-16   { margin-top: 16px; }
.mt-24   { margin-top: 24px; }
.mb-16   { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-code  { font-family: var(--font-mono); font-size: 0.78rem; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ─── Install wizard ─────────────────────────── */
.install-steps { display: flex; gap: 0; margin-bottom: 30px; }
.install-step {
  flex: 1; text-align: center;
  padding: 10px; font-size: 0.72rem;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  position: relative;
}
.install-step.active { color: var(--accent); border-bottom-color: var(--accent); }
.install-step.done   { color: var(--green);  border-bottom-color: var(--green); }
