/* ===== Variables ===== */
:root {
  --bg: #0f0f12;
  --surface: #18181d;
  --surface-hover: #222228;
  --border: #2d2d35;
  --text: #e8e8ed;
  --text-muted: #8b8b98;
  --accent: #7c6ef6;
  --accent-hover: #9185f8;
  --accent-muted: rgba(124, 110, 246, 0.2);
  --success: #4ade80;
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
}

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

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== Layout ===== */
.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.logo {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.lang-switcher {
  display: flex;
  gap: 0.25rem;
}

.lang-btn {
  font: inherit;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.lang-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.lang-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}

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

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface);
  padding: 0.25rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 0.65rem 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

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

.tab.active {
  color: var(--text);
  background: var(--accent-muted);
  color: var(--accent);
}

/* ===== Panels ===== */
.panel {
  display: none;
  animation: fadeIn 0.25s ease;
}

.panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

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

/* ===== Dropzone ===== */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  margin-bottom: 1rem;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.dropzone-text {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

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

/* ===== Preview list (PDF) ===== */
.preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  min-height: 0;
}

.preview-list:empty {
  display: none;
}

.preview-item {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-hover);
  border: 1px solid var(--border);
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-item .order {
  position: absolute;
  top: 4px;
  left: 4px;
  background: var(--accent);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-item .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  background: rgba(0,0,0,0.6);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.preview-item .remove:hover {
  background: #c0392b;
}

/* ===== Preview single (image format) ===== */
.preview-single {
  margin-top: 1rem;
  text-align: center;
}

.preview-single:empty {
  display: none;
}

.preview-single img {
  max-width: 100%;
  max-height: 240px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ===== Format options ===== */
.format-options,
.text-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.format-options.hidden,
.text-options.hidden {
  display: none;
}

.format-options label,
.text-options label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.quality-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

select {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
}

/* ===== Buttons ===== */
.actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.btn {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition);
}

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

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

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

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

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

/* ===== Text preview ===== */
.text-preview {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 1rem;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-muted);
}

.text-preview:empty {
  display: none;
}

/* ===== Footer ===== */
.footer {
  margin-top: auto;
  padding-top: 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .app {
    padding: 1.25rem 1rem;
  }

  .tabs {
    flex-direction: column;
  }

  .card {
    padding: 1.25rem;
  }

  .format-options,
  .text-options {
    flex-direction: column;
    align-items: stretch;
  }
}
