/* ============================================================================
   WFMeter - Unified App Stylesheet
   ============================================================================ */

/* ── Page Transitions (View Transitions API) ─────────────────────────────── */
@view-transition {
  navigation: auto;
}

/* Prevent white flash — match page background */
::view-transition-image-pair(root) {
  background: #121212;
}

/* Nav stays fixed — captured as its own named layer */
.app-nav {
  view-transition-name: app-nav;
  position: relative;
  z-index: 10;
}

/* Nav does not animate */
::view-transition-old(app-nav),
::view-transition-new(app-nav) {
  animation: none;
  mix-blend-mode: normal;
}

/* Header stays fixed — same on every page, should not slide */
::view-transition-old(app-header),
::view-transition-new(app-header) {
  animation: none;
  mix-blend-mode: normal;
}

/* Content: old page slides out left, new page slides in from right */
::view-transition-old(root) {
  animation: 420ms ease-in both wfm-slide-out;
}

::view-transition-new(root) {
  animation: 420ms ease-out both wfm-slide-in;
}

@keyframes wfm-slide-out {
  to { transform: translateX(-100%); opacity: 1; }
}

@keyframes wfm-slide-in {
  from { transform: translateX(100%); opacity: 1; }
}

* { box-sizing: border-box; font-family: system-ui, -apple-system, sans-serif; }

html {
  background-color: #121212;
}
body {
  background-color: #121212;
  color: #f0f0f0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 15px;
  margin: 0;
}

/* ── App Header ─────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1em auto 1.7em;
  view-transition-name: app-header;
}

.app-header-icon {
  width: 96px;
  height: 96px;
}

.app-header-title {
  font-size: 30px;
  letter-spacing: 0.04em;
  color: #f0f0f0;
  font-weight: 300;
}

.app-header-title strong { font-weight: 600; color: #00bcff; }

h1 { margin-bottom: 4px; font-size: clamp(20px, 5vw, 28px); text-align: center; }
p { margin-top: 0; color: #aaa; font-size: 13px; text-align: center; }

/* ── Navigation ──────────────────────────────────────────────────────────── */
.app-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 950px;
  margin-bottom: 20px;
  background: #181818;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid #333;
}

@media screen and (max-width: 700px) {
  .app-nav { flex-direction: column; gap: 6px; }
}

.nav-link {
  flex: 1;
  text-align: center;
  padding: 10px 16px;
  color: #aaa;
  text-decoration: none;
  font-weight: bold;
  font-size: 14px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.nav-link:hover { color: #fff; background: #252525; }
.nav-link.active { color: #fff; background: #007acc; }

/* ── Controls Panel ──────────────────────────────────────────────────────── */
#controls {
  width: 100%;
  max-width: 950px;
  margin: 15px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #1e1e1e;
  padding: 15px;
  border-radius: 8px;
  border: 1px solid #333;
}

.control-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; width: 100%; }

.control-row-title {
  width: 100%;
  font-size: 11px;
  text-transform: uppercase;
  color: #00bcff;
  font-weight: bold;
  letter-spacing: 0.5px;
  margin-bottom: -4px;
}

.control-group { display: flex; flex-direction: column; gap: 4px; flex: 1 1 180px; min-width: 0; }

/* ── Form Inputs ─────────────────────────────────────────────────────────── */
label { font-size: 12px; color: #aaa; font-weight: bold; }

input[type="number"],
input[type="text"],
select {
  background-color: #2a2a2a;
  color: #fff;
  border: 1px solid #444;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  width: 100%;
  height: 38px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

select {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="%23aaaaaa" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

input:focus, select:focus {
  border-color: #00bcff;
  box-shadow: 0 0 0 1px #00bcff;
}

input[type="file"] {
  background: #2a2a2a;
  color: #fff;
  border: 1px solid #444;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  width: 100%;
  height: 38px;
}

input[type="range"] { width: 100%; accent-color: #00bcff; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
button {
  padding: 9px 16px;
  font-size: 14px;
  font-weight: bold;
  background-color: #007acc;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  height: 38px;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

button:hover { background-color: #005999; }
button:disabled { background-color: #444; cursor: not-allowed; }
button.btn-stop { background-color: #d32f2f; }
button.btn-stop:hover { background-color: #b71c1c; }
.btn-secondary { background-color: #333; border: 1px solid #555; }
.btn-secondary:hover { background-color: #444; }

/* ── Status Message ──────────────────────────────────────────────────────── */
#status-msg {
  font-size: 13px;
  color: #ff9800;
  margin-bottom: 8px;
  font-weight: bold;
  text-align: center;
  width: 100%;
  max-width: 950px;
}

.status-progress {
  width: 100%;
  max-width: 950px;
  margin-bottom: 12px;
}

.status-progress-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: #232323;
  border: 1px solid #333;
  overflow: hidden;
}

.status-progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #00bcff 0%, #00ffcc 100%);
  transition: width 120ms linear;
}

.status-progress-bar.indeterminate {
  width: 36%;
  animation: wfm-progress-indeterminate 1.1s linear infinite;
}

.status-progress-label {
  margin-top: 6px;
  color: #888;
  font-size: 11px;
  text-align: center;
}

@keyframes wfm-progress-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(360%); }
}

/* ── Metric Readouts ─────────────────────────────────────────────────────── */
#readouts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 950px;
  margin-bottom: 15px;
  background: #181818;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #282828;
}

.metric { text-align: center; }
.metric-val { font-size: clamp(16px, 4vw, 20px); font-weight: bold; color: #00bcff; }
.metric-label { font-size: 10px; color: #888; text-transform: uppercase; margin-top: 2px; }

.notice-panel {
  width: 100%;
  max-width: 950px;
  margin-bottom: 15px;
  background: #181818;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #282828;
}

.notice-title {
  color: #888;
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  text-align: center;
}

.notice-summary {
  color: #aaa;
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.notice-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.notice-item {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 10px 12px;
  text-align: center;
}

.notice-item-band {
  color: #00bcff;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.notice-item-title {
  color: #f0f0f0;
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 3px;
}

.notice-item-detail {
  color: #aaa;
  font-size: 12px;
  line-height: 1.4;
}

/* ── Chart ───────────────────────────────────────────────────────────────── */
#chart-container {
  position: relative;
  width: 100%;
  max-width: 950px;
  background: #181818;
  border-radius: 8px;
  border: 1px solid #333;
  overflow: hidden;
  margin-bottom: 20px;
}

canvas { display: block; width: 100%; height: 380px; }

/* ── CSV Log ─────────────────────────────────────────────────────────────── */
#log-container { width: 100%; max-width: 950px; display: flex; flex-direction: column; gap: 8px; }
.log-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
textarea {
  width: 100%;
  height: 140px;
  background: #181818;
  color: #00ffcc;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 10px;
  font-family: monospace;
  font-size: 12px;
  resize: vertical;
}

/* ── Generator Card ──────────────────────────────────────────────────────── */
.card {
  width: 100%;
  max-width: 950px;
  margin-top: 15px;
  background: #1e1e1e;
  padding: 25px;
  border-radius: 8px;
  border: 1px solid #333;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.control { display: flex; flex-direction: column; gap: 6px; }
.control label { font-size: 13px; color: #ccc; font-weight: bold; display: flex; justify-content: space-between; }

.btn-group { display: flex; gap: 10px; }
.btn-group button { flex: 1; height: auto; padding: 12px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  body { padding: 8px; }
  .nav-link { font-size: 12px; padding: 8px 10px; }
  #controls { padding: 10px; gap: 14px; }
  .control-row { gap: 8px; }
  .control-group { flex: 1 1 100%; }
  button { width: 100%; }
  .btn-group button { width: auto; }
  canvas { height: 280px; }
  .notice-panel { padding: 12px; }
}
