/* ─── Abrsan Monitor - Navy & Orange Theme ─── */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #eef2f9;
  --bg2: #ffffff;
  --bg3: #f5f7fb;
  --card: #ffffff;
  --border: #d0d8e8;
  --border2: #b8c4d8;
  --accent: #e07020;
  --accent-light: #fff3eb;
  --accent2: #c05010;
  --navy: #1a2340;
  --navy2: #2a3560;
  --green: #2e7d32;
  --green-light: #e8f5e9;
  --yellow: #e07020;
  --yellow-light: #fff3e0;
  --red: #c62828;
  --red-light: #ffebee;
  --text: #1a2340;
  --text2: #4a5568;
  --text3: #8a95aa;
  --shadow: 0 2px 12px rgba(26,35,64,0.08);
  --shadow-lg: 0 8px 32px rgba(26,35,64,0.14);
  --radius: 10px;
  --sidebar-w: 240px;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #21262d;
  --card: #1c2128;
  --border: #30363d;
  --border2: #444c56;
  --accent: #ff8c42;
  --accent-light: rgba(255,140,66,0.12);
  --accent2: #ff6b1a;
  --navy: #e6edf3;
  --navy2: #c9d1d9;
  --green: #3fb950;
  --green-light: rgba(63,185,80,0.12);
  --yellow: #d29922;
  --yellow-light: rgba(210,153,34,0.12);
  --red: #f85149;
  --red-light: rgba(248,81,73,0.12);
  --text: #e6edf3;
  --text2: #8b949e;
  --text3: #6e7681;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Vazirmatn', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
  transition: background .25s, color .25s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ─── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 100;
  transition: background .25s, border-color .25s, transform .3s;
}

.main-content {
  flex: 1;
  margin-right: var(--sidebar-w);
  padding: 24px;
  min-height: 100vh;
  background: var(--bg);
  transition: background .25s;
}

/* ─── Sidebar ─── */
.sidebar-logo {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-text { font-size: 1.1rem; font-weight: 700; color: var(--navy); }
.sidebar-logo .logo-text span { color: var(--accent); }
.sidebar-logo .logo-sub { font-size: 0.72rem; color: var(--text3); margin-top: 2px; }

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

.nav-section-title {
  padding: 10px 16px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: var(--text2);
  font-size: 0.88rem;
  border-radius: 8px;
  margin: 2px 8px;
  transition: all .15s;
  cursor: pointer;
  text-decoration: none;
  position: relative;
}
.nav-item:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active::after {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  background: var(--accent);
  border-radius: 3px 0 0 3px;
}
.nav-item .icon { width: 18px; text-align: center; flex-shrink: 0; }

/* ─── Hamburger ─── */
.hamburger {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 200;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
  flex-direction: column;
  gap: 4px;
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ─── Theme Toggle ─── */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: 'Vazirmatn', sans-serif;
  font-size: 0.78rem;
  color: var(--text2);
  transition: all .15s;
  width: 100%;
}
.theme-toggle:hover { background: var(--border); color: var(--text); }
.toggle-track {
  width: 32px; height: 18px;
  background: var(--border2);
  border-radius: 9px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
[data-theme="dark"] .toggle-track { background: var(--accent); }
.toggle-thumb {
  position: absolute;
  top: 3px; right: 3px;
  width: 12px; height: 12px;
  background: white;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
[data-theme="dark"] .toggle-thumb { transform: translateX(-14px); }

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  background: var(--bg3);
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--navy);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; color: white;
  flex-shrink: 0;
}
[data-theme="dark"] .user-avatar { background: var(--accent); }
.user-name { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.user-role { font-size: 0.7rem; color: var(--text3); }

/* ─── Topbar ─── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
}
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--navy); }
.page-sub { font-size: 0.82rem; color: var(--text2); margin-top: 3px; }

/* ─── Cards ─── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: background .25s, border-color .25s;
}
.card-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Stats Grid ─── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: all .25s;
}
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0; left: 0;
  height: 3px;
}
.stat-card.blue::before { background: var(--accent); }
.stat-card.green::before { background: var(--navy); }
.stat-card.yellow::before { background: linear-gradient(90deg, var(--accent), #f59042); }
.stat-card.red::before { background: linear-gradient(90deg, var(--navy), var(--navy2)); }

.stat-icon { font-size: 1.6rem; margin-bottom: 10px; }
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1; color: var(--navy); }
.stat-label { font-size: 0.78rem; color: var(--text2); margin-top: 4px; }

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--bg3);
  color: var(--text2);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: right;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }
.td-small { font-size: 0.75rem; color: var(--text2); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-family: 'Vazirmatn', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,0.12); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent2); color: white; }
.btn-success { background: var(--green); color: white; }
.btn-warning { background: var(--yellow); color: white; }
.btn-danger { background: var(--red); color: white; }
.btn-secondary { background: var(--bg3); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; border-radius: 5px; }
.btn-icon { padding: 6px 8px; }

/* ─── Forms ─── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 6px; color: var(--text2); }
.form-control {
  width: 100%;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: 'Vazirmatn', sans-serif;
  font-size: 0.88rem;
  padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
  direction: rtl;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(224,112,32,0.12); }
.form-control::placeholder { color: var(--text3); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }

/* ─── Modal ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,35,64,0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
}
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-close { background: none; border: none; color: var(--text2); font-size: 1.3rem; cursor: pointer; padding: 4px; border-radius: 5px; }
.modal-close:hover { background: var(--bg3); }

/* ─── Traffic Bar ─── */
.traffic-bar { margin: 6px 0; }
.traffic-bar-track {
  height: 9px;
  background: var(--bg3);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.traffic-bar-fill { height: 100%; border-radius: 5px; transition: width .5s ease; }
.traffic-bar-fill.low { background: linear-gradient(90deg, var(--navy), var(--navy2)); }
.traffic-bar-fill.medium { background: linear-gradient(90deg, var(--accent), #f59042); }
.traffic-bar-fill.high { background: linear-gradient(90deg, #c05010, var(--accent)); }
.traffic-bar-fill.critical { background: linear-gradient(90deg, var(--red), #e53935); }
.traffic-bar-label { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text2); margin-top: 5px; }

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}
.badge-green { background: var(--green-light); color: var(--green); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-blue { background: var(--accent-light); color: var(--accent); }
.badge-gray { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }

/* ─── Alerts ─── */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 0.85rem; border: 1px solid; }
.alert-success { background: var(--green-light); border-color: rgba(46,125,50,0.2); color: var(--green); }
.alert-warning { background: var(--yellow-light); border-color: rgba(224,112,32,0.2); color: var(--accent); }
.alert-danger { background: var(--red-light); border-color: rgba(198,40,40,0.2); color: var(--red); }
.alert-info { background: var(--accent-light); border-color: rgba(224,112,32,0.2); color: var(--accent); }

/* ─── Live indicator ─── */
.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

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

/* ─── Grids ─── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ─── Server Cards ─── */
.server-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.server-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: all .2s;
  box-shadow: var(--shadow);
}
.server-card:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.server-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.server-card-name { font-weight: 700; font-size: 1rem; color: var(--navy); }
.server-card-client { font-size: 0.78rem; color: var(--text2); margin-top: 2px; }

/* ─── Login ─── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #d8e4f5 0%, #eef2f9 100%);
}
[data-theme="dark"] .login-page { background: radial-gradient(ellipse at center, #1a2035 0%, #0d1117 100%); }
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { font-size: 1.8rem; font-weight: 800; color: var(--navy); }
.login-logo h1 span { color: var(--accent); }
.login-logo p { color: var(--text2); font-size: 0.85rem; margin-top: 4px; }

/* ─── Code ─── */
code {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.82em;
  font-family: 'Courier New', monospace;
  color: var(--accent);
}

/* ─── Utilities ─── */
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.text-muted { color: var(--text2); }
.text-small { font-size: 0.78rem; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--accent); }
.text-accent { color: var(--accent); }
.fw-bold { font-weight: 700; }
.w-100 { width: 100%; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }
  .hamburger { display: flex; }
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-right: 0; padding: 16px; padding-top: 60px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .server-cards { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 600px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-title { font-size: 1.2rem; }
  .modal { width: 95%; max-width: 95%; max-height: 85vh; }
  .login-card { width: 95%; padding: 24px; }
  .flex.gap-2, .flex.gap-3 { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.4rem; }
  .card { padding: 14px; }
  .main-content { padding: 12px; padding-top: 56px; }
  .btn { padding: 7px 12px; font-size: 0.8rem; }
}
