/* =====================================================
   analysis.css — styles for analysis.html only
   ===================================================== */

body {
  overflow: auto;
  background: #f3f4f6;
  font-family: 'Titillium Web', sans-serif;
}

/* ── Layout ─────────────────────────────────────────── */

#analysis-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 16px 32px;
}

#analysis-wrap h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 12px 0 14px;
  color: #111;
}

/* ── Panel card ──────────────────────────────────────── */

.an-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.an-panel-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 10px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.an-panel-title::before {
  content: '▾';
  font-size: 0.9em;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.an-panel.collapsed .an-panel-title {
  margin-bottom: 0;
}

.an-panel.collapsed .an-panel-title::before {
  transform: rotate(-90deg);
}

.an-panel.collapsed > *:not(.an-panel-title) {
  display: none !important;
}

.an-panel-title-actions {
  margin-left: auto;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-size: 1rem;
}

/* ── Filter rows ─────────────────────────────────────── */

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 10px;
}

.filter-row:last-child {
  margin-bottom: 0;
}

.filter-label {
  font-size: 0.82rem;
  color: #374151;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.filter-label span {
  font-size: 0.72rem;
  color: #9ca3af;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

select, input[type="number"], input[type="text"] {
  font-family: 'Titillium Web', sans-serif;
  font-size: 0.88rem;
  height: 32px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  padding: 0 8px;
  background: #fff;
  color: #111;
  cursor: pointer;
}

select:focus, input[type="number"]:focus, input[type="text"]:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

input[type="number"] {
  width: 60px;
  cursor: text;
}

input[type="text"] {
  width: 150px;
  cursor: text;
}

/* ── Date slider ─────────────────────────────────────── */

#date-slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
  max-width: 320px;
}

#date-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #374151;
}

.date-preset-btns {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.date-preset-btns button {
  font-size: 0.72rem;
  padding: 2px 7px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #f9fafb;
  cursor: pointer;
  color: #374151;
  font-family: 'Titillium Web', sans-serif;
}

.date-preset-btns button:hover {
  background: #e5e7eb;
}

/* ── Split / radio group ─────────────────────────────── */

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.radio-group label {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: #374151;
}

.radio-group input[type="radio"] {
  cursor: pointer;
  accent-color: #3b82f6;
}

/* ── Limit row ───────────────────────────────────────── */

.limit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #374151;
}

.scatter-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  color: #374151;
  cursor: pointer;
}

.scatter-toggle input {
  accent-color: #3b82f6;
  cursor: pointer;
}

/* ── Summary text ────────────────────────────────────── */

#chart-summary {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 8px;
  line-height: 1.6;
}

.summary-filters {
  font-size: 0.75rem;
  color: #9ca3af;
}

/* ── Chart containers ────────────────────────────────── */

#main-chart-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
}

#comparison-chart-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
  margin-top: 12px;
}

/* ── Comparison section ──────────────────────────────── */

#toggle-comparison {
  font-size: 0.82rem;
  padding: 4px 12px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  background: #f9fafb;
  cursor: pointer;
  font-family: 'Titillium Web', sans-serif;
}

#toggle-comparison:hover {
  background: #e5e7eb;
}

#comparison-body {
  margin-top: 12px;
}

#comparison-body.hidden {
  display: none;
}

#slots-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.slot-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #f9fafb;
  border-radius: 6px;
  border-left: 4px solid #3b82f6;
}

.slot-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.slot-label {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 2px;
  flex-basis: 100%;
  padding-left: 18px;
}

.slot-row select {
  max-width: 170px;
}

.slot-remove {
  margin-left: auto;
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.slot-remove:hover {
  color: #ef4444;
}

.slot-move {
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 3px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  font-size: 0.65rem;
  color: #9ca3af;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.slot-move:hover:not(:disabled) {
  background: #e5e7eb;
  color: #374151;
  border-color: #9ca3af;
}

.slot-move:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.slot-move-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.slot-row.has-time-panel {
  border-radius: 6px 6px 0 0;
}

.slot-time-toggle {
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  height: 26px;
  padding: 0 6px;
  cursor: pointer;
  font-size: 0.82rem;
  color: #9ca3af;
  white-space: nowrap;
  flex-shrink: 0;
}

.slot-time-toggle:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.slot-time-toggle.active {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #3b82f6;
}

.slot-time-panel {
  padding: 8px 10px 6px;
  background: #f9fafb;
  border-left: 4px solid;
  border-right: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
  border-radius: 0 0 6px 6px;
}

.slot-time-panel .time-filter-group {
  margin-bottom: 6px;
}

.slot-time-panel .time-filter-group:last-child {
  margin-bottom: 0;
}

#add-slot-btn {
  font-size: 0.82rem;
  padding: 5px 12px;
  border: 1px dashed #9ca3af;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  color: #6b7280;
  font-family: 'Titillium Web', sans-serif;
}

#add-slot-btn:hover:not(:disabled) {
  border-color: #3b82f6;
  color: #3b82f6;
}

#add-slot-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Loading overlay ─────────────────────────────────── */

#an-loading {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}

#an-loading-inner {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 24px 36px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  font-size: 1rem;
  color: #374151;
}

#an-loading-inner .spinner {
  font-size: 1.6rem;
  display: block;
  margin-bottom: 8px;
  animation: spin 1s linear infinite;
}

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

#an-error {
  color: #ef4444;
  font-size: 0.85rem;
  margin-top: 8px;
}

#an-retry-btn {
  margin-top: 10px;
  padding: 6px 16px;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-family: 'Titillium Web', sans-serif;
  font-size: 0.9rem;
}

#an-retry-btn:hover {
  background: #2563eb;
}

/* ── Navbar "back" link ──────────────────────────────── */

.navbar-back {
  margin-left: auto;
  display: flex;
  align-items: center;
  padding: 0 12px;
  height: 40px;
  font-size: 0.9rem;
  text-decoration: none;
  color: #374151;
  white-space: nowrap;
}

.navbar-back:hover {
  color: #3b82f6;
}

/* ── No-data message ─────────────────────────────────── */

.no-data-msg {
  text-align: center;
  padding: 40px;
  color: #9ca3af;
  font-size: 0.95rem;
}

/* ── Include / Exclude mode toggle ──────────────────── */

.filter-mode-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
}

.filter-mode-btn {
  flex-shrink: 0;
  width: 28px;
  height: 32px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  font-family: 'Titillium Web', sans-serif;
  background: #f9fafb;
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.filter-mode-btn:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}

.filter-mode-btn.exclude {
  background: #fff7ed;
  border-color: #f59e0b;
  color: #d97706;
  font-weight: 700;
}

.filter-mode-btn.exclude:hover {
  background: #fef3c7;
}

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

.filter-mode-btn:disabled:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

select.exclude-mode {
  border-color: #f59e0b;
  background: #fffbeb;
}

/* ── Chip toggles (time filters) ─────────────────────── */

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 0.75rem;
  cursor: pointer;
  background: #f9fafb;
  color: #6b7280;
  user-select: none;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.chip.active {
  background: #3b82f6;
  color: #fff;
  border-color: #2563eb;
}

.chip:hover:not(.active) {
  background: #e5e7eb;
  border-color: #9ca3af;
}

.time-filter-group {
  width: 100%;
  margin-bottom: 8px;
}

.time-filter-group:last-child {
  margin-bottom: 0;
}

.time-filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chip-ctrl {
  font-size: 0.7rem;
  padding: 1px 7px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #f9fafb;
  cursor: pointer;
  color: #6b7280;
  font-family: 'Titillium Web', sans-serif;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.chip-ctrl:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}

/* ── Multi-select dropdown ───────────────────────────────── */

.ms-wrap {
  position: relative;
  display: inline-block;
}

.ms-trigger {
  font-family: 'Titillium Web', sans-serif;
  font-size: 0.88rem;
  height: 32px;
  min-width: 120px;
  padding: 0 22px 0 8px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  background: #fff;
  color: #111;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.ms-trigger::after {
  content: '▾';
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7em;
  color: #6b7280;
  pointer-events: none;
}

.ms-trigger:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

.ms-panel {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  z-index: 200;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  min-width: 180px;
  max-width: 300px;
  padding: 4px 0;
}

.ms-search {
  display: block;
  width: calc(100% - 16px);
  margin: 4px 8px 2px;
  height: 26px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 0 6px;
  font-family: 'Titillium Web', sans-serif;
  font-size: 0.82rem;
  box-sizing: border-box;
}

.ms-list {
  max-height: 200px;
  overflow-y: auto;
}

.ms-item {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #374151;
  user-select: none;
}

.ms-item:hover {
  background: #f3f4f6;
}

.ms-item input[type=checkbox] {
  cursor: pointer;
  accent-color: #3b82f6;
  flex-shrink: 0;
  margin-top: 2px;
}

.ms-wrap.exclude-mode .ms-trigger {
  border-color: #f59e0b;
  background: #fffbeb;
}

.slot-row .ms-trigger {
  min-width: 90px;
  max-width: 160px;
}
