/* SysAdminCenterHCP — Dashboard Theme
   Design system: indigo #4f46e5 / cyan #06b6d4 gradients, dark sidebar
   Matches SysAdminHCP marketing site aesthetic */

:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --accent: #06b6d4;
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-dark: #0f0c29;
  --bg-sidebar: #1a1a2e;
  --text: #1f2937;
  --text-light: #6b7280;
  --text-white: #f8fafc;
  --border: #e5e7eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ─── Login ──────────────────────────────────────────────────────── */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f0c29 0%, #1a1a2e 50%, #16213e 100%);
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 24px;
  margin-top: 16px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-subtitle {
  color: var(--text-light);
  font-size: 14px;
  margin-top: 4px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-card input {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  transition: border-color 0.2s;
}

.login-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.error-msg {
  color: var(--danger);
  font-size: 14px;
  min-height: 20px;
}

/* ─── Main Layout ────────────────────────────────────────────────── */

.main-screen {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  color: var(--text-white);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.nav-items {
  list-style: none;
  padding: 12px 8px;
  flex: 1;
}

.nav-item {
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 14px;
  margin-bottom: 4px;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 13px;
}

.btn-link:hover { color: var(--text-white); }

.content {
  margin-left: 240px;
  padding: 32px;
  flex: 1;
  min-width: 0; /* let flex children (tables, cards) shrink instead of overflowing the viewport */
}

/* Hamburger + overlay only ever appear below the mobile breakpoint (see @media block below) —
   hidden here so desktop layout is untouched. */
.mobile-header { display: none; }

.hamburger-btn {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  padding: 8px 12px;
  cursor: pointer;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 900;
}

.sidebar-overlay.active { display: block; }

/* ─── Dashboard Cards ────────────────────────────────────────────── */

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  margin-top: 8px;
}

.stat-card .stat-sub {
  font-size: 13px;
  margin-top: 4px;
}

.stat-card.online .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }

/* ─── Server Table ───────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

th {
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

tr:hover { background: rgba(0,0,0,0.02); }

/* ─── Status Badges ──────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-online { background: #d1fae5; color: #065f46; }
.badge-degraded { background: #fef3c7; color: #92400e; }
.badge-offline { background: #fee2e2; color: #991b1b; }
.badge-unknown { background: #e5e7eb; color: #4b5563; }
.badge-maintenance { background: #dbeafe; color: #1e40af; }

.badge-critical { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-active { background: #fee2e2; color: #991b1b; }
.badge-acknowledged { background: #fef3c7; color: #92400e; }
.badge-resolved { background: #d1fae5; color: #065f46; }

/* ─── Progress Bars ──────────────────────────────────────────────── */

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.progress-bar .fill.low { background: var(--success); }
.progress-bar .fill.mid { background: var(--warning); }
.progress-bar .fill.high { background: var(--danger); }

/* ─── Buttons ────────────────────────────────────────────────────── */

.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.btn:hover { border-color: var(--primary); color: var(--primary); }

.btn-sm {
  padding: 4px 12px;
  font-size: 13px;
}

.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-success { color: var(--success); border-color: var(--success); }

/* ─── Forms ──────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ─── Modal ──────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px;
  width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ─── Alert items ────────────────────────────────────────────────── */

.alert-item {
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: start;
}

.alert-item.critical { background: #fef2f2; border-left: 4px solid var(--danger); }
.alert-item.warning { background: #fffbeb; border-left: 4px solid var(--warning); }
.alert-item.info { background: #eff6ff; border-left: 4px solid #3b82f6; }

.alert-item .alert-title { font-weight: 600; font-size: 14px; }
.alert-item .alert-msg { font-size: 13px; color: var(--text-light); margin-top: 4px; }
.alert-item .alert-time { font-size: 12px; color: var(--text-light); }

/* ─── Responsive ─────────────────────────────────────────────────── */
/*
 * Below 900px the sidebar goes fully off-canvas (not just narrower) — a fixed-width sidebar,
 * even an icon-only one, was eating a third or more of a phone's width for zero navigation
 * value once .nav-item text was hidden entirely. Same pattern already proven on SysAdminHCP's
 * own admin/client themes: transform-based slide-in + backdrop overlay + hamburger toggle.
 */
@media (max-width: 900px) {
  .sidebar {
    width: 260px;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-header span, .nav-item { display: block; } /* undo the old icon-only collapse */

  .content { margin-left: 0; padding: 16px; }
  .mobile-header { display: flex; margin-bottom: 16px; }
  .hamburger-btn { display: inline-flex; align-items: center; }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }

  /* Every dynamically-rendered page wraps its tables in .card — give that wrapper horizontal
     scroll instead of letting a wide table blow out the whole page width. */
  .card { overflow-x: auto; padding: 16px; }
  table { min-width: 560px; } /* keeps columns legible while scrolling rather than crushing them */

  /* !important: several modals set their own inline width (e.g. style="width:560px") for
     desktop, which otherwise beats this class rule outright regardless of media query. */
  .modal { width: 92vw !important; max-width: 92vw; padding: 20px; }

  /* iOS Safari zooms the whole page on focusing any input under 16px — same fix as SysAdminHCP. */
  input, select, textarea { font-size: 16px !important; }

  .modal-actions { flex-wrap: wrap; }
  .card-header { flex-wrap: wrap; gap: 8px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .login-card { width: 92vw; padding: 32px 24px; }
}

/* ─── Fleet search ───────────────────────────────────────────────── */

.fleet-search {
  position: relative;
  margin-bottom: 20px;
}

.fleet-search input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: var(--bg-card);
  box-shadow: var(--shadow);
}

.fleet-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.fleet-search-results {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--bg-card);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  margin-top: 6px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
}

.fleet-hit {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.fleet-hit:hover { background: rgba(79, 70, 229, 0.04); }
.fleet-hit:last-child { border-bottom: none; }
.fleet-hit .hit-name { font-weight: 600; font-size: 14px; }
.fleet-hit .hit-server { font-size: 12px; color: var(--text-light); }

/* ─── WebSocket indicator ────────────────────────────────────────── */

#ws-indicator { font-size: 12px; color: #4b5563; transition: color 0.3s; }
#ws-indicator.connected { color: var(--success); }

/* ─── Sparklines ─────────────────────────────────────────────────── */

.sparkline-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.sparkline-row:last-child { border-bottom: none; }
.sparkline-label { width: 90px; font-size: 13px; color: var(--text-light); flex-shrink: 0; }
.sparkline { flex: 1; height: 32px; display: block; }