/* ==========================================================================
   ani-cli-ar-backend Operations Dashboard — High-Contrast B&W Theme
   ========================================================================== */

:root, [data-bs-theme="light"], .light {
  color-scheme: light;
  --bg-main: #ffffff;
  --bg-sidebar: #f8fafc;
  --bg-card: #f8fafc;
  --bg-card-hover: #f1f5f9;
  --bg-subtle: #f1f5f9;
  --bg-border: #e2e8f0;
  --text-primary: #000000;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-glow: rgba(37, 99, 235, 0.15);
  --terminal-bg: #0f172a;
  --terminal-text: #f8fafc;
  --terminal-border: #334155;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, Monaco, monospace;
}

[data-bs-theme="dark"], .dark {
  color-scheme: dark;
  --bg-main: #000000;
  --bg-sidebar: #09090b;
  --bg-card: #0c0c0e;
  --bg-card-hover: #141417;
  --bg-subtle: #141417;
  --bg-border: #26262a;
  --text-primary: #ffffff;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --terminal-bg: #050508;
  --terminal-text: #f4f4f5;
  --terminal-border: #27272a;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, Monaco, monospace;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
  overflow-x: hidden;
}

/* Monospace font utility */
.font-mono {
  font-family: var(--font-mono) !important;
}

/* ASCII Header Art */
.ascii-art {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.15;
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-glow);
  white-space: pre;
  user-select: none;
  margin: 0;
  display: inline-block;
}

[data-bs-theme="dark"] .ascii-art {
  color: #3b82f6;
  text-shadow: 0 0 16px rgba(59, 130, 246, 0.45);
}

[data-bs-theme="light"] .ascii-art {
  color: #1e40af;
  text-shadow: none;
}

/* App Layout */
#app-container {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  width: 260px;
  min-width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--bg-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  position: relative;
}

#sidebar.collapsed {
  width: 72px;
  min-width: 72px;
}

#sidebar.collapsed .nav-text,
#sidebar.collapsed .badge-label,
#sidebar.collapsed .brand-title {
  display: none !important;
}

#sidebar.collapsed .nav-link {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

#sidebar .brand-header {
  height: 64px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--bg-border);
}

#sidebar .nav-items {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  color: var(--text-secondary);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
  margin-bottom: 3px;
  cursor: pointer;
  border: 1px solid transparent;
}

#sidebar .nav-link:hover {
  color: var(--text-primary);
  background-color: var(--bg-subtle);
}

#sidebar .nav-link.active {
  color: var(--text-primary);
  background-color: var(--bg-subtle);
  border-color: var(--bg-border);
  font-weight: 600;
}

[data-bs-theme="dark"] #sidebar .nav-link.active {
  background-color: #18181b;
  border-color: #27272a;
}

#sidebar .nav-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--bg-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Main Content Area */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-main);
}

/* Top Header */
#top-header {
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-main);
  border-bottom: 1px solid var(--bg-border);
  z-index: 90;
}

/* Scrollable Tab Views */
#tab-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Cards & Surfaces */
.card-surface {
  background-color: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: 16px;
  padding: 20px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.card-surface:hover {
  border-color: rgba(59, 130, 246, 0.3);
}

/* Metric KPI Cards */
.kpi-card {
  padding: 18px 20px;
  border-radius: 16px;
  background-color: var(--bg-card);
  border: 1px solid var(--bg-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
  letter-spacing: -0.5px;
  margin-top: 8px;
}

/* Terminal TUI Preview Box */
.terminal-window {
  background-color: var(--terminal-bg);
  border: 1px solid var(--terminal-border);
  border-radius: 12px;
  overflow: hidden;
  font-family: var(--font-mono);
  color: var(--terminal-text);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.terminal-header {
  background-color: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--terminal-border);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.terminal-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.terminal-dot.red { background-color: #ef4444; }
.terminal-dot.yellow { background-color: #f59e0b; }
.terminal-dot.green { background-color: #10b981; }

.terminal-title {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 500;
}

.terminal-body {
  padding: 16px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Terminal Box Drawing Borders */
.tui-box {
  border: 2px solid #3b82f6;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.tui-box.style-blue { border-color: #2563eb; }
.tui-box.style-sky { border-color: #0284c7; }
.tui-box.style-cyan { border-color: #0891b2; }
.tui-box.style-amber { border-color: #d97706; }
.tui-box.style-rose { border-color: #e11d48; }
.tui-box.style-slate { border-color: #475569; }

/* Custom Inputs & Controls */
.form-control, .form-select {
  background-color: var(--bg-subtle) !important;
  border: 1px solid var(--bg-border) !important;
  color: var(--text-primary) !important;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-glow) !important;
  outline: none;
}

.btn-primary-custom {
  background-color: var(--accent);
  color: #ffffff;
  border: none;
  font-weight: 600;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn-primary-custom:hover {
  opacity: 0.9;
  color: #ffffff;
}

.btn-secondary-custom {
  background-color: var(--bg-subtle);
  border: 1px solid var(--bg-border);
  color: var(--text-primary);
  font-weight: 500;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-secondary-custom:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
}

/* Badges */
.badge-custom {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-weight: 500;
  border: 1px solid transparent;
}

.badge-blue {
  background-color: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.25);
}

.badge-green {
  background-color: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.25);
}

.badge-amber {
  background-color: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.25);
}

.badge-red {
  background-color: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25);
}

/* Modals */
.modal-custom {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-content-custom {
  background-color: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: 20px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

/* Tables */
.table-custom {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table-custom th {
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--bg-border);
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table-custom td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--bg-border);
  color: var(--text-primary);
}

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

.table-custom tr:hover td {
  background-color: var(--bg-subtle);
}

/* Code & Traceback Snippets */
.code-block {
  background-color: var(--terminal-bg);
  border: 1px solid var(--terminal-border);
  color: var(--terminal-text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  white-space: pre;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--bg-border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
