/* ==========================================================
   SimpleConvertor — Style Sheet
   ========================================================== */

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

:root {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-border-hover: #3b82f6;
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-light: #eff6ff;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;
  --color-error: #ef4444;
  --color-success: #22c55e;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  --max-width: 720px;
}

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

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- App Layout ------------------------------------------ */
.app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Hero ----------------------------------------------- */
.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}

.hero h1 {
  font-size: 2.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.hero .subtitle {
  margin-top: 0.5rem;
  font-size: 1.1rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* --- Card ----------------------------------------------- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  margin-bottom: 2rem;
  flex: 1;
}

/* --- Upload Zone ---------------------------------------- */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--color-bg);
}

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

.upload-zone.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  transform: scale(1.01);
}

.upload-icon {
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
  transition: color 0.2s;
}

.upload-zone:hover .upload-icon,
.upload-zone.drag-over .upload-icon {
  color: var(--color-primary);
}

.upload-text {
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.upload-text strong {
  color: var(--color-primary);
}

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

.first-run-note {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  line-height: 1.4;
}

.first-run-note svg {
  flex-shrink: 0;
  color: #ca8a04;
}

/* --- Preview -------------------------------------------- */
.preview-area {
  margin-top: 1.25rem;
}

.preview-image-wrapper {
  width: 100%;
  max-height: 400px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #f1f5f9;
}

.preview-image-wrapper img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: contain;
  display: block;
}

.preview-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

.preview-filename {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-filesize {
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* --- Buttons -------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-weight: 600;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  background: var(--color-surface);
  color: var(--color-text);
}

.btn:hover {
  background: #f1f5f9;
}

.btn-primary {
  width: 100%;
  padding: 0.875rem 1.5rem;
  font-size: 1.05rem;
  background: var(--color-primary);
  color: white;
  border: none;
  margin-top: 1.25rem;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

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

.btn-ghost {
  background: none;
  border: none;
  padding: 0.25rem;
  color: var(--color-text-muted);
  cursor: pointer;
}

.btn-ghost:hover {
  color: var(--color-error);
}

.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: 0.825rem;
}

.btn-small svg {
  flex-shrink: 0;
}

.btn-spinner {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.hidden {
  display: none !important;
}

/* --- Spinner -------------------------------------------- */
.spinner {
  animation: rotate 0.8s linear infinite;
  stroke: currentColor;
}

@keyframes rotate {
  100% { transform: rotate(360deg); }
}

/* --- Progress Bar --------------------------------------- */
.progress-section {
  margin-top: 1rem;
}

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

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), #8b5cf6);
  border-radius: 3px;
  animation: progressPulse 1.5s ease-in-out infinite;
  transition: width 0.3s ease;
}

@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.progress-text {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-top: 0.5rem;
  text-align: center;
}

/* --- Error ---------------------------------------------- */
.error-section {
  margin-top: 1rem;
}

.error-message {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: var(--color-error);
  font-size: 0.9rem;
}

/* --- Results -------------------------------------------- */
.results-section {
  margin-top: 1.5rem;
}

.results-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 1rem;
}

.tab-btn {
  padding: 0.625rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--color-text-secondary);
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.results-panel .results-text {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 500px;
  overflow-y: auto;
  min-height: 100px;
}

.results-table {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
}

.results-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.results-table th,
.results-table td {
  padding: 0.625rem 0.75rem;
  text-align: left;
  border: 1px solid var(--color-border);
}

.results-table th {
  background: var(--color-primary-light);
  font-weight: 700;
  color: var(--color-text);
}

.results-table td {
  background: var(--color-surface);
}

.results-table tr:nth-child(even) td {
  background: #f8fafc;
}

.results-table tr:hover td {
  background: #f1f5f9;
}

.results-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.processing-info {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.75rem;
  text-align: right;
}

/* --- Footer --------------------------------------------- */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  padding: 1.5rem 0;
}

.about-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  padding: 0.5rem 0;
  transition: color 0.2s;
}

.about-toggle:hover {
  color: var(--color-primary);
}

.about-arrow {
  transition: transform 0.3s ease;
  margin-left: auto;
}

.about-arrow.open {
  transform: rotate(180deg);
}

.about-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.3s ease;
  opacity: 0;
}

.about-content.open {
  max-height: 400px;
  opacity: 1;
}

.about-body {
  padding: 1rem 0 0.5rem;
  line-height: 1.7;
  color: var(--color-text-secondary);
  font-size: 0.925rem;
}

.about-body h3 {
  font-size: 1.1rem;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.about-body p {
  margin-bottom: 0.75rem;
}

.about-body p:last-child {
  margin-bottom: 0;
}

.contact-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

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

.footer-bottom {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: 0.825rem;
  color: var(--color-text-muted);
}

/* --- Responsive ----------------------------------------- */
@media (max-width: 600px) {
  .hero h1 {
    font-size: 1.75rem;
  }

  .hero .subtitle {
    font-size: 0.95rem;
  }

  .card {
    padding: 1.25rem;
    border-radius: var(--radius-md);
  }

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

  .upload-icon svg {
    width: 36px;
    height: 36px;
  }

  .results-actions {
    flex-wrap: wrap;
  }

  .app {
    padding: 0 1rem;
  }
}

@media (max-width: 400px) {
  .hero {
    padding: 2rem 0 1.5rem;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .btn-primary {
    font-size: 0.95rem;
    padding: 0.75rem 1rem;
  }
}

/* --- SEO Content (hidden from UI, visible to search engines) --- */
.seo-content {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Focus styles for accessibility --- */
.upload-zone:focus-visible,
.tab-btn:focus-visible,
.btn:focus-visible,
.about-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* --- Print styles --- */
@media print {
  .upload-section,
  .progress-section,
  .error-section {
    display: none !important;
  }

  .results-section {
    display: block !important;
  }

  .footer {
    position: static;
  }
}
