/**
 * Mine Shift Intelligence — Interactive Drill-down Drawer & Unit 360 Styles
 * PT Bina Sarana Sukses
 */

/* Drawer Backdrop */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 39, 65, 0.36);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 90;
  animation: fadeIn 0.18s ease;
}

.drawer-backdrop.open {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Slide-out Drawer */
.drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(1180px, 93vw);
  height: 100%;
  background: #ffffff;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-drawer);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}

/* Drawer Header */
.drawer-head {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 16px 22px;
  display: flex;
  gap: 14px;
  align-items: center;
}

.drawer-title {
  flex: 1;
  min-width: 0;
}

.drawer-title h3 {
  margin: 2px 0 3px;
  font-size: 20px;
  font-weight: 850;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-title p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-back {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 750;
  color: #2f5c85;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.drawer-back:hover {
  background: #f1f7fe;
  border-color: #b7cce3;
}

.drawer-close {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  font-size: 20px;
  color: #56718d;
  display: grid;
  place-items: center;
}

.drawer-close:hover {
  background: #fdf2f2;
  color: var(--red);
  border-color: #f1c5c5;
}

/* Drawer Body */
.drawer-body {
  padding: 18px 22px 48px;
  flex: 1;
}

.detail-loading {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* Micro Status Badge in Drawer Header */
.drawer-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  background: #f0f4f8;
  color: var(--muted);
  border: 1px solid var(--line);
  margin-left: 8px;
  vertical-align: middle;
}

.drawer-status-pill .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
}

.drawer-status-pill.live .status-dot {
  background: var(--green);
}

.drawer-status-pill.cached .status-dot {
  background: var(--blue);
}

.drawer-status-pill.updating .status-dot {
  background: var(--amber);
  animation: pulseDot 1s infinite alternate;
}

@keyframes pulseDot {
  from { opacity: 0.4; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1.15); }
}

/* Inline Source Loading Indicator (Non-blocking) */
.source-loading-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: #ffffff;
  border: 1px dashed var(--line);
  border-radius: 13px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  margin-top: 14px;
}

.spinner-small {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #e2ecf5;
  border-top-color: var(--blue);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* Subtle fade hydration for enriched sections */
.fade-hydrate {
  animation: fadeHydrate 0.28s ease;
}

@keyframes fadeHydrate {
  from { opacity: 0.3; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}


/* Detail Analysis Section (Analytics First) */
.detail-analysis {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.analysis-label {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  background: #edf5ff;
  color: #2766a4;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

/* Detail KPI Cards Grid */
.detail-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 9px;
}

.detail-kpi {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 11px 12px;
  box-shadow: var(--shadow2);
  min-width: 0;
}

.detail-kpi.critical { border-top: 3px solid var(--red); }
.detail-kpi.warning { border-top: 3px solid var(--amber); }
.detail-kpi.positive { border-top: 3px solid var(--green); }
.detail-kpi.info { border-top: 3px solid var(--blue); }

.detail-kpi .dk-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 850;
}

.detail-kpi .dk-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 6px 0 2px;
  font-size: 19px;
  font-weight: 900;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1e3f61;
}

.detail-kpi .dk-value small {
  font-size: 10px;
  color: #617a91;
  font-weight: 800;
}

.detail-kpi .dk-sub {
  font-size: 9px;
  color: #8193a5;
  line-height: 1.35;
}

/* Detail Insights */
.detail-insights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.detail-insight {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  border-left: 4px solid var(--blue);
}

.detail-insight.warning { border-left-color: var(--amber); }
.detail-insight.critical { border-left-color: var(--red); }
.detail-insight.positive { border-left-color: var(--green); }

.detail-insight b {
  display: block;
  font-size: 11px;
  margin-bottom: 3px;
}

.detail-insight p {
  margin: 0;
  color: #627a91;
  font-size: 10px;
  line-height: 1.5;
}

/* Analysis Block (Tables & Bars) */
.analysis-block {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 15px;
  overflow: hidden;
  box-shadow: var(--shadow2);
}

.analysis-block-head {
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.analysis-block-head b {
  font-size: 12px;
  font-weight: 800;
}

.analysis-block-head small {
  display: block;
  color: var(--muted);
  font-size: 9px;
  margin-top: 2px;
}

.analysis-table {
  overflow: auto;
  max-height: 420px;
}

.analysis-table table {
  min-width: 900px;
  font-size: 10px;
}

.detail-action-row {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.detail-action-row:hover {
  background: #eef7ff !important;
}

.drill-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #2268ae;
  font-size: 9px;
  font-weight: 800;
}

.drill-chip::before {
  content: '↗';
}

/* Analysis Bars */
.analysis-bars {
  padding: 12px 15px;
  display: grid;
  gap: 8px;
}

.analysis-bar {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) minmax(140px, 3fr) 90px;
  gap: 10px;
  align-items: center;
  font-size: 10px;
}

.analysis-bar .ab-label {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-bar .ab-track {
  height: 9px;
  background: #edf2f6;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.analysis-bar .ab-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, #3a86db, #7cb5ea);
}

.analysis-bar .ab-value {
  text-align: right;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.analysis-bar .ab-detail {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 9px;
  margin-top: -5px;
}

.detail-notes {
  padding: 10px 12px;
  background: #f5f9fd;
  border: 1px solid #dfeaf4;
  border-radius: 12px;
  color: #617991;
  font-size: 9px;
  line-height: 1.5;
}

.detail-notes b {
  color: #2f5c85;
}

/* Source Trace Section (Source Second) */
.detail-section {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 15px;
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--shadow2);
}

.detail-section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.detail-section-head b {
  font-size: 12px;
  font-weight: 800;
}

.detail-section-head span {
  font-size: 11px;
  color: var(--muted);
}

.detail-table {
  overflow: auto;
  max-height: 430px;
}

.detail-table table {
  font-size: 10px;
  min-width: 1200px;
}

.detail-table th {
  position: sticky;
  top: 0;
  background: #f4f8fc;
  z-index: 1;
}

/* Breakdown Cards & Hourly Breakdown */
.bd-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.bd-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--shadow2);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.bd-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.bd-card .big {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.03em;
  margin: 3px 0 2px;
}

.bd-card .small {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

.bd-card.BU { border-top: 4px solid var(--BU); }
.bd-card.MS { border-top: 4px solid var(--MS); }

.bd-hourly {
  display: grid;
  grid-template-columns: repeat(12, minmax(38px, 1fr));
  gap: 6px;
  align-items: end;
  height: 210px;
  padding-top: 20px;
}

.bd-hour {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}

.bd-stack {
  width: 100%;
  max-width: 34px;
  height: 150px;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  border-radius: 7px;
  overflow: hidden;
  background: #edf3f8;
}

.bd-stack i {
  display: block;
  width: 100%;
}

.bd-stack .bu { background: var(--BU); }
.bd-stack .ms { background: var(--MS); }

.bd-hour small {
  font-size: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.bd-hour b {
  font-size: 9px;
  font-weight: 800;
}

/* Unit 360 Specific Styles */
.unit-hero {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 13px;
}

.unit-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.04em;
  margin-top: 4px;
  color: #173859;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.metric {
  border: 1px solid #e2eaf2;
  border-radius: 12px;
  padding: 10px;
  background: #fbfdff;
  transition: background var(--transition-fast);
}

.metric.clickable:hover {
  background: #edf5ff;
}

.metric b {
  display: block;
  font-size: 14px;
  font-weight: 850;
  color: #23476d;
}

.metric span {
  font-size: 9px;
  color: #7890a5;
  font-weight: 700;
}

.eventlog {
  display: grid;
}

.event {
  display: grid;
  grid-template-columns: 145px 85px 1fr;
  gap: 10px;
  padding: 10px 6px;
  border-bottom: 1px solid #edf1f4;
  align-items: center;
}

.event.source-click {
  cursor: pointer;
}

.event.source-click:hover {
  background: #f2f8ff;
}

.event b {
  font-size: 11px;
}

.event small {
  display: block;
  color: #8295a8;
  font-size: 9px;
  margin-top: 2px;
}

.reason {
  font-size: 11px;
}

/* Data Check View Styles */
.dq-score {
  display: flex;
  gap: 16px;
  align-items: center;
}

.issue {
  border: 1px solid #e2e9f1;
  border-radius: 12px;
  padding: 11px 13px;
  margin-bottom: 8px;
  background: #ffffff;
}

.issue-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.issue b {
  font-size: 11px;
}

.issue p {
  font-size: 10px;
  color: #71869a;
  margin: 4px 0 0;
  line-height: 1.45;
}

.debug {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  background: #f6f8fa;
  border: 1px solid #e0e7ef;
  padding: 12px;
  border-radius: 12px;
  font-size: 10px;
  line-height: 1.7;
  color: #4f667c;
}

.dimension-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.mini-tab {
  border: 1px solid #dbe5ee;
  background: #ffffff;
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 750;
  color: #617a92;
  transition: all var(--transition-fast);
}

.mini-tab:hover {
  background: #f4f8fe;
}

.mini-tab.active {
  background: #edf5ff;
  color: #1c63b2;
  border-color: #b6d5f5;
}
