/* ============================================================
   YassirOps Enterprise Console
   Design System v2 — Ops Console Aesthetic
   Inspired by: Datadog, PagerDuty, Grafana, Linear
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&family=Manrope:wght@600;700;800&display=swap');

/* ---- DESIGN TOKENS ----------------------------------------- */
:root {
  /* Surface */
  --c-bg:        #0d1117;
  --c-surface:   #161b22;
  --c-surface-2: #1c2230;
  --c-surface-3: #21283a;

  /* Border */
  --c-border:    #2a3547;
  --c-border-2:  #1e2a3a;

  /* Accent — Teal (distinctive, not purple) */
  --c-teal:      #00c7a3;
  --c-teal-dim:  rgba(0, 199, 163, 0.15);
  --c-teal-text: #00e0b8;

  /* Semantic */
  --c-green:     #3fb950;
  --c-green-dim: rgba(63, 185, 80, 0.12);
  --c-amber:     #d29922;
  --c-amber-dim: rgba(210, 153, 34, 0.12);
  --c-red:       #f85149;
  --c-red-dim:   rgba(248, 81, 73, 0.12);
  --c-blue:      #388bfd;

  /* Text */
  --c-text:      #c9d1d9;
  --c-text-muted:#8b949e;
  --c-text-dim:  #484f58;
  --c-white:     #f0f6fc;

  /* Radius */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;

  /* Transition */
  --t: 140ms ease;
}

/* ---- RESET -------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---- LAYOUT SHELL ------------------------------------------ */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---- SIDEBAR ----------------------------------------------- */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  width: 28px;
  height: 28px;
  background: var(--c-teal);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo svg {
  width: 16px;
  height: 16px;
  color: #000;
}

.sidebar-wordmark {
  font-family: 'Manrope', sans-serif;
  font-size: 15px;
  font-weight: 800;
  color: var(--c-white);
  letter-spacing: -0.3px;
}

.sidebar-env {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-teal);
  margin-top: 1px;
}

/* Nav */
.nav-section {
  padding: 10px 8px 4px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-text-dim);
  padding: 8px 8px 4px;
  display: block;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--r-md);
  color: var(--c-text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--t), color var(--t);
}

.nav a svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--t);
}

.nav a:hover {
  background: var(--c-surface-2);
  color: var(--c-white);
}

.nav a:hover svg { opacity: 0.9; }

.nav a.active {
  background: var(--c-teal-dim);
  color: var(--c-teal-text);
  font-weight: 600;
}

.nav a.active svg {
  opacity: 1;
  color: var(--c-teal-text);
}

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: 9px;
}

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--c-surface-3);
  border: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text);
  flex-shrink: 0;
  font-family: 'IBM Plex Mono', monospace;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--c-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 10.5px;
  color: var(--c-text-muted);
}

.sidebar-logout {
  font-size: 11px;
  color: var(--c-text-muted);
  padding: 4px 6px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border);
  background: transparent;
  transition: all var(--t);
  white-space: nowrap;
}

.sidebar-logout:hover {
  background: var(--c-red-dim);
  color: var(--c-red);
  border-color: var(--c-red);
}

/* ---- MAIN CONTENT AREA ------------------------------------ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Top bar */
.topbar {
  height: 52px;
  min-height: 52px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--c-surface);
  gap: 16px;
}

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

.topbar-title {
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--c-white);
}

.topbar-sep {
  color: var(--c-text-dim);
  font-size: 16px;
  font-weight: 300;
}

.topbar-subtitle {
  font-size: 12.5px;
  color: var(--c-text-muted);
}

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

/* Status indicator pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--c-text-muted);
}

.status-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-green);
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---- PAGE CONTENT ----------------------------------------- */
.page-content {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---- GRID -------------------------------------------------- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.col-span-2 { grid-column: span 2; }

/* ---- SURFACE CARDS ---------------------------------------- */
.surface {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
}

.surface-pad { padding: 16px 20px; }

/* ---- STAT CARDS ------------------------------------------- */
.stat {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  transition: border-color var(--t);
}

.stat:hover {
  border-color: var(--c-border-2);
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg {
  width: 14px;
  height: 14px;
}

.stat-num {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 28px;
  font-weight: 500;
  color: var(--c-white);
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 8px;
}

.stat-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--c-text-muted);
}

.delta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 5px;
  border-radius: var(--r-sm);
}

.delta-up { background: var(--c-green-dim); color: var(--c-green); }
.delta-down { background: var(--c-red-dim); color: var(--c-red); }

/* ---- STATUS BADGES ---------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  font-size: 11.5px;
  font-weight: 500;
}

.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-green, .badge-active, .badge-DELIVERED {
  background: var(--c-green-dim);
  color: var(--c-green);
}

.badge-amber, .badge-pending, .badge-ASSIGNED, .badge-IN_TRANSIT {
  background: var(--c-amber-dim);
  color: var(--c-amber);
}

.badge-red, .badge-rejected, .badge-CANCELLED {
  background: var(--c-red-dim);
  color: var(--c-red);
}

.badge-teal {
  background: var(--c-teal-dim);
  color: var(--c-teal-text);
}

.badge-neutral {
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  border: 1px solid var(--c-border);
}

/* ---- TOOLBAR ---------------------------------------------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 360px;
}

.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--c-text-dim);
  pointer-events: none;
}

.input-search {
  width: 100%;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 7px 12px 7px 32px;
  color: var(--c-white);
  font-size: 13px;
  outline: none;
  transition: border-color var(--t);
}

.input-search:focus {
  border-color: var(--c-teal);
}

.input-search::placeholder {
  color: var(--c-text-dim);
}

.select-filter {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 7px 10px;
  color: var(--c-text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--t);
}

.select-filter:focus {
  border-color: var(--c-teal);
}

/* ---- TABLE ------------------------------------------------- */
.table-wrap {
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table thead {
  background: var(--c-surface-2);
}

.table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-text-muted);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}

.table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--c-border-2);
  color: var(--c-text);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: var(--c-surface-2);
}

.td-mono {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  color: var(--c-teal-text);
}

.td-primary {
  font-weight: 600;
  color: var(--c-white);
}

.td-muted {
  font-size: 12px;
  color: var(--c-text-muted);
  margin-top: 2px;
}

/* ---- BUTTONS ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  outline: none;
  transition: all var(--t);
  white-space: nowrap;
  font-family: inherit;
  line-height: 1;
}

/* Primary — teal solid */
.btn-primary {
  background: var(--c-teal);
  color: #000d0a;
  font-weight: 600;
  border-color: var(--c-teal);
}

.btn-primary:hover {
  background: #00e0b8;
  border-color: #00e0b8;
}

/* Secondary — ghost border */
.btn-secondary {
  background: transparent;
  color: var(--c-text);
  border-color: var(--c-border);
}

.btn-secondary:hover {
  background: var(--c-surface-2);
  border-color: var(--c-border);
  color: var(--c-white);
}

/* Danger */
.btn-danger {
  background: transparent;
  color: var(--c-red);
  border-color: var(--c-red);
}

.btn-danger:hover {
  background: var(--c-red-dim);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--c-text-muted);
  border-color: transparent;
  padding: 6px 10px;
}

.btn-ghost:hover {
  background: var(--c-surface-2);
  color: var(--c-white);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---- SECTION HEADER --------------------------------------- */
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--c-white);
}

.section-desc {
  font-size: 12.5px;
  color: var(--c-text-muted);
  margin-top: 2px;
}

/* ---- FORMS ------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input, .form-select {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 9px 12px;
  color: var(--c-white);
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
  transition: border-color var(--t);
}

.form-input:focus, .form-select:focus {
  border-color: var(--c-teal);
}

.form-hint {
  font-size: 11.5px;
  color: var(--c-text-muted);
}

/* ---- MODAL ------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 440px;
  padding: 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  transform: translateY(8px);
  transition: transform 0.15s ease;
}

.modal-backdrop.active .modal {
  transform: translateY(0);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--c-border);
}

.modal-title {
  font-family: 'Manrope', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--c-white);
}

.modal-close {
  background: none;
  border: 1px solid var(--c-border);
  color: var(--c-text-muted);
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  transition: all var(--t);
}

.modal-close:hover {
  background: var(--c-red-dim);
  border-color: var(--c-red);
  color: var(--c-red);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

/* ---- INFO BOX ---------------------------------------------- */
.info-box {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.info-box-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--c-text-muted);
  margin-bottom: 4px;
}

.info-box-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
  font-weight: 500;
  color: var(--c-teal-text);
}

/* ---- MAP --------------------------------------------------- */
.map-container {
  height: 360px;
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  background: #080c14;
  overflow: hidden;
  position: relative;
}

#telemetryMap {
  width: 100%;
  height: 100%;
}

/* ---- FEED -------------------------------------------------- */
.feed-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--c-border-2);
  font-size: 13px;
}

.feed-item:last-child { border-bottom: none; }

.feed-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.feed-dot-green { background: var(--c-green); }
.feed-dot-amber { background: var(--c-amber); }
.feed-dot-teal  { background: var(--c-teal); }
.feed-dot-dim   { background: var(--c-text-dim); }

.feed-text {
  font-weight: 500;
  color: var(--c-white);
  line-height: 1.3;
}

.feed-sub {
  font-size: 11.5px;
  color: var(--c-text-muted);
  margin-top: 2px;
}

/* ---- LIVE DOT --------------------------------------------- */
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-green);
  animation: blink 2s ease-in-out infinite;
}

/* ---- CODE BLOCK ------------------------------------------- */
.code-block {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--c-green);
  overflow-x: auto;
  line-height: 1.7;
}

.code-comment { color: var(--c-text-dim); }
.code-key     { color: var(--c-text-muted); }
.code-str     { color: var(--c-amber); }
.code-num     { color: var(--c-blue); }

/* ---- ENDPOINT CARD ---------------------------------------- */
.endpoint-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  transition: border-color var(--t);
}

.endpoint-card:hover { border-color: var(--c-teal-dim); }

.endpoint-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.method {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 7px;
  border-radius: var(--r-sm);
}

.method-get  { background: var(--c-green-dim); color: var(--c-green); }
.method-post { background: var(--c-amber-dim); color: var(--c-amber); }

.endpoint-path {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  color: var(--c-white);
}

.endpoint-desc {
  font-size: 12.5px;
  color: var(--c-text-muted);
}

/* ---- AUDIT TABLE ------------------------------------------ */
.audit-action {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.audit-details {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--c-text-dim);
  background: var(--c-surface-2);
  padding: 3px 7px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border-2);
}

/* ---- RESPONSIVE ------------------------------------------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .app-shell { flex-direction: column; height: auto; }
  .sidebar { width: 100%; min-width: unset; height: auto; overflow: visible; }
  .main { min-height: 100vh; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 16px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .col-span-2 { grid-column: span 1; }
}
