/* ============================================================
   Tensai Firmware Flasher — Frontend CSS
   Design language: Smart Solution (smartsolutionint.com)
   Colors: Navy #0a1f4e | Blue #0a3d8f | Accent #1a90ff
   ============================================================ */

:root {
  --tff-navy:       #0a1f4e;
  --tff-blue:       #0a3d8f;
  --tff-accent:     #1a90ff;
  --tff-accent-glow:rgba(26, 144, 255, 0.18);
  --tff-success:    #10b981;
  --tff-warning:    #f59e0b;
  --tff-error:      #ef4444;
  --tff-text:       #1e293b;
  --tff-muted:      #64748b;
  --tff-border:     #e2e8f0;
  --tff-bg:         #f8fafc;
  --tff-white:      #ffffff;
  --tff-radius:     12px;
  --tff-shadow:     0 4px 24px rgba(10,31,78,.10);
  --tff-shadow-lg:  0 8px 40px rgba(10,31,78,.16);
  --tff-font:       'Segoe UI', system-ui, -apple-system, sans-serif;
  --tff-transition: 0.22s ease;
}

/* ── Wrapper ─────────────────────────────────────────────── */
.tff-flasher-wrap {
  font-family: var(--tff-font);
  color: var(--tff-text);
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ── Hero Banner ─────────────────────────────────────────── */
.tff-hero {
  background: linear-gradient(135deg, var(--tff-navy) 0%, var(--tff-blue) 100%);
  border-radius: var(--tff-radius);
  padding: 48px 40px 40px;
  color: var(--tff-white);
  margin-bottom: 36px;
  position: relative;
  overflow: hidden;
}
.tff-hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: rgba(26,144,255,.12);
  pointer-events: none;
}
.tff-hero::after {
  content: '';
  position: absolute;
  bottom: -40px; left: 30%;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
  pointer-events: none;
}
.tff-hero-badge {
  display: inline-block;
  background: rgba(26,144,255,.22);
  border: 1px solid rgba(26,144,255,.4);
  color: #90caf9;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.tff-hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  margin: 0 0 10px;
  line-height: 1.2;
  color: var(--tff-white);
}
.tff-hero p {
  font-size: 1rem;
  opacity: .78;
  margin: 0;
  max-width: 520px;
  color: var(--tff-white);
}
.tff-hero-steps {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}
.tff-hero-step {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: .85rem;
  color: rgba(255,255,255,.9);
}
.tff-hero-step-num {
  background: var(--tff-accent);
  color: #fff;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Section Labels ──────────────────────────────────────── */
.tff-section-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--tff-accent);
  margin-bottom: 14px;
}

/* ── Loading Spinner ─────────────────────────────────────── */
#tff-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--tff-muted);
}
.tff-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--tff-border);
  border-top-color: var(--tff-accent);
  border-radius: 50%;
  animation: tff-spin .7s linear infinite;
  margin: 0 auto 16px;
}
@keyframes tff-spin { to { transform: rotate(360deg); } }

/* ── Product Grid ────────────────────────────────────────── */
.tff-products-section {
  margin-bottom: 32px;
}
.tff-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.tff-product-card {
  background: var(--tff-white);
  border: 2px solid var(--tff-border);
  border-radius: var(--tff-radius);
  cursor: pointer;
  transition: border-color var(--tff-transition),
              box-shadow    var(--tff-transition),
              transform     var(--tff-transition);
  overflow: hidden;
  user-select: none;
}
.tff-product-card:hover {
  border-color: var(--tff-accent);
  box-shadow: 0 0 0 4px var(--tff-accent-glow);
  transform: translateY(-3px);
}
.tff-product-card.tff-card-selected {
  border-color: var(--tff-accent);
  box-shadow: 0 0 0 4px var(--tff-accent-glow), var(--tff-shadow);
}
.tff-product-img-wrap {
  background: #f1f5fb;
  width: 100%;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.tff-product-img-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.tff-product-placeholder svg {
  width: 64px; height: 64px;
}
.tff-product-info {
  padding: 14px 16px;
}
.tff-product-info h3 {
  font-size: .95rem;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--tff-navy);
}

/* ── Chips ───────────────────────────────────────────────── */
.tff-chip, .tff-chip-sm {
  display: inline-block;
  background: #e8f0fe;
  color: var(--tff-blue);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 3px 10px;
  border-radius: 999px;
}
.tff-chip-sm { font-size: .65rem; padding: 2px 8px; }

/* ── Flash Panel ─────────────────────────────────────────── */
.tff-flash-panel {
  background: var(--tff-white);
  border-radius: var(--tff-radius);
  box-shadow: var(--tff-shadow);
  padding: 32px;
  margin-bottom: 24px;
  border: 1px solid var(--tff-border);
}

.tff-panel-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
}
@media (max-width: 720px) {
  .tff-panel-grid { grid-template-columns: 1fr; }
}

/* Version select */
.tff-version-section { display: none; }
.tff-form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--tff-navy);
  margin-bottom: 8px;
}
.tff-select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--tff-border);
  border-radius: 8px;
  font-size: .95rem;
  font-family: var(--tff-font);
  background: var(--tff-bg);
  color: var(--tff-text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230a3d8f' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: border-color var(--tff-transition);
  cursor: pointer;
}
.tff-select:focus {
  outline: none;
  border-color: var(--tff-accent);
  box-shadow: 0 0 0 3px var(--tff-accent-glow);
}

/* Release notes */
.tff-release-notes {
  background: #f8fafc;
  border-left: 3px solid var(--tff-accent);
  border-radius: 0 6px 6px 0;
  padding: 12px 16px;
  font-size: .85rem;
  color: var(--tff-muted);
  margin-top: 14px;
  display: none;
  white-space: pre-wrap;
}

/* Flash button */
.tff-flash-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 28px;
  background: linear-gradient(135deg, var(--tff-blue) 0%, var(--tff-accent) 100%);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 24px;
  transition: opacity var(--tff-transition), transform var(--tff-transition), box-shadow var(--tff-transition);
  box-shadow: 0 4px 18px rgba(26,144,255,.35);
  letter-spacing: .02em;
}
.tff-flash-btn:hover:not(:disabled) {
  opacity: .92;
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(26,144,255,.45);
}
.tff-flash-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none;
}
.tff-flash-btn svg {
  width: 22px; height: 22px;
}

/* ── Product Detail Sidebar ──────────────────────────────── */
#tff-product-detail {
  display: none;
  background: linear-gradient(160deg, var(--tff-navy) 0%, #0d2b6b 100%);
  color: var(--tff-white);
  border-radius: var(--tff-radius);
  padding: 28px;
}
#tff-product-detail h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--tff-white);
}
#tff-product-detail .tff-chip {
  background: rgba(26,144,255,.22);
  color: #90caf9;
}
.tff-detail-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}
.tff-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.16);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--tff-transition);
}
.tff-link-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.tff-link-btn svg { width: 16px; height: 16px; }
.tff-link-yt { border-color: rgba(255,0,0,.3); background: rgba(255,0,0,.08); }
.tff-link-yt:hover { background: rgba(255,0,0,.16); }

/* ── Status Bar ──────────────────────────────────────────── */
.tff-status {
  display: none;
  padding: 14px 20px;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.tff-status-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.tff-status-success { background: #f0fdf4; border-color: #86efac; color: #166534; }
.tff-status-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.tff-status-error   { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }

/* ── Progress Bar ────────────────────────────────────────── */
#tff-progress-wrap {
  display: none;
  margin-bottom: 20px;
}
.tff-progress-track {
  background: var(--tff-border);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 6px;
}
#tff-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--tff-blue), var(--tff-accent));
  border-radius: 999px;
  transition: width .3s ease;
  width: 0%;
}
#tff-progress-label {
  font-size: .78rem;
  color: var(--tff-muted);
  font-weight: 500;
}

/* ── Web Serial Warning ──────────────────────────────────── */
.tff-webserial-warn {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 14px 18px;
  font-size: .85rem;
  color: #78350f;
  margin-bottom: 20px;
  display: none;
}

/* ── Empty State ─────────────────────────────────────────── */
.tff-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--tff-muted);
}
.tff-empty-state svg {
  width: 64px; height: 64px;
  margin-bottom: 16px;
  opacity: .4;
}
