/* CSV-to-XLSX Converter — Dark Theme */

/* ── Root Variables ── */
:root {
  --bg-primary: #0f0f14;
  --bg-secondary: #1a1a24;
  --bg-tertiary: #24243a;
  --border-color: #2e2e48;
  --border-hover: #6366f1;
  --text-primary: #e0e0e0;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --success: #22c55e;
  --error: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --max-w: 640px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Focus Visible ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Skip Link ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  z-index: 1000;
  text-decoration: none;
  font-weight: 600;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0.5rem;
}

/* ── Header ── */
header[role="banner"] {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
}

header nav {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  gap: 1rem;
}

/* ── Logo ── */
.logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.logo:hover {
  color: var(--accent);
}

/* ── Nav Toggle (mobile) ── */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.25rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  line-height: 1;
}

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

/* ── Nav Links ── */
.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}

.nav-links a:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-links a.active {
  color: var(--accent);
  background: var(--accent-glow);
  font-weight: 600;
}

/* ── Main ── */
main {
  flex: 1;
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Page Title ── */
.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Subtitle ── */
.subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* ── Converter Wrapper ── */
.converter-wrapper {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2.5rem;
}

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--border-hover);
  background: var(--accent-glow);
}

.upload-zone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.upload-icon {
  color: var(--accent);
  opacity: 0.8;
}

.upload-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.upload-subtext {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── File List ── */
.file-list {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  animation: slideIn 0.25s ease-out;
}

.file-thumb {
  width: 36px;
  height: 36px;
  background: var(--accent-glow);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.file-status {
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.file-status.pending { color: var(--text-muted); }
.file-status.converting { color: var(--accent); }
.file-status.done { color: var(--success); }
.file-status.error { color: var(--error); }

.file-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.25rem;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s;
}

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

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

/* ── Actions ── */
.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  min-height: 44px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-convert {
  background: var(--accent);
  color: #fff;
  flex: 1;
}

.btn-convert:hover {
  background: var(--accent-hover);
}

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

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

.btn-clear:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-download-all {
  margin-top: 1rem;
  background: var(--success);
  color: #fff;
  width: 100%;
}

.btn-download-all:hover {
  filter: brightness(1.1);
}

.btn-download {
  background: var(--accent);
  color: #fff;
  padding: 0.45rem 0.9rem;
  font-size: 0.8rem;
}

.btn-download:hover {
  background: var(--accent-hover);
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ── Progress Bar ── */
.progress-bar {
  margin-top: 1rem;
  background: var(--bg-tertiary);
  border-radius: 999px;
  height: 8px;
  position: relative;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 999px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0;
  color: transparent;
}

/* ── Results ── */
.results {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.results-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

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

.result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.result-card .file-name {
  font-size: 0.85rem;
}

.result-card .file-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.result-card .result-info {
  flex: 1;
  min-width: 0;
}

/* ── Error Message ── */
.error-msg {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 0.875rem;
  text-align: center;
}

/* ── Info Section ── */
.info-section {
  margin-top: 1rem;
}

.info-section h2 {
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

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

.step:hover {
  border-color: var(--border-hover);
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.step h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}

.step p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Footer ── */
footer[role="contentinfo"] {
  text-align: center;
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  main {
    padding: 1.5rem 1rem;
  }

  .page-title {
    font-size: 1.4rem;
  }

  .upload-zone {
    padding: 2rem 1rem;
  }

  .steps {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .actions {
    flex-direction: column;
  }

  header nav {
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
  }

  .nav-toggle {
    display: block;
  }

  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    padding: 0.5rem 0.75rem;
  }
}

@media (max-width: 480px) {
  .page-title {
    font-size: 1.2rem;
  }

  .converter-wrapper {
    padding: 1rem;
  }

  .result-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .btn-download {
    width: 100%;
  }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Hidden ── */
[hidden] {
  display: none !important;
}
