/* ============================================================
   WATCHMAN — Enterprise IT Monitoring System
   Main Application Stylesheet
   ============================================================ */

:root {
  --wm-sidebar-width: 260px;
  --wm-sidebar-collapsed: 0px;
  --wm-topbar-height: 60px;
  --wm-primary: #0d6efd;
  --wm-bg-sidebar: #0f172a;
  --wm-text-sidebar: #cbd5e1;
  --wm-active-sidebar: rgba(99,179,237,.15);
  --wm-active-sidebar-text: #63b3ed;
}

/* ── Layout ── */
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bs-body-bg);
  overflow-x: hidden;
}

.wm-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--wm-sidebar-width);
  height: 100vh;
  background: var(--wm-bg-sidebar);
  color: var(--wm-text-sidebar);
  z-index: 1040;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .25s ease;
  display: flex;
  flex-direction: column;
}

.wm-main {
  margin-left: var(--wm-sidebar-width);
  min-height: 100vh;
  transition: margin-left .25s ease;
  display: flex;
  flex-direction: column;
}

.wm-topbar {
  position: sticky;
  top: 0;
  height: var(--wm-topbar-height);
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  z-index: 1030;
  gap: .5rem;
}

.wm-content {
  padding: 1.5rem;
  flex: 1;
}

/* ── Sidebar Brand ── */
.wm-sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.wm-logo-icon {
  width: 38px; height: 38px;
  background: var(--wm-primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  flex-shrink: 0;
}

/* ── Sidebar Nav ── */
.wm-sidebar-nav {
  padding: 1rem 0.75rem;
  flex: 1;
}

.wm-nav-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #64748b;
  padding: .4rem .75rem;
  margin-top: .25rem;
}

.wm-nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .75rem;
  color: var(--wm-text-sidebar);
  text-decoration: none;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  transition: all .15s;
  margin-bottom: 2px;
}

.wm-nav-link:hover {
  background: rgba(255,255,255,.06);
  color: #e2e8f0;
}

.wm-nav-link.active {
  background: var(--wm-active-sidebar);
  color: var(--wm-active-sidebar-text);
}

.wm-nav-link i { font-size: 1rem; width: 1.2rem; text-align: center; flex-shrink: 0; }

/* ── Cards ── */
.wm-card {
  border: 1px solid var(--bs-border-color);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.wm-card .card-header {
  background: transparent;
  border-bottom: 1px solid var(--bs-border-color);
  padding: .875rem 1.125rem;
}

/* ── Status Cards ── */
.wm-stat-card {
  border-radius: 12px;
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  transition: transform .2s;
}
.wm-stat-card:hover { transform: translateY(-2px); }

.wm-stat-icon {
  font-size: 1.75rem;
  margin-bottom: .5rem;
}
.wm-stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.wm-stat-label { font-size: .8rem; color: var(--bs-secondary-color); margin-top: .25rem; }

.wm-stat-total  .wm-stat-icon, .wm-stat-total  .wm-stat-value { color: #6c757d; }
.wm-stat-online .wm-stat-icon, .wm-stat-online .wm-stat-value { color: #198754; }
.wm-stat-offline .wm-stat-icon, .wm-stat-offline .wm-stat-value { color: #dc3545; }
.wm-stat-warning .wm-stat-icon, .wm-stat-warning .wm-stat-value { color: #fd7e14; }
.wm-stat-alerts .wm-stat-icon, .wm-stat-alerts .wm-stat-value { color: #dc3545; }
.wm-stat-sla .wm-stat-icon, .wm-stat-sla .wm-stat-value { color: #0d6efd; }

/* ── Status Badge ── */
.wm-status-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .6rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
}

.wm-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.wm-status-online   { background: rgba(25,135,84,.12);  color: #198754; }
.wm-status-online   .wm-status-dot { background: #198754; animation: pulse-green 2s infinite; }
.wm-status-offline  { background: rgba(220,53,69,.12);  color: #dc3545; }
.wm-status-offline  .wm-status-dot { background: #dc3545; }
.wm-status-warning  { background: rgba(255,193,7,.15);  color: #856404; }
.wm-status-warning  .wm-status-dot { background: #ffc107; }
.wm-status-critical { background: rgba(253,126,20,.12); color: #842029; }
.wm-status-critical .wm-status-dot { background: #fd7e14; }
.wm-status-maintenance { background: rgba(108,117,125,.12); color: #6c757d; }
.wm-status-maintenance .wm-status-dot { background: #6c757d; }
.wm-status-unknown  { background: rgba(108,117,125,.1); color: #6c757d; }
.wm-status-unknown  .wm-status-dot { background: #adb5bd; }

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(25,135,84,.4); }
  50%       { box-shadow: 0 0 0 6px rgba(25,135,84,0); }
}

/* ── Severity Badges ── */
.wm-severity-critical { background: #dc3545; color: #fff; }
.wm-severity-high     { background: #fd7e14; color: #fff; }
.wm-severity-warning  { background: #ffc107; color: #212529; }
.wm-severity-medium   { background: #ffc107; color: #212529; }
.wm-severity-info     { background: #0dcaf0; color: #212529; }
.wm-severity-low      { background: #20c997; color: #fff; }

/* ── Avatar ── */
.wm-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--wm-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .8rem;
  flex-shrink: 0;
}

.wm-avatar-lg {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--wm-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 2rem;
}

/* ── Auth Page ── */
.wm-auth-body { background: #0f172a; min-height: 100vh; }

.wm-auth-bg {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  z-index: 0;
}

.wm-auth-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(99,179,237,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,179,237,.08) 1px, transparent 1px);
  background-size: 50px 50px;
}

.wm-auth-card {
  background: rgba(30,41,59,.95);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
  color: #e2e8f0;
}

.wm-auth-card .form-control, .wm-auth-card .form-select {
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.12);
  color: #e2e8f0;
}
.wm-auth-card .form-control:focus { background: rgba(255,255,255,.1); color: #fff; border-color: var(--wm-primary); box-shadow: 0 0 0 .25rem rgba(13,110,253,.25); }
.wm-auth-card .input-group-text { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); color: #94a3b8; }
.wm-auth-card .form-label { color: #cbd5e1; }
.wm-auth-card .text-muted { color: #64748b !important; }
.wm-auth-card a { color: #63b3ed; }

.wm-auth-logo {
  width: 64px; height: 64px;
  background: var(--wm-primary);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
  font-size: 2rem;
  color: white;
}
.wm-auth-footer { position: fixed; bottom: 1rem; left: 0; right: 0; z-index: 1; }

/* ── Timeline ── */
.wm-timeline { display: flex; flex-direction: column; gap: 1rem; }
.wm-tl-item { display: flex; align-items: flex-start; gap: .75rem; }
.wm-tl-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }

/* ── Utility ── */
.btn-xs { padding: .2rem .4rem; font-size: .75rem; border-radius: 4px; }
.font-monospace { font-family: 'Consolas', 'Courier New', monospace; }

/* ── Dark Mode Overrides ── */
[data-bs-theme="dark"] {
  --wm-bg-sidebar: #0a0f1e;
}
[data-bs-theme="dark"] .wm-card { box-shadow: 0 1px 3px rgba(0,0,0,.3); }
[data-bs-theme="dark"] .wm-auth-card { background: rgba(15,23,42,.97); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .wm-sidebar {
    width: 0;
    transform: translateX(-100%);
  }
  .wm-sidebar.show {
    width: var(--wm-sidebar-width);
    transform: translateX(0);
  }
  .wm-main {
    margin-left: 0;
  }
}

/* ── ApexCharts theme fix ── */
.apexcharts-text { fill: var(--bs-body-color) !important; }
.apexcharts-gridline { stroke: var(--bs-border-color) !important; }
