/* ═══════════════════════════════════════════════════════════════════════
   Tabla I/O — Onboarding Tutorial Popup & Help Button Styles
   File: css/tutorial-popup.css
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── 1. Popup Overlay ──────────────────────────────────────────────── */
.tutorial-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 10050;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.3s ease;
  padding: 16px;
}

.tutorial-overlay.active {
  display: flex;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ─── 2. Popup Card ─────────────────────────────────────────────────── */
.tutorial-card {
  position: relative;
  width: 100%;
  max-width: 600px;
  height: min(560px, calc(100dvh - 32px));
  background: var(--bg-surface, var(--bg-card, var(--bg-primary, #0d0d0d)));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45),
              0 0 30px rgba(234, 101, 0, 0.12);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  transform: scale(0.95) translateY(10px);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  margin: auto;
}

.tutorial-overlay.active .tutorial-card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* ─── 3. Popup Header ───────────────────────────────────────────────── */
.tutorial-header {
  padding: 24px 100px 18px 24px;
  text-align: left;
  display: flex;
  align-items: center;
  min-height: 72px;
  position: relative;
}

.tutorial-header .tutorial-icon { display: none; }
.tutorial-header h2 { min-width: 0; white-space: normal; }
#tutorial-lang-toggle { top: 20px !important; right: 20px !important; }

.tutorial-header-icon,
.tutorial-header .tutorial-icon {
  font-size: 2rem;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-subtle, rgba(234, 101, 0, 0.12));
  border-radius: 50%;
  color: var(--accent, #ea6500);
  box-shadow: 0 0 20px rgba(234, 101, 0, 0.15);
  line-height: 1;
}

.tutorial-header h2,
.tutorial-header-title,
.tutorial-title {
  margin: 0;
  font-family: var(--font-system);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary, #f0f0f0);
  letter-spacing: -0.01em;
  line-height: 1.3;
}


.tutorial-header p,
.tutorial-subtitle {
  margin: 2px 0 0 0;
  font-size: 0.875rem;
  color: var(--text-secondary, #888888);
  line-height: 1.4;
}

/* Optional Close Icon Button in top-right of card */
.tutorial-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-tertiary, #555555);
  font-size: 1.25rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
  line-height: 1;
}

.tutorial-close-btn:hover {
  color: var(--text-primary, #f0f0f0);
  background: var(--bg-tertiary, #111111);
}

/* ─── 3.5 Tabs ──────────────────────────────────────────────────────── */
.tutorial-tabs {
  display: flex;
  margin: 0 24px 16px 24px;
  gap: 8px;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  padding-bottom: 8px;
}

.tutorial-tab-btn {
  min-height: 30px;
  line-height: 1.25;
  background: transparent;
  border: none;
  color: var(--text-tertiary, #666);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tutorial-tab-btn:hover {
  background: var(--bg-tertiary, rgba(255, 255, 255, 0.05));
  color: var(--text-secondary, #aaa);
}

.tutorial-tab-btn.active {
  background: var(--accent-subtle, rgba(234, 101, 0, 0.15));
  color: var(--accent, #ea6500);
}

/* ─── 4. Popup Body ─────────────────────────────────────────────────── */
.tutorial-body {
  padding: 0 24px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: visible;
}

/* One reading order, with room reserved for the longest section. */
.tutorial-tab-content.active {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-content: start;
}

.tutorial-tab-content > .tutorial-divider {
  display: none;
}

.tutorial-feature > div:last-child {
  min-width: 0;
}

.tutorial-feature strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.35;
}

.tutorial-feature p {
  margin: 6px 0 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text-secondary, #888888);
}

.tutorial-btn-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* Numbered rows separated by rules, without individual cards. */
.tutorial-feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

.tutorial-feature:last-child { border-bottom: 0; }

#tutorial-btn-back:disabled { opacity: 0.4; cursor: default; }

.tutorial-feature-icon {
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-subtle, rgba(234, 101, 0, 0.12));
  color: var(--accent, #ea6500);
  border-radius: 50%;
  flex-shrink: 0;
}

.tutorial-feature-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tutorial-feature-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary, #f0f0f0);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.tutorial-feature-desc,
.tutorial-feature-description {
  font-size: 0.85rem;
  color: var(--text-secondary, #888888);
  line-height: 1.45;
  margin: 0;
}

/* Keyboard Shortcut Badges */
.tutorial-shortcut {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-subtle, rgba(234, 101, 0, 0.15));
  color: var(--accent, #ea6500);
  border: 1px solid var(--accent, #ea6500);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
  line-height: 1.2;
  vertical-align: middle;
  letter-spacing: -0.02em;
}

/* Divider Line */
.tutorial-divider {
  height: 1px;
  width: 100%;
  background: var(--border-color, rgba(255, 255, 255, 0.08));
  border: none;
  margin: 4px 0;
  flex-shrink: 0;
}

/* ─── 5. Popup Footer ───────────────────────────────────────────────── */
.tutorial-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  background: var(--bg-secondary, #0a0a0a);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tutorial-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary, #888888);
  user-select: none;
  cursor: pointer;
  transition: color 0.2s ease;
}

.tutorial-checkbox-row:hover {
  color: var(--text-primary, #f0f0f0);
}

.tutorial-checkbox-row input[type="checkbox"],
.tutorial-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  min-height: 16px !important;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.2));
  border-radius: 4px;
  background: var(--bg-tertiary, #111111);
  cursor: pointer;
  position: relative;
  outline: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin: 0;
}

.tutorial-checkbox-row input[type="checkbox"]:checked,
.tutorial-checkbox:checked {
  background: var(--accent, #ea6500);
  border-color: var(--accent, #ea6500);
}

.tutorial-checkbox-row input[type="checkbox"]:checked::after,
.tutorial-checkbox:checked::after {
  content: "";
  width: 4px;
  height: 8px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
  display: block;
}

.tutorial-checkbox-row input[type="checkbox"]:focus-visible,
.tutorial-checkbox:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-subtle, rgba(234, 101, 0, 0.3));
}

/* Footer Action Buttons Container */
.tutorial-footer-actions,
.tutorial-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  width: 100%;
}

/* Secondary / Skip Button */
.tutorial-btn-skip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary, #888888);
  background: transparent;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}

.tutorial-btn-skip:hover {
  color: var(--text-primary, #f0f0f0);
  background: var(--bg-tertiary, #111111);
  border-color: var(--text-secondary, #888888);
}

.tutorial-btn-skip:active {
  transform: translateY(0);
}

/* Primary / OK Button */
.tutorial-btn-ok, .tutorial-btn-next {
  flex: 0 0 auto;
  min-width: 84px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  color: #ffffff;
  background: var(--accent, #ea6500);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(234, 101, 0, 0.25);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}

.tutorial-btn-ok:hover, .tutorial-btn-next:hover {
  background: var(--accent-hover, #f97316);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(234, 101, 0, 0.35);
}

.tutorial-btn-ok:active, .tutorial-btn-next:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(234, 101, 0, 0.2);
}

/* ─── 6. Help Icon Button ───────────────────────────────────────────── */
.tutorial-help-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary, #0a0a0a);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  color: var(--text-secondary, #888888);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
  outline: none;
  text-decoration: none;
  margin: 0;
}

.tutorial-help-btn:hover {
  border-color: var(--accent, #ea6500);
  color: var(--accent, #ea6500);
  background: var(--accent-subtle, rgba(234, 101, 0, 0.1));
  box-shadow: 0 0 10px rgba(234, 101, 0, 0.35);
  transform: scale(1.06);
}

.tutorial-help-btn:focus-visible {
  outline: 2px solid var(--accent, #ea6500);
  outline-offset: 2px;
}

.tutorial-help-btn:active {
  transform: scale(0.96);
}

/* Compact spacing keeps the same guide readable on smaller screens. */
@media (max-width: 639px) {
  .tutorial-overlay { padding: 12px; }
  .tutorial-card { height: min(620px, calc(100dvh - 24px)); }
  .tutorial-header { padding: 16px 78px 12px 16px; min-height: 64px; }
  .tutorial-header h2 { font-size: 1.1rem; }
  #tutorial-lang-toggle { top: 14px !important; right: 14px !important; }
  .tutorial-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0 16px 8px;
    gap: 4px;
    padding-bottom: 6px;
  }
  .tutorial-tab-btn { padding: 4px 6px; font-size: 0.8rem; }
  .tutorial-body { padding: 0 16px 12px; }
  .tutorial-feature { padding: 10px 0; gap: 10px; }
  .tutorial-feature strong { font-size: 0.875rem; }
  .tutorial-feature p { margin-top: 4px; font-size: 0.8125rem; line-height: 1.4; }
  .tutorial-footer { padding: 12px 16px; flex-direction: column; align-items: stretch; gap: 10px; }
  .tutorial-btn-row { justify-content: flex-end; }
  .tutorial-btn-ok, .tutorial-btn-next, .tutorial-btn-skip { padding: 8px 12px; font-size: 0.85rem; }
}

@media (max-width: 360px) {
  .tutorial-header h2 { font-size: 0.95rem; }
  .tutorial-header { padding-top: 12px; padding-bottom: 10px; min-height: 56px; }
  .tutorial-feature { display: block; position: relative; padding: 6px 0; }
  .tutorial-feature-icon { position: absolute; top: 6px; left: 0; min-width: 18px; height: 18px; }
  .tutorial-feature strong { padding-left: 26px; min-height: 18px; }
  .tutorial-shortcut { padding: 0 4px; }
  .tutorial-footer { padding: 8px 16px; gap: 6px; }
}

/* On landscape phones, use the full row width for each explanation. */
@media (min-width: 640px) and (max-height: 500px) {
  .tutorial-header { padding: 12px 90px 10px 20px; min-height: 48px; }
  .tutorial-header h2 { font-size: 1.1rem; }
  #tutorial-lang-toggle { top: 8px !important; right: 14px !important; }
  .tutorial-tabs { margin: 0 20px 4px; gap: 4px; padding-bottom: 4px; }
  .tutorial-tab-btn { padding: 4px 8px; font-size: 0.8rem; }
  .tutorial-body { padding: 0 20px 6px; }
  .tutorial-feature { padding: 6px 0; gap: 10px; }
  .tutorial-feature > div:last-child { font-size: 0.8125rem; line-height: 1.4; }
  .tutorial-feature strong { display: inline; font-size: 0.875rem; margin-right: 6px; }
  .tutorial-feature p { display: inline; font-size: 0.8125rem; line-height: 1.35; }
  .tutorial-feature-icon { min-width: 20px; height: 20px; }
  .tutorial-shortcut { padding: 0 4px; }
  .tutorial-footer { padding: 8px 20px; }
  .tutorial-btn-ok, .tutorial-btn-next, .tutorial-btn-skip { padding: 7px 12px; }
}

/* ─── 7.5 Bol Dictionary Tab (Apple Reference) ────────────────────── */
.tutorial-dictionary-search-box {
  margin-bottom: 12px;
}

.tutorial-dictionary-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  border-radius: 10px;
  color: var(--text-primary, #f0f0f0);
  font-family: var(--font-system);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
  box-sizing: border-box;
}

[data-theme="cream"] .tutorial-dictionary-input {
  background: #ffffff;
  border-color: rgba(180, 110, 50, 0.25);
  color: #2C1A0E;
}

[data-theme="light"] .tutorial-dictionary-input {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.15);
  color: #111111;
}

.tutorial-dictionary-input:focus {
  border-color: var(--accent, #ea6500);
  box-shadow: 0 0 0 3px var(--accent-subtle, rgba(234, 101, 0, 0.15));
}

.tutorial-dictionary-table-wrap {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 10px;
  background: var(--bg-card, rgba(0, 0, 0, 0.15));
}

[data-theme="cream"] .tutorial-dictionary-table-wrap {
  background: #ffffff;
  border-color: rgba(180, 110, 50, 0.18);
}

[data-theme="light"] .tutorial-dictionary-table-wrap {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
}

.tutorial-dictionary-table {
  width: 100%;
  border-collapse: collapse;
}

.tutorial-dictionary-table th {
  padding: 9px 14px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #888);
  background: var(--bg-secondary, rgba(0, 0, 0, 0.3));
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  z-index: 1;
}

[data-theme="cream"] .tutorial-dictionary-table th {
  background: #f7ede0;
  color: #6B3F1F;
}

[data-theme="light"] .tutorial-dictionary-table th {
  background: #f5f5f5;
  color: #555555;
}

.tutorial-dictionary-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.05));
  color: var(--text-primary, #f0f0f0);
  font-size: 0.92rem;
}

[data-theme="cream"] .tutorial-dictionary-table td {
  color: #2C1A0E;
  border-color: rgba(180, 110, 50, 0.1);
}

[data-theme="light"] .tutorial-dictionary-table td {
  color: #111111;
  border-color: rgba(0, 0, 0, 0.06);
}

.tutorial-dictionary-table tr:last-child td {
  border-bottom: none;
}

.tutorial-dictionary-table tr:hover {
  background: var(--accent-subtle, rgba(234, 101, 0, 0.08));
}

/* ─── 8. Accessibility (Reduced Motion) ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .tutorial-overlay,
  .tutorial-card,
  .tutorial-feature,
  .tutorial-btn-ok,
  .tutorial-btn-next,
  .tutorial-btn-skip,
  .tutorial-help-btn {
    transition: none !important;
    animation: none !important;
  }
}
