/* ==========================================================================
   regAssist Monitor — Extraction Dashboard Stylesheet
   ========================================================================== */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: #f9fafb;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.5;
}

/* --- Navigation Bar --- */
.navbar {
  display: flex;
  align-items: center;
  background: #1e3a5f;
  color: #fff;
  padding: 0.6rem 1.25rem;
  gap: 1rem;
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.05rem;
  flex: 1;
  white-space: nowrap;
}

.navbar-links a {
  color: #fff;
  text-decoration: none;
  margin-right: 1rem;
  font-size: 0.9rem;
}
.navbar-links a:hover { text-decoration: underline; }
.navbar-links a.nav-active { font-weight: 700; text-decoration: underline; }

/* --- Environment Toggle --- */
.env-toggle { display: flex; gap: 0.5rem; }
.env-btn {
  color: #fff;
  text-decoration: none;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #fff;
  font-size: 0.82rem;
}
.env-btn.nav-active {
  background: #fff;
  color: #1e3a5f;
  font-weight: 700;
}

/* --- Infrastructure Status Dots --- */
.infra-status { display: flex; gap: 0.75rem; align-items: center; margin-right: 0.5rem; }
.infra-dot { font-size: 0.8rem; color: #9ca3af; white-space: nowrap; }
.infra-dot.up { color: #4ade80; }
.infra-dot.down { color: #f87171; }

/* --- Content Container --- */
.container {
  padding: 1rem 2rem;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 44px);  /* subtract navbar height */
  overflow: hidden;
}

/* --- Cards --- */
.cards { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.card {
  flex: 1;
  min-width: 130px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.85rem 1.1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  user-select: none;
}
.card:hover { box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); }
.card h3 {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
}
.card .count { font-size: 2.2rem; font-weight: 700; line-height: 1; }
.card .sub { font-size: 0.75rem; color: #6b7280; margin-top: 0.2rem; }

/* Card active state */
.card.card-active { background: #1e3a5f; color: #fff; border-color: #1e3a5f; }
.card-active h3 { color: rgba(255, 255, 255, 0.8); }
.card-active .sub { color: rgba(255, 255, 255, 0.7); }
.card-active .count { color: #fff !important; }

/* Card-based table filtering */
.filter-card {
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.filter-card:hover {
    opacity: 0.85;
}
.filter-card.card-filter-active {
    outline: 2px solid #1e3a5f;
    background: #e0e7ef;
}
.filter-card[data-status="total"] {
    cursor: default;
}

/* --- Status Colors --- */
.status-pending, .card-pending .count { color: #6b7280; }   /* grey */
.status-queued, .card-queued .count   { color: #d97706; }   /* amber */
.status-running, .card-running .count { color: #2563eb; }   /* blue */
.status-processing .count             { color: #2563eb; }
.status-completed, .card-completed .count { color: #059669; } /* green */
.status-failed, .card-failed .count   { color: #dc2626; }   /* red */
.status-discarded, .card-discarded .count { color: #9333ea; }

/* --- Tables --- */
.table-container {
  flex: 1 1 auto;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

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

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f0f4f8;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #374151;
  padding: 0.45rem 0.6rem;
  border-bottom: 2px solid #dce4ed;
  text-align: left;
  white-space: nowrap;
}

tbody td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
}

/* Zebra striping */
tbody tr:nth-child(even) { background: #f9fafb; }
tbody tr:hover { background: #eef2f7; }

td.error-msg { max-width: 400px; word-break: break-word; }

.table-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; color: #1e3a5f; }
.row-count { color: #6b7280; margin-bottom: 0.4rem; font-size: 0.85rem; }

/* --- Section Layout --- */
.section { margin-bottom: 2.5rem; }
.section-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid #dce4ed;
  padding-bottom: 0.6rem;
}
.section-header h2 { margin: 0; font-size: 1.2rem; color: #1e3a5f; }

/* --- Sub-Tabs (underline style) --- */
.sub-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 1rem;
}
.sub-tab {
  padding: 0.5rem 1.1rem;
  cursor: pointer;
  font-size: 0.88rem;
  color: #6b7280;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.sub-tab:hover { color: #1e3a5f; }
.sub-tab.active {
  color: #1e3a5f;
  font-weight: 600;
  border-bottom-color: #1e3a5f;
}

/* --- Auto-Pause Banner --- */
.auto-pause-banner {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: #92400e;
}
.auto-pause-banner i { color: #d97706; }

/* --- Control Buttons --- */
.control-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  cursor: pointer;
  font-size: 0.85rem;
  background: #fff;
  transition: background 0.15s;
}
.control-btn:hover { background: #f3f4f6; }
.control-btn.paused { background: #fef3c7; border-color: #d97706; color: #92400e; }
.control-btn.running { background: #d1fae5; border-color: #059669; color: #14532d; }
.control-btn.unavailable { background: #f3f4f6; border-color: #9ca3af; color: #6b7280; cursor: not-allowed; }
.control-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* --- Window Toggle --- */
.window-toggle { display: flex; gap: 0.5rem; margin-bottom: 1rem; align-items: center; }
.window-toggle span { font-size: 0.85rem; color: #6b7280; margin-right: 0.4rem; }
.window-btn {
  padding: 0.25rem 0.7rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.82rem;
}
.window-btn:hover { background: #f3f4f6; }
.window-btn.win-active { background: #1e3a5f; color: #fff; border-color: #1e3a5f; font-weight: 600; }

/* --- Tab Panes — fill available space, scroll internally --- */
.tab-pane {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;       /* allow flex child to shrink below content */
  overflow: hidden;
}
.tab-pane > div {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.tab-pane .table-container {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

/* --- Crawl 3-column layout — each column scrolls independently --- */
/* Compact cards inside crawl columns */
.crawl-column .cards { gap: 0.4rem; margin-bottom: 0.5rem; }
.crawl-column .card {
  min-width: 0;
  padding: 0.3rem 0.5rem;
}
.crawl-column .card .count { font-size: 1.2rem; }
.crawl-column .card .sub { font-size: 0.65rem; }

.crawl-columns {
  display: grid;
  grid-template-columns: 2fr 3fr 3fr;
  gap: 1rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.crawl-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.crawl-column .table-container {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

@media (max-width: 1024px) {
  .crawl-columns { grid-template-columns: 1fr !important; }
}

/* --- Loading Spinner --- */
.loading-spinner {
  padding: 2rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.95rem;
}
.loading-spinner i { margin-right: 0.5rem; }

/* --- Sortable Headers --- */
thead th[style*="cursor"] { user-select: none; }
thead th:hover { background: #e2e8f0; }

/* --- Utility --- */
.text-muted { color: #6b7280; }
.text-sm { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.hidden { display: none; }
