/* NWT Monitor — Minimal Custom CSS (Tailwind handles most styling) */

/* Nav Links */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  color: #94a3b8;
  text-decoration: none;
  transition: all 0.2s;
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-link:hover {
  background: rgba(51, 65, 85, 0.5);
  color: #e2e8f0;
}

.nav-link.active {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border-left: 3px solid #f59e0b;
}

.nav-link i {
  width: 18px;
  height: 18px;
}

/* Detail Panel Animations */
#panel-backdrop.visible {
  opacity: 1;
  pointer-events: all;
}

#detail-panel.open {
  transform: translateX(0);
}

/* RAG Bar (Custom Segments) */
.rag-bar {
  display: flex;
  height: 48px;
  border-radius: 0.5rem;
  overflow: hidden;
  background: #1e293b;
}

.rag-bar .segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: white;
  transition: flex 0.3s ease;
}

.rag-bar .segment.red {
  background: #ef4444;
}

.rag-bar .segment.amber {
  background: #f59e0b;
}

.rag-bar .segment.green {
  background: #22c55e;
}

.rag-bar .segment.known {
  background: #a855f7;
}

.rag-bar .segment.skip {
  background: #8B4513;
}

.rag-bar .segment:hover {
  filter: brightness(1.1);
}

/* RAG Dots */
.rag-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.rag-dot.RED {
  background: #ef4444;
}

.rag-dot.AMBER {
  background: #f59e0b;
}

.rag-dot.GREEN {
  background: #22c55e;
}

.rag-dot.KNOWN {
  background: #a855f7;
}

.rag-dot.SKIP, .rag-dot.OFFLINE {
  background: #8B4513;
}

/* Review Checkboxes */
.review-checkbox {
  accent-color: #f59e0b;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.review-checkbox:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Platform Badges */
.platform-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  border-width: 1px;
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(245, 158, 11, 0.3);
  border-top-color: #f59e0b;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Report iframe */
.report-iframe {
  width: 100%;
  height: 600px;
  border: none;
  border-radius: 0.5rem;
  background: white;
}

/* Run log container */
.run-log {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 0.5rem;
  padding: 1rem;
  max-height: 400px;
  overflow-y: auto;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.85rem;
}

.log-line {
  padding: 4px 0;
  color: #cbd5e1;
}

.log-line.success {
  color: #22c55e;
}

.log-line.error {
  color: #ef4444;
}

.log-line.warning {
  color: #f59e0b;
}

.log-line.info {
  color: #94a3b8;
}

/* Smooth scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #0f172a;
}

::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Site Map */
#site-map {
  height: 400px;
  border-radius: 0.5rem;
  z-index: 1;
}

#site-map .leaflet-popup-content-wrapper {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

#site-map .leaflet-popup-content {
  margin: 10px 14px;
  font-size: 0.85rem;
  line-height: 1.5;
}

#site-map .leaflet-popup-tip {
  background: #1e293b;
  border: 1px solid #334155;
}

#site-map .leaflet-control-zoom a {
  background: #1e293b;
  color: #e2e8f0;
  border-color: #334155;
}

#site-map .leaflet-control-zoom a:hover {
  background: #334155;
}

#site-map .leaflet-control-attribution {
  background: rgba(15, 23, 42, 0.8) !important;
  color: #64748b !important;
  font-size: 0.65rem;
}

#site-map .leaflet-control-attribution a {
  color: #94a3b8 !important;
}

/* Sub-tabs (within page content) */
.sub-tab {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #94a3b8;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}
.sub-tab:hover {
  color: #e2e8f0;
  background: rgba(51, 65, 85, 0.5);
}
.sub-tab.active {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
}

/* Sparkline indicators */
.sparkline {
  display: inline-flex;
  gap: 2px;
  align-items: center;
  vertical-align: middle;
}

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

.sparkline-dot.RED { background: #ef4444; }
.sparkline-dot.AMBER { background: #f59e0b; }
.sparkline-dot.GREEN { background: #22c55e; }
.sparkline-dot.KNOWN { background: #a855f7; }
.sparkline-dot.SKIP { background: #8B4513; }

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Mobile bottom nav */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0f172a;
  border-top: 1px solid #1e293b;
  z-index: 100;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 60px;
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #64748b;
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 500;
  padding: 4px 2px;
  flex: 1;
  min-width: 0;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-btn i {
  width: 20px;
  height: 20px;
}

.mobile-nav-btn.active {
  color: #f59e0b;
}

.mobile-nav-btn:active {
  color: #f59e0b;
}

/* Mobile card layout for tables */
.mobile-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 0.75rem;
  padding: 0.875rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.mobile-card:active {
  background: #334155;
}

.mobile-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.mobile-card-title {
  font-weight: 600;
  color: #f1f5f9;
  font-size: 0.9rem;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.75rem;
  color: #94a3b8;
}

.mobile-card-detail {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 0.375rem;
  line-height: 1.4;
}

.mobile-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  /* Show mobile nav, hide sidebar */
  .mobile-nav {
    display: block;
  }

  /* Sidebar */
  nav.w-64,
  .desktop-sidebar {
    display: none !important;
  }

  /* Main content area */
  .flex.h-screen {
    flex-direction: column;
  }

  main.flex-1 {
    padding-bottom: 70px; /* space for bottom nav */
  }

  #main-content {
    padding: 1rem !important;
  }

  /* Page titles smaller */
  #main-content h2.text-3xl {
    font-size: 1.5rem;
  }

  /* Dashboard RAG cards — 3 across */
  .grid.grid-cols-2.md\\:grid-cols-3.lg\\:grid-cols-6 {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.5rem !important;
  }

  .grid.grid-cols-2.md\\:grid-cols-3.lg\\:grid-cols-6 > div {
    padding: 0.75rem 0.5rem !important;
  }

  .grid.grid-cols-2.md\\:grid-cols-3.lg\\:grid-cols-6 .text-4xl {
    font-size: 1.75rem !important;
  }

  .grid.grid-cols-2.md\\:grid-cols-3.lg\\:grid-cols-6 .text-sm {
    font-size: 0.7rem !important;
  }

  /* Dashboard info row — 2 cols */
  .grid.grid-cols-2.md\\:grid-cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }

  /* Platform breakdown cards */
  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-3 {
    grid-template-columns: 1fr !important;
  }

  /* Settings grid */
  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-3 {
    grid-template-columns: 1fr !important;
  }

  /* Quick actions + status — stack */
  .grid.grid-cols-1.lg\\:grid-cols-2 {
    grid-template-columns: 1fr !important;
  }

  /* RAG bar */
  .rag-bar {
    height: 36px;
    font-size: 0.75rem;
  }

  /* Detail panel full width */
  #detail-panel {
    max-width: 100% !important;
  }

  #detail-content {
    padding: 1rem !important;
  }

  #detail-content h3.text-2xl {
    font-size: 1.25rem;
  }

  /* Report iframe */
  .report-iframe {
    height: 400px;
  }

  /* Site map */
  #site-map {
    height: 280px;
  }

  /* Run page pipeline steps */
  .flex.items-center.gap-4.mt-6 {
    flex-wrap: wrap;
    gap: 0.5rem !important;
  }

  .flex.items-center.gap-4.mt-6 > div {
    flex: 1 1 auto !important;
    min-width: 80px;
  }

  .flex.items-center.gap-4.mt-6 > .w-5 {
    display: none;
  }

  /* Run log */
  .run-log {
    max-height: 250px;
    font-size: 0.75rem;
    padding: 0.75rem;
  }

  /* Sites table — hidden on mobile, replaced by cards */
  .sites-table-desktop {
    display: none !important;
  }

  .sites-cards-mobile {
    display: block !important;
  }

  /* Known issues table — hidden on mobile, replaced by cards */
  .ki-table-desktop {
    display: none !important;
  }

  .ki-cards-mobile {
    display: block !important;
  }

  /* Run history table — horizontal scroll */
  .run-history-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .run-history-wrap table {
    min-width: 500px;
  }

  /* Reports section */
  .report-item-desktop {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }

  .report-item-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Compare section */
  .compare-controls {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .compare-controls select {
    width: 100%;
  }

  .compare-controls .compare-vs-text {
    text-align: center;
  }

  /* Modals */
  .fixed.inset-0 .w-full.max-w-lg,
  .fixed.inset-0 .w-full.max-w-md {
    max-width: 95vw !important;
    margin: 0.5rem;
  }

  /* Settings monitored sites */
  #ms-site-list {
    max-height: 300px !important;
  }

  /* Flex wrap for buttons */
  .flex.gap-3.mt-6,
  .flex.gap-3 {
    flex-wrap: wrap;
  }

  /* Header flex adjustments */
  .mb-8.flex.justify-between {
    flex-direction: column;
    gap: 0.75rem;
  }

  .mb-8.flex.justify-between button,
  .mb-8.flex.justify-between a {
    align-self: flex-start;
  }

  /* Platform filter buttons smaller */
  #platform-toggle button {
    padding: 0.375rem 0.5rem !important;
    font-size: 0.75rem !important;
  }

  /* RAG filter buttons smaller */
  button[data-rag] {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.7rem !important;
  }
}

/* Tiny screens (< 400px) */
@media (max-width: 400px) {
  .mobile-nav-btn {
    font-size: 0.6rem;
  }

  .mobile-nav-btn i {
    width: 18px;
    height: 18px;
  }

  #main-content {
    padding: 0.75rem !important;
  }

  .grid.grid-cols-2.md\\:grid-cols-3.lg\\:grid-cols-6 .text-4xl {
    font-size: 1.4rem !important;
  }
}

/* === Review Workflow === */
.review-card {
  transition: border-color 0.2s;
}
.review-card:hover {
  border-color: #475569;
}

.known-issue-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: #7c3aed;
  color: white;
  font-weight: bold;
  font-size: 0.75em;
  vertical-align: middle;
}
