/* ==========================================================================
   Mod-Karten Generator — Main Stylesheet
   ========================================================================== */

/* --- 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", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: #1e293b;
  background-color: #f8f9fa;
  min-height: 100vh;
}

/* --- Layout -------------------------------------------------------------- */

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* --- Phase visibility ---------------------------------------------------- */

.phase {
  transition: opacity 0.25s ease;
}

.phase.hidden {
  display: none !important;
}

.phase.visible {
  display: block;
  animation: fadeIn 0.3s ease forwards;
}

/* --- Header -------------------------------------------------------------- */

.app-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.app-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 0.9375rem;
  color: #64748b;
  max-width: 520px;
  margin: 0 auto;
}

/* --- Upload Dropzones ---------------------------------------------------- */

.dropzones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.dropzone-wrapper-full {
  margin-bottom: 1.5rem;
}

.dropzone-wrapper {
  display: flex;
  flex-direction: column;
}

.dropzone-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.5rem;
}

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  padding: 2rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  background-color: #fafbfc;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone:hover {
  border-color: #2563eb;
  background-color: #f0f4ff;
}

.dropzone.dragover {
  border-color: #2563eb;
  background-color: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.dropzone.has-file {
  border-style: solid;
  border-color: #22c55e;
  background-color: #f0fdf4;
  cursor: default;
}

.dropzone-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.dropzone-icon {
  width: 40px;
  height: 40px;
  color: #94a3b8;
  transition: color 0.2s ease;
}

.dropzone:hover .dropzone-icon {
  color: #2563eb;
}

.dropzone-text {
  font-size: 0.8125rem;
  color: #94a3b8;
  line-height: 1.5;
}

.dropzone-filled {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dropzone-check {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.dropzone-filename {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #16a34a;
  word-break: break-all;
}

.dropzone-remove {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.125rem 0.375rem;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
}

.dropzone-remove:hover {
  color: #ef4444;
  background-color: #fef2f2;
}

.dropzone-input {
  display: none;
}

/* --- File Error ---------------------------------------------------------- */

.file-error {
  font-size: 0.8125rem;
  color: #dc2626;
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}

/* --- Settings Panel ------------------------------------------------------ */

.settings-panel {
  margin-bottom: 1.5rem;
}

.settings-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
  margin-bottom: 0.75rem;
  font-family: inherit;
}

.settings-toggle:hover {
  color: #1e293b;
  border-color: #cbd5e1;
  background-color: #f8fafc;
}

.settings-chevron {
  display: inline-block;
  width: 16px;
  height: 16px;
  transition: transform 0.25s ease;
}

.settings-toggle[aria-expanded="true"] .settings-chevron {
  transform: rotate(180deg);
}

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

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

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  padding-top: 0.5rem;
}

.setting-field-wide {
  grid-column: 1 / -1;
}

.setting-field-checkbox {
  display: flex;
  align-items: center;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #2563eb;
  cursor: pointer;
  flex-shrink: 0;
}

.setting-field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #475569;
  margin-bottom: 0.375rem;
}

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

.color-input-wrapper input[type="color"] {
  width: 38px;
  height: 34px;
  padding: 2px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  background: #ffffff;
  flex-shrink: 0;
}

.color-hex {
  font-size: 0.8125rem;
  color: #64748b;
  font-family: "SF Mono", "Fira Code", monospace;
}

/* --- Form Elements ------------------------------------------------------- */

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  line-height: 1.5;
  color: #1e293b;
  background-color: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
}

input[type="text"]:focus,
input[type="number"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input[type="color"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* --- Form Actions -------------------------------------------------------- */

.form-actions {
  margin-top: 0.5rem;
}

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  border: none;
  border-radius: 8px;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}

.btn-primary {
  width: 100%;
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #ffffff;
  background-color: #2563eb;
}

.btn-primary:hover {
  background-color: #1d4ed8;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

.btn-primary:active {
  background-color: #1e40af;
}

.btn-primary:disabled {
  background-color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.7;
}

.btn-secondary {
  width: 100%;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
  background-color: #ffffff;
  border: 1px solid #d1d5db;
}

.btn-secondary:hover {
  background-color: #f8fafc;
  border-color: #94a3b8;
  color: #1e293b;
}

.btn-secondary:active {
  background-color: #f1f5f9;
}

/* --- Processing Section -------------------------------------------------- */

.processing-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  padding: 2rem 1.5rem;
}

.processing-status {
  font-size: 0.9375rem;
  font-weight: 500;
  color: #334155;
  margin-bottom: 1rem;
}

.progress-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background-color: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: #2563eb;
  border-radius: 4px;
  width: 0%;
  transition: width 0.4s ease;
}

.progress-text {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #475569;
  min-width: 3rem;
  text-align: right;
}

/* --- Processing Error ---------------------------------------------------- */

.processing-error {
  font-size: 0.875rem;
  color: #dc2626;
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

/* --- Log Panel ----------------------------------------------------------- */

.log-panel {
  margin-top: 1rem;
}

.log-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: none;
  border: none;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  color: #64748b;
  cursor: pointer;
  padding: 0.25rem 0;
  transition: color 0.15s ease;
}

.log-toggle:hover {
  color: #334155;
}

.log-chevron {
  display: inline-block;
  width: 16px;
  height: 16px;
  transition: transform 0.25s ease;
}

.log-toggle[aria-expanded="true"] .log-chevron {
  transform: rotate(180deg);
}

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

.log-content.open {
  max-height: 220px;
  opacity: 1;
  overflow-y: auto;
}

.log-content pre {
  background-color: #1e293b;
  color: #cbd5e1;
  font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", "Courier New", monospace;
  font-size: 0.75rem;
  line-height: 1.7;
  padding: 1rem;
  border-radius: 6px;
  margin: 0.5rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

.log-content pre::-webkit-scrollbar {
  width: 6px;
}

.log-content pre::-webkit-scrollbar-track {
  background: #1e293b;
}

.log-content pre::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 3px;
}

/* --- Result Section ------------------------------------------------------ */

.result-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  padding: 2.5rem 1.5rem;
  text-align: center;
}

.result-icon {
  margin-bottom: 1rem;
}

.result-icon svg {
  width: 48px;
  height: 48px;
}

.result-card h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.result-card .result-detail,
.result-card .error-detail {
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 1.5rem;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 320px;
  margin: 0 auto;
}

.result-actions .btn {
  width: 100%;
}

/* Result icon colors in headings */
#complete-success h2 {
  color: #15803d;
}

#complete-error h2 {
  color: #dc2626;
}

/* --- Utility Classes ----------------------------------------------------- */

.hidden {
  display: none !important;
}

/* --- Animations ---------------------------------------------------------- */

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

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 640px) {
  .container {
    padding: 1rem 1rem 3rem;
  }

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

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

  .app-header h1 {
    font-size: 1.375rem;
  }

  .dropzone {
    padding: 1.5rem 1rem;
  }

  .processing-card,
  .result-card {
    padding: 1.5rem 1rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0.75rem 0.75rem 2rem;
  }
}
