/* mkctrl Web Setup - Light & Minimal */

:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-pale: #dbeafe;
  --success: #10b981;
  --success-pale: #d1fae5;
  --error: #ef4444;
  --warning: #f59e0b;
  --bg: #fafafa;
  --bg-card: #ffffff;
  --bg-hover: #f3f4f6;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 3rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.version {
  color: var(--text-light);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

/* Steps */
.step {
  display: none;
  animation: fadeIn 0.4s ease;
}

.step.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.step h2 {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.step > p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

/* Device Cards */
.device-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
  text-align: center;
}

.device-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.device-card.selected {
  border-color: var(--primary);
  background: var(--primary-pale);
}

.device-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 1rem;
}

.device-icon svg {
  width: 100%;
  height: 100%;
}

.device-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.device-card > p {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
}

.device-card ul {
  list-style: none;
  font-size: 0.75rem;
  text-align: left;
}

.device-card li {
  padding: 0.2rem 0;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.device-card li::before {
  content: "";
  width: 4px;
  height: 4px;
  background: var(--success);
  border-radius: 50%;
}

/* Instructions */
.instructions {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.instruction-step {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.instruction-step:last-child {
  margin-bottom: 0;
}

.step-number {
  background: var(--primary);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.instruction-step p {
  font-size: 0.9rem;
  color: var(--text);
}

.instruction-step strong {
  color: var(--primary);
}

/* Device Diagram */
.device-diagram {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0;
}

.device-diagram svg {
  max-width: 300px;
  height: auto;
}

/* Port hint */
.port-hint {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.port-hint strong {
  color: var(--text);
  background: var(--bg-hover);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.75rem;
}

/* Large button */
.btn-large {
  padding: 1rem 2.5rem;
  font-size: 1rem;
}

/* Progress bar */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}

/* Config Visual */
.config-visual {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.gamepad-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.gamepad-preview svg {
  max-width: 250px;
}

.mapping-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mapping-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mapping-row label:first-child {
  min-width: 80px;
  font-weight: 500;
  font-size: 0.9rem;
}

.mapping-row select {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

.mapping-row span {
  color: var(--text-muted);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Settings Grid */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.setting-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-item label {
  font-size: 0.85rem;
  font-weight: 500;
}

.setting-item input[type="range"] {
  width: 100%;
}

.setting-item span {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
}

/* Flash Cards */
.flash-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.flash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  transition: all 0.2s;
}

.flash-card.done {
  border-color: var(--success);
  background: var(--success-pale);
}

.flash-card .device-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 0.75rem;
}

.flash-card h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.flash-card > p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.flash-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg);
  border-radius: 4px;
  display: inline-block;
}

.flash-status.done {
  color: #065f46;
  background: transparent;
}

.progress-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
}

.progress-bar-sm {
  width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-sm > div {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.2s;
}

.progress-inline span {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 40px;
}

/* Bootloader Hint */
.bootloader-hint {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
}

.hint-diagram {
  width: 100px;
  flex-shrink: 0;
}

.bootloader-hint p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* Step description */
.step-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* Complete summary */
.complete-summary {
  background: var(--success-pale);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.complete-summary p {
  font-weight: 500;
  margin-bottom: 1rem;
  color: #065f46;
}

.complete-summary ol {
  margin-left: 1.25rem;
  font-size: 0.9rem;
  color: #065f46;
}

.complete-summary li {
  margin-bottom: 0.4rem;
}

/* Flash Container */
.flash-container {
  text-align: center;
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

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

/* Error Messages */
.error {
  color: var(--error);
  background: #fef2f2;
  padding: 1rem;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.875rem;
  border: 1px solid #fecaca;
}

/* Next Steps */
.next-steps {
  background: var(--success-pale);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.next-steps h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #065f46;
}

.device-next {
  display: none;
}

.device-next.active {
  display: block;
}

.device-next ol {
  margin-left: 1.25rem;
  font-size: 0.875rem;
  color: #065f46;
}

.device-next li {
  margin-bottom: 0.4rem;
}

.device-next a {
  color: var(--primary);
  font-weight: 500;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Footer */
footer {
  margin-top: 4rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.8rem;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
}

footer a:hover {
  color: var(--primary);
}

footer p {
  margin-bottom: 0.4rem;
}

/* Config Page */
.config-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.config-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

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

.config-label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.config-label span {
  font-weight: 500;
  font-size: 0.9rem;
}

.config-label small {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.config-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

select, input[type="range"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.5rem;
  font-size: 0.85rem;
}

select {
  min-width: 110px;
}

select:focus {
  outline: none;
  border-color: var(--primary);
}

input[type="range"] {
  width: 100px;
  accent-color: var(--primary);
}

.value-display {
  min-width: 45px;
  text-align: right;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Preview */
.preview-container {
  display: flex;
  justify-content: center;
  padding: 1.5rem;
}

.joystick-preview {
  width: 120px;
  height: 120px;
  border: 2px solid var(--border);
  border-radius: 50%;
  position: relative;
  background: var(--bg);
}

.joystick-dot {
  width: 24px;
  height: 24px;
  background: var(--primary);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: all 0.1s ease;
  box-shadow: var(--shadow);
}

.joystick-crosshair {
  position: absolute;
  background: var(--border);
}

.joystick-crosshair.h {
  width: 100%;
  height: 1px;
  top: 50%;
}

.joystick-crosshair.v {
  width: 1px;
  height: 100%;
  left: 50%;
}

/* Connection Status */
.connection-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
}

.status-dot.connected {
  background: var(--success);
}

.connect-btn {
  margin-left: auto;
}

/* Responsive */
@media (max-width: 560px) {
  .container {
    padding: 2rem 1rem;
  }

  .device-cards {
    grid-template-columns: 1fr;
  }

  .config-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .config-input {
    width: 100%;
    justify-content: flex-end;
  }
}
