/**
 * PanelForge — SIKO 风格样式
 * 
 * 遵循 SIKO Frontend Convention v1.1
 * 蓝白工程美学 · 精密仪表盘风格
 */

/* ── Design Tokens ───────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg: #F7FAFD;
  --muted: #EBF2FA;
  --card: #FFFFFF;

  /* Foreground */
  --fg: #0D1F35;
  --muted-fg: #5A7A9A;

  /* Borders */
  --border: #D6E4F0;
  --accent-border: rgba(20, 120, 200, 0.25);

  /* SIKO Blue */
  --accent: #1478C8;
  --accent-2: #2878DC;
  --accent-light: rgba(20, 120, 200, 0.08);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(20, 80, 160, 0.07);
  --shadow-md: 0 4px 16px rgba(20, 80, 160, 0.10);
  --shadow-lg: 0 12px 40px rgba(20, 80, 160, 0.14);
  --shadow-accent: 0 6px 24px rgba(20, 120, 200, 0.28);

  /* Shape */
  --radius: 16px;
  --radius-sm: 8px;

  /* Status Colors */
  --success: #10B981;
  --success-light: rgba(16, 185, 129, 0.1);
  --error: #EF4444;
  --error-light: rgba(239, 68, 68, 0.1);
}


/* ── Reset & Base ────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}


/* ── Background Layers ───────────────────────────────────────────── */
.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 10% 20%, rgba(20,120,200,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 60% at 90% 80%, rgba(40,120,220,0.05) 0%, transparent 55%);
}

.bg-dots {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(20,120,200,0.12) 1px, transparent 1px);
  background-size: 32px 32px;
}

.deco-ring {
  position: fixed;
  width: 480px;
  height: 480px;
  top: -120px;
  right: -120px;
  border: 2px dashed var(--accent-border);
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
  animation: ring-rotate 80s linear infinite;
}

.deco-ring-2 {
  position: fixed;
  width: 700px;
  height: 700px;
  bottom: -200px;
  left: -200px;
  border: 1px dashed var(--accent-border);
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
  animation: ring-rotate 120s linear infinite reverse;
}

@keyframes ring-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}


/* ── Page Layout ─────────────────────────────────────────────────── */
.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  gap: 32px;
  max-width: 720px;
  margin: 0 auto;
}


/* ── Animations ──────────────────────────────────────────────────── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header { animation: fadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0s both; }
.upload-card { animation: fadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both; }
.config-card { animation: fadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both; }
.action-section { animation: fadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.35s both; }
.footer { animation: fadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.4s both; }


/* ── Header ──────────────────────────────────────────────────────── */
.header {
  text-align: center;
  width: 100%;
}

.logo-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.title-group {
  text-align: left;
}

.title {
  font-family: 'Calistoga', serif;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--fg);
}

.gradient-text {
  background: linear-gradient(to right, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted-fg);
}


/* ── Main ────────────────────────────────────────────────────────── */
.main {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}


/* ── Card ────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.icon-box {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 10px;
  color: white;
}


/* ── Upload Zone ─────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.upload-icon {
  color: var(--muted-fg);
}

.upload-text {
  font-size: 0.95rem;
  color: var(--fg);
}

.upload-text .link {
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}

.upload-hint {
  font-size: 0.8rem;
  color: var(--muted-fg);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--muted);
  border-radius: var(--radius-sm);
  color: var(--fg);
}

.file-info svg {
  color: var(--accent);
  flex-shrink: 0;
}

.file-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-remove {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--muted-fg);
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.file-remove:hover {
  background: var(--error-light);
  color: var(--error);
}


/* ── Config ──────────────────────────────────────────────────────── */
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.config-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.config-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted-fg);
}


/* ── Toggle Group ────────────────────────────────────────────────── */
.toggle-group {
  display: flex;
  background: var(--muted);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.toggle-btn {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: transparent;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted-fg);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.toggle-btn.active {
  background: var(--card);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.toggle-btn:hover:not(.active) {
  color: var(--fg);
}


/* ── Switch ──────────────────────────────────────────────────────── */
.switch {
  position: relative;
  width: 48px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 28px;
  cursor: pointer;
  transition: background 0.3s;
}

.slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  bottom: 3px;
  background: var(--card);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}


/* ── Circuit Config ──────────────────────────────────────────────── */
.circuit-config {
  margin-top: 20px;
}

.config-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 20px;
}

.config-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.config-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.config-hint {
  font-size: 0.8rem;
  color: var(--muted-fg);
  margin-bottom: 16px;
}


/* ── Badge ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--accent-border);
  background: var(--accent-light);
  border-radius: 99px;
  padding: 4px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
}

.badge-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.3); }
}


/* ── Placeholder List ────────────────────────────────────────────── */
.placeholder-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.placeholder-row {
  display: grid;
  grid-template-columns: 80px 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.placeholder-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.placeholder-field label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-fg);
}

.input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--fg);
  background: var(--card);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.input::placeholder {
  color: var(--muted-fg);
  opacity: 0.6;
}

.module-field .input {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  text-align: center;
}

.btn-remove {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted-fg);
  font-size: 1.2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-remove:hover {
  background: var(--error-light);
  border-color: var(--error);
  color: var(--error);
}

.btn-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  padding: 10px 16px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted-fg);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.btn-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}


/* ── Action Section ──────────────────────────────────────────────── */
.action-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-accent);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.2s;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(20, 120, 200, 0.35);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary svg {
  transition: transform 0.2s;
}

.btn-primary:hover:not(:disabled) svg {
  transform: translateX(2px);
}


/* ── Status ──────────────────────────────────────────────────────── */
.status {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
}

.status-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--accent-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.status-success {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--success-light);
  color: var(--success);
}

.status-error {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--error-light);
  color: var(--error);
}

.download-link {
  margin-left: 8px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  transition: text-decoration 0.2s;
}

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


/* ── Footer ──────────────────────────────────────────────────────── */
.footer {
  margin-top: auto;
  padding-top: 24px;
  text-align: center;
}

.footer p {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted-fg);
  opacity: 0.7;
}


/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .page {
    padding: 32px 16px;
  }

  .title {
    font-size: 1.8rem;
  }

  .config-grid {
    grid-template-columns: 1fr;
  }

  .placeholder-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }

  .placeholder-row:last-child {
    border-bottom: none;
  }

  .btn-remove {
    width: 100%;
    height: auto;
    padding: 8px;
    margin-top: 4px;
  }
}


/* ── Reduced Motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .deco-ring,
  .deco-ring-2 {
    animation: none;
  }

  .badge-dot {
    animation: none;
  }

  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
