/* stats.css - 지진관측망 일일 파형 통계 분석 스타일시트 */

.stats-container {
  padding: 18px 24px 40px;
  max-width: 1600px;
  margin: 0 auto;
}

/* Header & KPI Summary Cards */
.stats-header-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
}

.stats-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stats-header-title h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
}

.stats-header-title span {
  font-size: 13px;
  color: #64748b;
}

.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stats-kpi-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
}

.stats-kpi-card .lbl {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
}

.stats-kpi-card .val {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
}

.stats-kpi-card.pass .val { color: #16a34a; }
.stats-kpi-card.warn .val { color: #d97706; }
.stats-kpi-card.fail .val { color: #dc2626; }
.stats-kpi-card.avail .val { color: #2563eb; }

/* Toolbar */
.stats-toolbar {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px 18px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.stats-toolbar-left,
.stats-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stats-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.stats-input,
.stats-select {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background-color: #f8fafc;
  color: #1e293b;
  outline: none;
}

.stats-input:focus,
.stats-select:focus {
  border-color: #2563eb;
  background-color: #ffffff;
}

.stats-btn {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 5px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
}

.stats-btn.primary {
  background: #2563eb;
  color: #ffffff;
}
.stats-btn.primary:hover { background: #1d4ed8; }

.stats-btn.secondary {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}
.stats-btn.secondary:hover { background: #e2e8f0; }

.stats-btn.success {
  background: #16a34a;
  color: #ffffff;
}
.stats-btn.success:hover { background: #15803d; }

.stats-btn.danger {
  background: #dc2626;
  color: #ffffff;
}
.stats-btn.danger:hover { background: #b91c1c; }

/* Status Badges */
.stats-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.stats-badge.pass { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.stats-badge.warn { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.stats-badge.fail { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* Table Container & 2-level Interactive Table */
.stats-table-wrap {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: center;
}

.stats-table th {
  background: #1e293b;
  color: #ffffff;
  padding: 10px 8px;
  font-weight: 600;
  border: 1px solid #334155;
  white-space: nowrap;
  user-select: none;
}

.stats-table th.sortable {
  cursor: pointer;
}
.stats-table th.sortable:hover {
  background: #334155;
}

.stats-table td {
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  color: #1e293b;
}

.stats-sta-row {
  cursor: pointer;
  transition: background 0.1s ease-in-out;
}

.stats-sta-row:hover {
  background: #f1f5f9;
}

.stats-sta-row.expanded {
  background: #e2e8f0;
  font-weight: 600;
}

.stats-chevron {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 11px;
  color: #64748b;
  margin-right: 4px;
}

.stats-sta-row.expanded .stats-chevron {
  transform: rotate(90deg);
  color: #2563eb;
}

/* Expandable Sub-table (Channels) */
.stats-sub-row {
  background: #f8fafc;
}

.stats-sub-wrap {
  padding: 12px 18px;
  border-top: 1px solid #cbd5e1;
  border-bottom: 2px solid #cbd5e1;
}

.stats-sub-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  font-size: 11.5px;
  margin-bottom: 10px;
}

.stats-sub-table th {
  background: #334155;
  color: #fff;
  padding: 7px;
  border: 1px solid #475569;
}

.stats-sub-table td {
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
}

/* Mini Timeline Bar in Table */
.stats-mini-bar-wrap {
  display: flex;
  gap: 1.5px;
  height: 14px;
  width: 140px;
  margin: 0 auto;
  background: #e2e8f0;
  border-radius: 2px;
  overflow: hidden;
}

.stats-mini-bar-seg {
  flex: 1;
  height: 100%;
}
.stats-mini-bar-seg.full { background: #16a34a; }
.stats-mini-bar-seg.partial { background: #eab308; }
.stats-mini-bar-seg.zero { background: #dc2626; }

/* Modals */
.stats-modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(2px);
}

.stats-modal-content {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: statsModalFadeIn 0.15s ease-out;
}

@keyframes statsModalFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.stats-modal-header {
  padding: 14px 20px;
  background: #1e293b;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stats-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.stats-modal-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.stats-modal-close:hover { color: #fff; }

.stats-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.stats-modal-footer {
  padding: 12px 20px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Modal Tabs */
.stats-modal-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 16px;
}

.stats-tab-pill {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  border: none;
  background: none;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.stats-tab-pill.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}
