/* ---------- History dialog ---------- */

/* ---------- Subtask selector (inside timer right-ui) ---------- */
.subtask-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 8px;
}

.subtask-selector-label {
  font-weight: 700;
  font-size: 13px;
  color: #2b2213;
  white-space: nowrap;
}

.subtask-select {
  appearance: none;
  border: 2px solid rgba(224, 162, 51, .6);
  border-radius: 999px;
  padding: 5px 28px 5px 12px;
  font-weight: 700;
  font-size: 13px;
  color: #2b2213;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%232b2213'/%3E%3C/svg%3E") no-repeat right 10px center,
    rgba(255, 235, 160, .75);
  cursor: pointer;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtask-select:focus {
  outline: 2px solid #e0a233;
  outline-offset: 2px;
}

/* Ensure hidden attribute wins over display:flex */
#historyDialog[hidden],
#historyBackdrop[hidden] {
  display: none !important;
}

.history-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  width: min(680px, 92vw);
  max-height: calc(100vh - 120px);
  overflow: hidden;
  display: flex;
  flex-direction: column;

  border-radius: 28px;
  z-index: 31;
  border: 2px solid rgba(194, 178, 140, .4);
  background:
    radial-gradient(120px circle at 50% 42%, rgba(255, 255, 255, .4), rgba(245, 240, 230, .15) 70%),
    linear-gradient(135deg, rgba(222, 196, 160, .45) 0%, rgba(194, 178, 140, .35) 100%);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  box-shadow:
    0 18px 36px rgba(0, 0, 0, .35),
    inset 0 0 0 1px rgba(245, 240, 230, .25),
    0 0 20px rgba(194, 178, 140, .2);
  color: #2b2213;
  pointer-events: auto;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 8px;
  flex-shrink: 0;
}

.history-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}

.history-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 18px 10px;
  flex-shrink: 0;
}

.history-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px 8px;
  min-height: 180px;
}

.history-empty {
  font-weight: 700;
  color: rgba(43, 34, 19, .6);
  text-align: center;
  margin-top: 40px;
}

.history-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 18px 16px;
  flex-shrink: 0;
}

/* Widen the panel now that it has two columns */
.history-panel {
  width: min(860px, 94vw);
}

/* ── Two-column layout ─────────────────────────────────────────── */
.hist-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  min-height: 260px;
}

/* ── Left: chart ───────────────────────────────────────────────── */
.hist-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hist-chart-title {
  font-weight: 700;
  font-size: 13px;
  color: #2b2213;
}

.hist-total-big {
  font-weight: 800;
  font-size: 26px;
  color: #2b2213;
  letter-spacing: .5px;
}

.hist-chart {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  flex: 1;
  min-height: 120px;
  max-height: 160px;
}

.hist-yaxis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 11px;
  font-weight: 700;
  color: rgba(43, 34, 19, .6);
  padding-bottom: 18px; /* aligns with bar labels */
  min-width: 24px;
}

.hist-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  flex: 1;
  height: 100%;
}

.hbar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
}

.hbar-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
}

.hbar-bar {
  width: 100%;
  min-height: 3px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(to top, #4e6650, #6e8c70);
  transition: height .3s ease;
}

.hbar-bar--current {
  background: linear-gradient(to top, #f2b942, #ffd36b);
}

.hbar-label {
  font-size: 9px;
  font-weight: 700;
  color: rgba(43, 34, 19, .6);
  text-align: center;
  margin-top: 3px;
  white-space: nowrap;
}

.hist-session-count {
  font-size: 13px;
  font-weight: 700;
  color: rgba(43, 34, 19, .75);
  margin-top: 4px;
}

/* ── Right: subtask list ───────────────────────────────────────── */
.hist-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 2px solid rgba(224, 162, 51, .35);
  padding-left: 16px;
}

.hist-list-title {
  font-weight: 800;
  font-size: 15px;
  color: #2b2213;
}

.hist-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 200px;
  flex: 1;
}

.hist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 12px;
  border: 1px solid rgba(224, 162, 51, .35);
  background: rgba(255, 235, 160, .35);
}

.hist-row-name {
  font-weight: 700;
  font-size: 14px;
  color: #2b2213;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hist-row-time {
  font-weight: 800;
  font-size: 14px;
  color: #2b2213;
  white-space: nowrap;
  flex-shrink: 0;
}

.hist-list-total {
  font-size: 13px;
  font-weight: 700;
  color: rgba(43, 34, 19, .75);
  padding-top: 6px;
  border-top: 1px solid rgba(224, 162, 51, .3);
  margin-top: auto;
}

/* ── Responsive: stack on narrow screens ──────────────────────── */
@media (max-width: 600px) {
  .hist-layout {
    grid-template-columns: 1fr;
  }
  .hist-right {
    border-left: none;
    border-top: 2px solid rgba(224, 162, 51, .35);
    padding-left: 0;
    padding-top: 12px;
  }
}
