@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');

:root {
  --bg-base: #0a0c16;
  --bg-sidebar: #0e1120;
  --bg-card: rgba(18, 22, 38, 0.85);
  --bg-card-hover: rgba(26, 32, 54, 0.95);
  --bg-input: #12162a;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.35);
  --brand: #6366f1;
  --brand-light: #818cf8;
  --brand-glow: rgba(99, 102, 241, 0.25);
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.2);
  --amber: #f59e0b;
  --rose: #ef4444;
  --cyan: #06b6d4;
  --fuchsia: #d946ef;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5), inset 0 1px 0 0 rgba(255, 255, 255, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(217, 70, 239, 0.06) 0%, transparent 40%);
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
}

/* Backdrop for Mobile Drawer */
#sidebarBackdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 45;
  transition: opacity 0.25s ease;
}

#sidebarBackdrop.active {
  display: block;
}

/* Sidebar */
aside.sidebar {
  width: 275px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  z-index: 50;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.traffic-lights {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 14px;
}

.traffic-light {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

.traffic-light.red { background-color: #ff5f56; }
.traffic-light.yellow { background-color: #ffbd2e; }
.traffic-light.green { background-color: #27c93f; }

.modder-credit {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-subtle);
}

.modder-credit span {
  color: var(--brand-light);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon-box {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.brand-title {
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Navigation items */
nav.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-section-title {
  font-size: 10.5px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  padding: 10px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8.5px 12px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.16s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.14);
  color: #fff;
  border-color: rgba(99, 102, 241, 0.4);
}

.nav-icon {
  font-size: 19px;
  transition: transform 0.2s ease;
}

.nav-item:hover .nav-icon {
  transform: scale(1.1);
}

.nav-badge {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--emerald);
  background: var(--emerald-glow);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* Main Area */
main.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

header.topbar {
  height: 60px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(10, 12, 22, 0.7);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.menu-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
}

.page-title-box h1 {
  font-size: 16.5px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
}

.page-title-box p {
  font-size: 11.5px;
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Viewport & Pages */
.viewport-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}

.view-page {
  display: none;
  max-width: 1440px;
  margin: 0 auto;
  flex-direction: column;
  gap: 20px;
}

.view-page.active {
  display: flex;
}

/* Grids */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 18px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-icon-wrap {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
}

.kpi-sub {
  font-size: 11.5px;
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Tables & Horizontal Scroll Container */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
}

table.data-table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

table.data-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 11px 16px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

table.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  vertical-align: middle;
  white-space: nowrap;
}

table.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges & Tags */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 2.5px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-badge.active {
  background: var(--emerald-glow);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.vip {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.status-badge.disabled {
  background: rgba(239, 68, 68, 0.12);
  color: var(--rose);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.status-badge.idle {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-subtle);
}

.tag-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-muted);
  white-space: nowrap;
}

.tag-pill.active {
  background: var(--emerald-glow);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  min-height: 38px;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  min-height: 32px;
  border-radius: 6px;
}

/* Form Controls */
.input-control, .select-control {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  color: #fff;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  min-height: 38px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-control:focus, .select-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

/* Progress bar */
.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand) 0%, var(--fuchsia) 100%);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Code Snippet Box */
.code-box-container {
  background: #070911;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.code-tabs {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.code-tab-btn {
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.code-tab-btn.active {
  color: #fff;
  border-bottom-color: var(--brand);
}

.code-pre {
  padding: 16px;
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: #cbd5e1;
  line-height: 1.6;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Terminal Console Box */
.terminal-window {
  background: #05060b;
  border: 1px solid #1a2035;
  border-radius: var(--radius-md);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  height: 480px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.terminal-header {
  padding: 8px 14px;
  background: #0c0e18;
  border-bottom: 1px solid #1a2035;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.terminal-body {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #34d399;
}

.terminal-line {
  word-break: break-all;
  line-height: 1.5;
}

/* Chat Container */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  min-height: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chat-header {
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-bubble {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: 4px;
}

.chat-input-bar {
  padding: 14px 18px;
  background: rgba(14, 17, 31, 0.95);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input-bar textarea {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: #fff;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  height: 48px;
  outline: none;
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #111425;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: modal-pop 0.2s ease-out;
}

@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover {
  color: #fff;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #14182a;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 11px 16px;
  font-size: 12.5px;
  color: #fff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  min-width: 260px;
  max-width: 90vw;
}

.toast.success { border-color: rgba(16, 185, 129, 0.4); }
.toast.success .toast-icon { color: var(--emerald); }
.toast.error { border-color: rgba(239, 68, 68, 0.4); }
.toast.error .toast-icon { color: var(--rose); }

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ==========================================================
   Mobile & Responsive Adaptations (HP / Mobile Friendly)
   ========================================================== */
@media (max-width: 1023px) {
  aside.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
  }

  aside.sidebar.mobile-open {
    transform: translateX(0);
  }

  .menu-toggle {
    display: inline-flex;
  }

  header.topbar {
    padding: 0 16px;
    height: 56px;
  }

  .viewport-container {
    padding: 14px;
  }

  .grid-4, .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }

  .kpi-card {
    padding: 16px;
  }

  .kpi-value {
    font-size: 22px;
  }

  .chat-bubble {
    max-width: 92%;
  }

  .modal-card {
    padding: 18px;
    max-width: 95vw;
  }
}
