/* ==========================================================================
   ITU RR Appendix 4 - Styles
   Professional light theme for internal use
   ========================================================================== */

/* -- CSS Custom Properties ------------------------------------------------ */
:root {
  --color-primary: #1a365d;
  --color-primary-light: #2c5282;
  --color-secondary: #2b6cb0;
  --color-bg: #f7fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-border-dark: #cbd5e0;
  --color-text: #2d3748;
  --color-text-muted: #718096;
  --color-text-light: #a0aec0;

  /* Marker colors */
  --marker-X-bg: #fed7d7;
  --marker-X-fg: #c53030;
  --marker-plus-bg: #fefcbf;
  --marker-plus-fg: #b7791f;
  --marker-O-bg: #bee3f8;
  --marker-O-fg: #2b6cb0;
  --marker-C-bg: #e9d8fd;
  --marker-C-fg: #6b46c1;
  --marker-blank-bg: #edf2f7;
  --marker-blank-fg: #a0aec0;

  /* Tag colors */
  --tag-coord-bg: #c6f6d5;
  --tag-coord-fg: #276749;
  --tag-sensor-bg: #feebc8;
  --tag-sensor-fg: #744210;
  --tag-orbit-bg: #bee3f8;
  --tag-orbit-fg: #2a4365;
  --tag-reg-bg: #e9d8fd;
  --tag-reg-fg: #553c9a;

  /* Semantic colors */
  --color-white: #fff;
  --color-section-bg: #edf2f7;
  --color-row-alt: #fafbfc;
  --color-highlight: #fefcbf;
  --color-primary-ring: rgba(43, 108, 176, 0.15);
  --color-separator: rgba(255, 255, 255, 0.15);

  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Cascadia Code", "Fira Code", "Consolas", monospace;

  --header-height: 60px;
  --row-height-min: 32px;
}

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

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

/* -- App Header ----------------------------------------------------------- */
.app-header {
  background: var(--color-primary);
  color: var(--color-white);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-links a {
  color: #fff;
  background: rgba(255,255,255,0.15);
  padding: 4px 12px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 12px;
  transition: background 0.15s;
}

.nav-links a:hover {
  background: rgba(255,255,255,0.3);
}

.app-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.app-header .subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.8;
}

/* -- Controls Bar --------------------------------------------------------- */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
  max-width: 80%;
  margin: 0 auto;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.search-box input {
  width: 100%;
  padding: 7px 32px 7px 12px;
  border: 1px solid var(--color-border-dark);
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--font-main);
  outline: none;
  transition: border-color 0.15s;
}

.search-box input:focus {
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 2px var(--color-primary-ring);
}

.search-box #clear-search {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  color: var(--color-text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
}

.search-box #clear-search:hover {
  color: var(--color-text);
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logic-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logic-label {
  font-size: 12px;
  color: var(--color-text-muted);
}

#logic-toggle-btn {
  padding: 4px 10px;
  border: 1px solid var(--color-border-dark);
  border-radius: 3px;
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--color-primary);
  text-align: center;
  transition: all 0.15s;
}

#logic-toggle-btn:hover {
  background: var(--color-bg);
}

#logic-toggle-btn[data-mode="OR"] {
  background: var(--color-secondary);
  color: var(--color-white);
  border-color: var(--color-secondary);
}

#expand-all,
#collapse-all,
#clear-all-filters {
  padding: 4px 10px;
  border: 1px solid var(--color-border-dark);
  border-radius: 3px;
  background: var(--color-surface);
  font-size: 11px;
  cursor: pointer;
  color: var(--color-text);
  transition: all 0.15s;
}

#expand-all:hover,
#collapse-all:hover,
#clear-all-filters:hover {
  background: var(--color-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
}

.depth-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--color-text-muted);
  cursor: default;
}
.depth-control input[type="range"] {
  width: 100px;
  accent-color: var(--color-primary);
}
.depth-val {
  display: inline-block;
  width: 18px;
  text-align: center;
  font-weight: 600;
  color: var(--color-primary);
  font-size: 12px;
}

/* -- Filter Panel --------------------------------------------------------- */
.filter-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  max-width: 80%;
  margin: 0 auto;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-group h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.optional-filters-section {
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
}

.optional-filters-label {
  margin: 0;
  padding: 0;
  width: 100%;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.optional-filters-section .filter-group {
  margin: 0;
}

.filter-buttons {
  display: flex;
  gap: 4px;
}

.filter-buttons button {
  padding: 4px 10px;
  border: 1px solid var(--color-border-dark);
  border-radius: 3px;
  background: var(--color-surface);
  font-size: 11px;
  cursor: pointer;
  color: var(--color-text);
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-buttons button:hover {
  background: var(--color-bg);
  border-color: var(--color-secondary);
}

.filter-buttons button.active {
  background: var(--color-secondary);
  color: var(--color-white);
  border-color: var(--color-secondary);
}

.filter-buttons button.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--color-section-bg);
  color: var(--color-text-light);
  border-color: var(--color-border);
}

.filter-buttons button.disabled:hover {
  background: var(--color-section-bg);
  border-color: var(--color-border);
}

/* Colored marker filter buttons */
.filter-buttons button.marker-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-weight: 600;
  border: 1px solid transparent;
  font-family: var(--font-main);
  font-size: 11px;
}

.marker-symbol {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
}

.marker-label {
  font-size: 11px;
  white-space: nowrap;
}

.filter-buttons button.marker-X {
  background: var(--marker-X-bg);
  color: var(--marker-X-fg);
  border-color: var(--marker-X-fg);
}

.filter-buttons button.marker-plus {
  background: var(--marker-plus-bg);
  color: var(--marker-plus-fg);
  border-color: var(--marker-plus-fg);
}

.filter-buttons button.marker-O {
  background: var(--marker-O-bg);
  color: var(--marker-O-fg);
  border-color: var(--marker-O-fg);
}

.filter-buttons button.marker-C {
  background: var(--marker-C-bg);
  color: var(--marker-C-fg);
  border-color: var(--marker-C-fg);
}

.filter-buttons button.marker-button:hover {
  opacity: 0.8;
  border-color: currentColor;
}

.filter-buttons button.marker-button.active {
  opacity: 1;
  font-weight: 700;
  box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 3px currentColor;
}

/* Primary selectors (Network Type + Filing Type) */
.primary-selectors {
  background: var(--color-section-bg);
  border-bottom: 2px solid var(--color-border-dark);
}

.primary-selectors .filter-buttons button {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
}

/* Summary inline (in primary selectors row) */
.summary-inline {
  margin-left: auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* -- Marker Badges -------------------------------------------------------- */
.marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 22px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 12px;
  font-family: var(--font-mono);
  line-height: 1;
}

.marker-X {
  background: var(--marker-X-bg);
  color: var(--marker-X-fg);
}

.marker-plus {
  background: var(--marker-plus-bg);
  color: var(--marker-plus-fg);
}

.marker-O {
  background: var(--marker-O-bg);
  color: var(--marker-O-fg);
}

.marker-C {
  background: var(--marker-C-bg);
  color: var(--marker-C-fg);
}

.marker-blank {
  background: var(--marker-blank-bg);
  color: var(--marker-blank-fg);
  font-weight: 400;
}

/* -- Table ---------------------------------------------------------------- */
.table-container {
  overflow: auto;
  max-height: calc(100vh - 280px);
  margin: 0 auto;
  border-bottom: 1px solid var(--color-border);
  max-width: 66.67%;
  padding: 0;
}

#data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 500px;
}

/* Column widths */
.col-id {
  width: 220px;
  min-width: 200px;
}

.col-label {
  width: auto;
  min-width: 400px;
}

/* -- Table Header --------------------------------------------------------- */
#data-table thead th {
  position: sticky;
  z-index: 10;
  background: var(--color-primary);
  color: var(--color-white);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 6px 4px;
  border-right: 1px solid var(--color-separator);
  white-space: nowrap;
  user-select: none;
}

/* Header row */
.header-group th {
  top: 0;
}

/* Marker column header */
.col-marker {
  width: 220px;
  min-width: 200px;
  text-align: center;
}

/* Sortable columns */
#data-table thead th.sortable {
  cursor: pointer;
  text-align: left;
}

#data-table thead th.sortable:hover {
  background: var(--color-primary-light);
}

.sort-icon::after {
  content: "\2195";
  margin-left: 4px;
  font-size: 10px;
  opacity: 0.5;
}

.sortable.sort-asc .sort-icon::after {
  content: "\2191";
  opacity: 1;
}

.sortable.sort-desc .sort-icon::after {
  content: "\2193";
  opacity: 1;
}

/* Sticky left columns */
#data-table thead th.col-id,
#data-table tbody td.col-id {
  position: sticky;
  left: 0;
  z-index: 5;
}

#data-table thead th.col-label,
#data-table tbody td.col-label {
  position: sticky;
  left: 220px;
  z-index: 5;
}

#data-table thead th.col-id,
#data-table thead th.col-label {
  z-index: 15;
}

/* -- Table Body ----------------------------------------------------------- */
#data-table tbody tr {
  border-bottom: 1px solid var(--color-border);
}

#data-table tbody tr:nth-child(even) {
  background: var(--color-row-alt);
}

#data-table tbody tr:hover {
  background: var(--color-section-bg);
}

#data-table tbody td {
  padding: 4px 6px;
  vertical-align: top;
  font-size: 12px;
}

#data-table tbody td.col-id {
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--color-primary);
  white-space: nowrap;
  border-right: 1px solid var(--color-border);
  padding-left: 6px;
}

/* Indentation for item IDs based on depth */
#data-table tbody tr.depth-2 td.col-id { padding-left: 30px; }
#data-table tbody tr.depth-3 td.col-id { padding-left: 54px; }
#data-table tbody tr.depth-4 td.col-id { padding-left: 78px; }
#data-table tbody tr.depth-5 td.col-id { padding-left: 102px; }

#data-table tbody tr:nth-child(even) td.col-id {
  background: var(--color-row-alt);
}

#data-table tbody tr:hover td.col-id,
#data-table tbody tr:hover td.col-label {
  background: var(--color-section-bg);
}

#data-table tbody tr.row-table-header:hover td,
#data-table tbody tr.row-table-header:hover td.col-id,
#data-table tbody tr.row-table-header:hover td.col-label {
  background: #243f6b;
}

#data-table tbody tr.row-table-header:nth-child(even) td.col-id,
#data-table tbody tr.row-table-header:nth-child(even) td.col-label {
  background: var(--color-primary);
}

#data-table tbody td.col-label {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  max-width: none;
}

#data-table tbody tr:nth-child(even) td.col-label {
  background: var(--color-row-alt);
}

#data-table tbody td.marker-cell {
  text-align: center;
  padding: 4px 2px;
  width: 50px;
  min-width: 40px;
}

/* Item label styling */
.item-label {
  font-weight: 600;
  color: var(--color-text);
  font-size: 12px;
}

.item-fulltext {
  color: var(--color-text-muted);
  font-size: 11px;
  margin-top: 2px;
  line-height: 1.4;
  overflow: visible;
  white-space: normal;
  word-wrap: break-word;
}

/* Table header rows (depth 0 items: Table A, B, C, D) */
#data-table tbody tr.row-table-header td,
#data-table tbody tr.row-table-header td.col-id,
#data-table tbody tr.row-table-header td.col-label,
#data-table tbody tr.row-table-header td.marker-cell {
  background: var(--color-primary);
  color: #fff;
  border-bottom: 2px solid var(--color-primary);
}

.row-table-header .item-label {
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
}

.row-table-header .tree-toggle {
  color: rgba(255, 255, 255, 0.7);
}

.row-table-header .tree-toggle:hover {
  color: #fff;
}

.row-table-header .marker {
  visibility: hidden;
}

/* Section header rows (depth 1 items like A.1, A.2, B.1, etc.) */
#data-table tbody tr.row-header td,
#data-table tbody tr.row-header td.col-id,
#data-table tbody tr.row-header td.col-label {
  background: var(--color-section-bg);
}

.row-header .item-label {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.3px;
}

/* Tree toggle arrow */
.tree-toggle {
  display: inline-block;
  width: 14px;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 9px;
  text-align: center;
  user-select: none;
  flex-shrink: 0;
}

.tree-toggle:hover {
  color: var(--color-secondary);
}

/* Depth-based indentation */
.depth-2 .item-label { padding-left: 16px; }
.depth-3 .item-label { padding-left: 32px; }
.depth-4 .item-label { padding-left: 48px; }
.depth-5 .item-label { padding-left: 64px; }

/* Tags display */
.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 3px;
}

.tag {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.tag-coord { background: var(--tag-coord-bg); color: var(--tag-coord-fg); }
.tag-sensor { background: var(--tag-sensor-bg); color: var(--tag-sensor-fg); }
.tag-orbit { background: var(--tag-orbit-bg); color: var(--tag-orbit-fg); }
.tag-reg { background: var(--tag-reg-bg); color: var(--tag-reg-fg); }

/* -- Footer --------------------------------------------------------------- */
.app-footer {
  padding: 8px 24px;
  text-align: center;
  font-size: 11px;
  color: var(--color-text-light);
}

/* -- No results ----------------------------------------------------------- */
.no-results {
  text-align: center;
  padding: 40px;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* -- Search highlight ----------------------------------------------------- */
mark {
  background: var(--color-highlight);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

/* -- Triple-state buttons: include / exclude / only ---------------------- */
.filter-buttons button[data-mode="include"] {
  background: var(--color-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
}

.filter-buttons button[data-mode="exclude"] {
  background: var(--marker-X-bg);
  color: var(--marker-X-fg);
  border-color: var(--marker-X-fg);
}

.filter-buttons button[data-mode="only"] {
  background: var(--marker-O-bg);
  color: var(--marker-O-fg);
  border-color: var(--marker-O-fg);
}

/* -- Responsive ----------------------------------------------------------- */
@media (max-width: 1024px) {
  .controls-bar,
  .filter-panel {
    max-width: 95%;
  }

  .table-container {
    max-width: 95%;
  }
}

@media (max-width: 640px) {
  .filter-panel {
    flex-direction: column;
    max-width: 100%;
    padding: 8px 12px;
  }

  .controls-bar {
    max-width: 100%;
    padding: 8px 12px;
  }

  .table-container {
    max-width: 100%;
  }

  #data-table {
    min-width: auto;
  }

  .search-box {
    min-width: 140px;
    max-width: none;
    flex: 1;
  }

  .col-id {
    width: 120px;
    min-width: 100px;
  }

  .col-label {
    min-width: 200px;
  }
}
