/* === UVTools2 — aligned with the shared N7SIX design system === */
/* Tokens, reset, body base, .btn and select live in css/theme.css.
   This file only holds uvtools2-specific layout & components, all built
   on the shared tokens so light/dark themes stay consistent with k5viewer. */

/* ---------- Layout ---------- */
body {
  display: flex;
  justify-content: center;
  /* Anchor to the top, not vertically centered: otherwise switching to a
     taller/shorter panel re-centers the card and it appears to jump up/down. */
  align-items: flex-start;
  padding: 20px;
}

.container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  max-width: 1024px;
  width: 100%;
  padding: 40px;
}

/* ---------- Header ---------- */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
}

/* Brand block — same treatment as k5viewer (name + "by F4HWN · Adopted by N7SIX" author) */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand_h1 {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
}

.brand-author {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.2;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* Global "firmwares flashed" counter pill (shared with UV Studio) */
.flash-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in oklab, var(--text-muted) 7%, var(--surface));
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}
.flash-counter[hidden] {
  display: none;
}
.flash-counter-icon {
  font-size: 13px;
  line-height: 1;
}
.flash-counter-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.flash-counter-unit {
  color: var(--text-muted);
}

/* Icon-only theme toggle keeps the ◐/◑ glyph centered */
#themeToggle {
  padding: 8px 12px;
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 30px;
  font-size: 14px;
}

/* ---------- Tabs ---------- */
/* Section navigation as a k5viewer-style button toolbar (each .tab also
   carries the shared .btn class, so inactive tabs get the alu look; the
   active one is filled primary blue like k5viewer's active model tab). */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.tab {
  white-space: nowrap;
}

.tab.active {
  background: linear-gradient(160deg, #3b82f6 0%, #2563eb 100%);
  border-color: #2563eb;
  color: #fff;
  box-shadow:
    0 2px 6px rgba(37, 99, 235, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: none;
}

.tab.active:hover:not(:disabled) {
  background: linear-gradient(160deg, #60a5fa 0%, #3b82f6 100%);
  border-color: #3b82f6;
  color: #fff;
  transform: translateY(-1px);
  box-shadow:
    0 3px 10px rgba(37, 99, 235, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

[data-theme='dark'] .tab.active {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border-color: #3b82f6;
  color: #fff;
  box-shadow:
    0 2px 8px rgba(59, 130, 246, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

[data-theme='dark'] .tab.active:hover:not(:disabled) {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  box-shadow:
    0 4px 12px rgba(59, 130, 246, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.tab-description {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- Sections & form controls ---------- */
.section {
  margin-bottom: 25px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}

input[type='text'] {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s;
}

input[type='text']:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------- Custom file input ---------- */
.file-input-wrapper {
  position: relative;
  width: 100%;
}

input[type='file'] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.file-input-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  transition: all 0.15s;
}

.file-input-label:hover {
  border-color: var(--accent);
}

.file-input-label.has-file {
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 8%, var(--surface));
}

.file-name {
  color: var(--text-secondary);
  font-size: 14px;
}

.file-name.has-file {
  color: var(--text);
  font-weight: 500;
}

/* Small primary chip inside the file picker */
.file-button {
  background: linear-gradient(160deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  box-shadow:
    0 2px 6px rgba(37, 99, 235, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  white-space: nowrap;
}

/* ---------- Primary action buttons (contained, centered CTA) ---------- */
/* Scaled-up .btn.primary rather than a full-width slab, to match k5viewer's
   compact button vocabulary. */
button:not(.tab):not(.log-toggle):not(.btn) {
  display: block;
  width: fit-content;
  min-width: 240px;
  max-width: 100%;
  margin: 10px 0 0;
  padding: 12px 28px;
  border-radius: var(--radius);
  border: 1px solid #2563eb;
  background: linear-gradient(160deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow:
    0 2px 8px rgba(37, 99, 235, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

button:not(.tab):not(.log-toggle):not(.btn):hover:not(:disabled) {
  background: linear-gradient(160deg, #60a5fa 0%, #3b82f6 100%);
  border-color: #3b82f6;
  transform: translateY(-1px);
  box-shadow:
    0 4px 12px rgba(37, 99, 235, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

button:not(.tab):not(.log-toggle):not(.btn):active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

[data-theme='dark'] button:not(.tab):not(.log-toggle):not(.btn) {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  box-shadow:
    0 2px 8px rgba(59, 130, 246, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
[data-theme='dark']
  button:not(.tab):not(.log-toggle):not(.btn):hover:not(:disabled) {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  box-shadow:
    0 4px 12px rgba(59, 130, 246, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Focus: no halo — the select's border turns blue on focus (via theme.css),
   matching k5viewer. Buttons fall back to the browser's default focus ring. */

/* ---------- Progress bar ---------- */
.progress-container {
  margin-top: 20px;
  display: none;
}

.progress-bar {
  position: relative;
  width: 100%;
  height: 30px;
  background: var(--border);
  border-radius: 15px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
  width: 0%;
  transition: width 0.3s;
}

.progress-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

/* ---------- Download link ---------- */
/* Compact success chip, centered — not a full-width bar */
.download-link {
  display: none;
  width: fit-content;
  max-width: 100%;
  margin: 20px 0 0;
  padding: 10px 18px;
  background: color-mix(in oklab, var(--accent) 8%, var(--surface));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  text-align: center;
}

.download-link a {
  color: var(--accent-hover);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.download-link a:hover {
  text-decoration: underline;
}

.download-link a .dl-icon {
  flex: 0 0 auto;
}

/* ---------- Log / console ---------- */
.log-container {
  margin-top: 25px;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.log-toggle {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.log-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
}

.log {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  max-height: 300px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  display: none;
}

.log.visible {
  display: block;
}

.log-entry {
  margin-bottom: 4px;
  color: var(--text);
}

.log-entry.error {
  color: var(--error);
  font-weight: 600;
}

.log-entry.success {
  color: var(--success);
  font-weight: 600;
}

.log-entry.info {
  color: var(--accent);
}

/* ---------- Info block ---------- */
.info-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 15px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ---------- Logo controls ---------- */
.logo-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 15px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.logo-controls input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.logo-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
  margin-bottom: 0;
}

.logo-checkbox-label input[type='checkbox'] {
  accent-color: var(--accent);
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.logo-preview-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.logo-preview-label {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.logo-canvas {
  width: 512px;
  max-width: 100%;
  height: auto;
  /* Physical aspect ratio of the ST7565 LCD on UV-K5/K1 (~22x12 mm panel),
     not the logical 128/64=2.0. Pixels render slightly taller than wide,
     matching what the user actually sees on the radio. */
  aspect-ratio: 22 / 16;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

/* ---------- Accessibility helpers ---------- */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
