/* ===== THEME TOKENS ===== */
/* Values sourced from lomaketulkki reference */

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --border: #e2e4e7;
  --accent: #3c82f6;
  --accent-hover: #2563eb;
  --info: #e8f1ff;
  --info-border: #b8d1ff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-soft: 0 10px 25px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --header-h: 60px;
}

[data-theme="dark"] {
  --bg: #1f1f1f;
  --surface: #2a2a2a;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --border: #444444;
  --accent: #5c9cff;
  --accent-hover: #93c5fd;
  --info: #2c3a52;
  --info-border: #3d5273;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.6);
}

/* ===== RESET ===== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

body {
  min-height: 100vh;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.app-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--header-h);
}

.header-title h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}

.header-desc {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== HEADER CONTROLS (lang + theme) ===== */

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lang-select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  max-width: 130px;
  transition: border-color 0.15s;
}

.lang-select:focus {
  border-color: var(--accent);
}

.theme-toggle {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: background 0.15s;
  padding: 0;
}

.theme-toggle:hover {
  background: var(--info);
}

/* ===== MAIN ===== */

.app-main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 24px auto 48px;
  padding: 0 24px;
}

/* ===== TWO-COLUMN LAYOUT ===== */

.main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px 24px;
  align-items: start;
}

/* ===== STEP ROW (full-width, centered) ===== */

.step-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

.step-indicator {
  display: flex;
  align-items: center;
}

.step-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.step-btn.visited {
  border-color: var(--accent);
  color: var(--accent);
  cursor: pointer;
}

.step-btn.visited:hover {
  background: var(--info);
}

.step-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: default;
}

.step-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
}

/* ===== SLIDES ===== */

.slides-viewport {
  overflow: hidden;
  min-height: 480px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.slides-container {
  display: flex;
  transition: transform 0.3s ease-out;
}

.slide {
  flex: 0 0 100%;
  padding: 28px;
  box-sizing: border-box;
}

.slide-title {
  margin: 0 0 20px;
  font-size: 19px;
  font-weight: 700;
}

/* ===== FORM FIELDS ===== */

.field-group {
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field-optional {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  margin-inline-start: 4px;
}

.field-input,
.field-textarea,
.field-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field-input:focus,
.field-textarea:focus,
.field-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(60, 130, 246, 0.15);
}

.field-textarea {
  resize: vertical;
  min-height: 100px;
}

.field-hint {
  display: block;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 4px;
  min-height: 1.25em;
}

.lang-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ===== BUTTONS ===== */

.slide-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
}

.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  padding: 9px 20px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, filter 0.15s;
  line-height: 1;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

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

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg);
}

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

.btn-block {
  width: 100%;
  text-align: center;
}

/* ===== SIDEBAR ===== */

.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.card-title {
  margin: 0;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.card-body {
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.55;
}

.card-body p {
  margin: 0 0 8px;
}

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

.sidebar-pending {
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}

.tip-block {
  background: var(--info);
  border: 1px solid var(--info-border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 13px;
}

.tip-block:last-child {
  margin-bottom: 0;
}

.tip-block strong {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.tip-block p {
  margin: 0;
  color: var(--text);
}

/* ===== DRAFT (slide 5) ===== */

.drafts {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.draft-lang-label {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.draft-text {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-line;
  min-height: 80px;
}

.error-msg {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 14px 16px;
  color: #dc2626;
  font-size: 14px;
}

[data-theme="dark"] .error-msg {
  background: #4b1e1e;
  border-color: #7a3737;
  color: #fca5a5;
}

/* ===== LOADING MODAL ===== */

.loading-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
  backdrop-filter: blur(2px);
}

.loading-modal.active {
  opacity: 1;
  visibility: visible;
}

.loading-spinner-wrapper {
  background: var(--surface);
  border-radius: 12px;
  padding: 2.5rem 3rem;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  min-width: 200px;
  text-align: center;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

.loading-spinner-wrapper p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

/* ===== RTL OVERRIDES ===== */

/* Inputs inherit dir="auto" from attribute — no override needed.
   Layout flips automatically via dir="rtl" on <html>. */

[dir="rtl"] .step-line {
  /* Step line direction is visual only — no change needed */
}

/* draft text: let dir="auto" on the element handle reading direction */
[dir="rtl"] .draft-text {
  direction: auto;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  .app-main {
    padding: 0 16px;
    margin: 16px auto 32px;
  }

  .app-header-inner {
    padding: 8px 16px;
    min-height: auto;
  }

  .header-desc {
    display: none;
  }

  .main-layout {
    grid-template-columns: 1fr;
  }

  .slides-viewport {
    min-height: auto;
  }

  .sidebar {
    position: static;
  }

  .lang-row {
    grid-template-columns: 1fr;
  }

  .step-line {
    width: 24px;
  }
}

@media (max-width: 480px) {
  .slide {
    padding: 20px 16px;
  }

  .step-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .step-line {
    width: 14px;
  }

  .lang-select {
    max-width: 100px;
    font-size: 12px;
  }
}

/* ===== PASSWORD MODAL ===== */

.password-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(3px);
}

.password-modal.hidden {
  display: none;
}

.password-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.password-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.password-modal-error {
  margin: 0;
  font-size: 13px;
  color: #dc2626;
  padding: 8px 10px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
}

[data-theme="dark"] .password-modal-error {
  background: #4b1e1e;
  border-color: #7a3737;
  color: #fca5a5;
}

.password-modal-input {
  margin: 0;
}
