/* ═══════════════════════════════════════════════════════════════════════
   Tabla I/O — Palta Builder Stylesheet
   Premium, responsive components for Palta generation, ghost input,
   auto-khali toggle, palta cards, and slash command hints.
   ═══════════════════════════════════════════════════════════════════════ */

/* Container wrapper for ghost text positioning (scoped to ghost overlay only) */
.palta-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  width: 100%;
}

/* Absolute overlay container sitting directly over the input bar */
.palta-ghost-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 5px 12px;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
  white-space: nowrap;
  box-sizing: border-box;
}

/* Invisible span matching typed text to accurately position ghost text after cursor */
.palta-ghost-typed {
  opacity: 0;
  visibility: hidden;
  color: transparent;
  font-size: 0.88rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  letter-spacing: normal;
  white-space: pre;
}

/* Faded suggestion text that appears ahead of cursor */
.palta-ghost-text {
  color: var(--text-tertiary, #555555);
  opacity: 0.4;
  font-style: italic;
  font-size: 0.88rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  pointer-events: none;
  line-height: 1.2;
  transition: opacity var(--transition-fast, 0.15s ease);
}

/* Tiny floating badge below ghost text prompting 'Tab to accept' */
.palta-ghost-hint {
  position: absolute;
  top: calc(100% + 4px);
  right: 12px;
  background: var(--accent, #ea6500);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 100px;
  box-shadow: 0 2px 8px rgba(234, 101, 0, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity var(--transition-fast, 0.15s ease), transform var(--transition-fast, 0.15s ease);
}

.palta-ghost-container.active .palta-ghost-hint,
.palta-ghost-hint.visible {
  opacity: 1;
  transform: translateY(0);
  animation: paltaGhostPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ─── 2. Auto-Khali & Auto-Tihai Pills ────────────────────────────── */

.qe-auto-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.qe-auto-pill {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  background: var(--bg-secondary, #0a0a0a);
  color: var(--text-muted, #555);
  cursor: pointer;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  line-height: 1.4;
  min-height: unset;
}

.qe-auto-pill:hover {
  border-color: var(--border-strong, rgba(255, 255, 255, 0.2));
  color: var(--text-secondary, #888);
}

.qe-auto-pill.active {
  background: var(--accent, #ea6500);
  border-color: var(--accent, #ea6500);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(234, 101, 0, 0.3);
}

.qe-auto-pill.active:hover {
  background: var(--accent-hover, #d45a00);
  border-color: var(--accent-hover, #d45a00);
  box-shadow: 0 0 16px rgba(234, 101, 0, 0.4);
}

@media (max-width: 600px) {
  .qe-auto-pills {
    margin-left: 0;
  }
  .qe-auto-pill {
    font-size: 0.65rem;
    padding: 3px 8px;
  }
}

/* ─── 3. Palta Generator Panel & Cards ────────────────────────────── */

.palta-generator-panel {
  background: var(--bg-secondary, #0a0a0a);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-lg, 16px);
  padding: 24px;
  box-shadow: var(--shadow-lg, 0 20px 50px rgba(0, 0, 0, 0.5)),
              0 0 30px rgba(234, 101, 0, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  box-sizing: border-box;
}

.palta-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

.palta-panel-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary, #f0f0f0);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.palta-panel-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent, #ea6500);
  background: rgba(234, 101, 0, 0.12);
  padding: 3px 10px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.palta-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  width: 100%;
}

/* Individual Palta Result Cards */
.palta-card {
  background: var(--bg-tertiary, #111111);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-md, 12px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  transition: transform var(--transition-normal, 0.25s ease),
              border-color var(--transition-normal, 0.25s ease),
              box-shadow var(--transition-normal, 0.25s ease);
}

.palta-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent, #ea6500);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4),
              0 0 16px rgba(234, 101, 0, 0.18);
}

.palta-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary, #f0f0f0);
}

.palta-card-number {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary, #888888);
}

/* Generated Bols Text Display */
.palta-card-bols {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  background: var(--bg-primary, #000000);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.06));
  border-radius: var(--radius-sm, 8px);
  padding: 12px;
  color: var(--text-primary, #f0f0f0);
  word-break: break-word;
  letter-spacing: 0.02em;
  min-height: 48px;
  box-sizing: border-box;
}

/* Bhari Bols (weighty / open sound) - Warmer & Bolder */
.palta-card .bhari,
.palta-bol-bhari {
  color: var(--accent, #ea6500);
  font-weight: 700;
  background: rgba(234, 101, 0, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
  border-bottom: 2px solid var(--accent, #ea6500);
  display: inline-block;
  margin: 1px;
}

/* Khali Bols (wave / empty sound) - Cooler & Lighter */
.palta-card .khali,
.palta-bol-khali {
  color: #51a49a;
  font-weight: 500;
  opacity: 0.9;
  background: rgba(81, 164, 154, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
  border-bottom: 2px dashed rgba(81, 164, 154, 0.6);
  display: inline-block;
  margin: 1px;
}

/* Action Buttons inside Card */
.palta-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 4px;
}

.palta-card-actions button,
.palta-btn-insert,
.palta-btn-copy {
  padding: 6px 14px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  transition: background var(--transition-fast, 0.15s ease),
              color var(--transition-fast, 0.15s ease),
              transform var(--transition-fast, 0.15s ease),
              box-shadow var(--transition-fast, 0.15s ease);
  outline: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Primary Insert Button */
.palta-btn-insert {
  background: var(--accent, #ea6500);
  color: #ffffff;
  border: none;
}

.palta-btn-insert:hover {
  background: var(--accent-hover, #f97316);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(234, 101, 0, 0.3);
}

.palta-btn-insert:active {
  transform: translateY(0);
}

/* Secondary Copy Button */
.palta-btn-copy {
  background: var(--bg-secondary, #0a0a0a);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  color: var(--text-secondary, #888888);
}

.palta-btn-copy:hover {
  background: var(--bg-glass-hover, #1a1a1a);
  color: var(--text-primary, #f0f0f0);
  border-color: var(--border-strong, rgba(255, 255, 255, 0.2));
  transform: translateY(-1px);
}

/* ─── 4. Slash Command Hint ───────────────────────────────────────── */

.palta-slash-hint {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--bg-tertiary, #141414);
  border: 1px solid var(--border-strong, var(--border-color, rgba(255, 255, 255, 0.15)));
  border-radius: var(--radius-sm, 8px);
  padding: 8px 12px;
  box-shadow: var(--shadow-md, 0 8px 24px rgba(0, 0, 0, 0.4));
  font-size: 0.8rem;
  color: var(--text-secondary, #888888);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
  animation: paltaPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.palta-slash-hint kbd,
.palta-slash-hint .palta-cmd-key {
  background: var(--bg-secondary, #0a0a0a);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent, #ea6500);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Tooltip Downward Arrow */
.palta-slash-hint::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 16px;
  border-width: 5px;
  border-style: solid;
  border-color: var(--border-strong, var(--border-color, rgba(255, 255, 255, 0.15))) transparent transparent transparent;
}

/* ─── Keyframe Animations ────────────────────────────────────────── */

@keyframes paltaPopIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

/* ─── 5. Responsive Layout & Mobile Enhancements ──────────────────── */

/* Mobile Breakpoint (<600px) */
@media (max-width: 600px) {

  .palta-cards-grid {
    grid-template-columns: 1fr;
  }

  .palta-generator-panel {
    padding: 16px;
    border-radius: var(--radius-md, 12px);
  }

  .palta-ghost-hint {
    display: none; /* Hide floating badge on small touch screens to avoid overlap */
  }

  .palta-card-actions {
    flex-direction: row;
    width: 100%;
  }

  .palta-btn-insert,
  .palta-btn-copy {
    flex: 1;
    justify-content: center;
  }
}

/* ─── 6. Light Theme Overrides ────────────────────────────────────── */

[data-theme="light"] .palta-ghost-text {
  color: var(--text-tertiary, #888888);
  opacity: 0.5;
}

[data-theme="light"] .qe-auto-pill:not(.active) {
  background: var(--bg-tertiary, #ebebeb);
  border-color: var(--border-color, rgba(0, 0, 0, 0.1));
  color: var(--text-muted, #999);
}

[data-theme="light"] .qe-auto-pill:not(.active):hover {
  border-color: var(--border-strong, rgba(0, 0, 0, 0.2));
  color: var(--text-secondary, #666);
}

[data-theme="light"] .palta-card .khali,
[data-theme="light"] .palta-bol-khali {
  color: #2b7a78;
  background: rgba(43, 122, 120, 0.12);
  border-bottom-color: rgba(43, 122, 120, 0.6);
}

[data-theme="light"] .palta-slash-hint {
  background: var(--bg-secondary, #ffffff);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
