/**
 * components.css
 * Reusable UI component styles for the Nativa platform.
 * Depends on: variables.css
 */

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS
   Base .btn class + variant modifiers.
   ═══════════════════════════════════════════════════════════════════════════ */

/** Base button — layout, typography, transitions */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 0.6rem var(--space-md);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  white-space: nowrap;
}

.btn:active {
  /* Tactile press feedback */
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/** Primary CTA — filled accent background */
.btn-primary {
  background-color: var(--color-accent);
  color: #000;
}

.btn-primary:hover {
  background-color: #00ffb3;
  box-shadow: 0 0 18px rgba(0, 229, 160, 0.35);
}

/** Secondary — outlined accent */
.btn-secondary {
  background-color: transparent;
  color: var(--color-accent);
  border: 1.5px solid var(--color-accent);
}

.btn-secondary:hover {
  background-color: var(--color-accent-dim);
}

/** Ghost — no border, subtle text */
.btn-ghost {
  background-color: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  color: var(--color-text-primary);
  background-color: var(--color-surface-elevated);
}

/** Full-width variant */
.btn-full {
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CARD
   Surface container for content groupings.
   ═══════════════════════════════════════════════════════════════════════════ */

.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  transition: border-color var(--transition-fast);
}

.card:hover {
  border-color: var(--color-border-active);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BADGE
   Small status / label pill.
   ═══════════════════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background-color: var(--color-surface-elevated);
  color: var(--color-text-secondary);
}

/** Premium badge — accent glow */
.badge-premium {
  background-color: var(--color-accent-dim);
  color: var(--color-accent);
  border: 1px solid rgba(0, 229, 160, 0.3);
}

/* ═══════════════════════════════════════════════════════════════════════════
   INPUTS
   Text input and textarea.
   ═══════════════════════════════════════════════════════════════════════════ */

.input,
.textarea {
  width: 100%;
  background-color: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.7rem var(--space-md);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.7;
}

/** Focused state — accent border + subtle glow */
.input:focus,
.textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 229, 160, 0.12);
}

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

/** Label sitting above an input */
.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

/** Field wrapper for consistent spacing */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOAST
   Transient notification that slides up from the bottom.
   ═══════════════════════════════════════════════════════════════════════════ */

.toast {
  position: fixed;
  bottom: calc(56px + var(--space-md)); /* above tab bar */
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  z-index: var(--z-toast);
  background-color: var(--color-surface-elevated);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.65rem 1.2rem;
  font-size: 0.88rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--transition-normal),
    transform var(--transition-normal);
  white-space: nowrap;
  max-width: calc(100vw - 2rem);
}

/** Visible state — added by JS */
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/** Error variant */
.toast.toast-error {
  border-color: var(--color-error);
  color: var(--color-error);
}

/** Success variant */
.toast.toast-success {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BOTTOM TAB BAR
   Fixed 5-tab navigation at the bottom of the screen.
   ═══════════════════════════════════════════════════════════════════════════ */

/** Tab bar container */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: stretch;
  z-index: var(--z-popup);
  /* Safe area for phones with home indicator */
  padding-bottom: env(safe-area-inset-bottom);
}

/** Individual tab button */
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  position: relative;
  color: var(--color-text-secondary);
  transition: color var(--transition-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

/** Tab icon emoji / SVG */
.tab-item__icon {
  font-size: 1.2rem;
  line-height: 1;
}

/** Tab label text */
.tab-item__label {
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/** Active tab — accent colour + top underline */
.tab-item.is-active {
  color: var(--color-accent);
}

.tab-item.is-active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background-color: var(--color-accent);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOADER
   Spinning circle indicator in accent colour.
   ═══════════════════════════════════════════════════════════════════════════ */

.loader {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--color-accent-dim);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

/** Small variant */
.loader-sm {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

/** Centered loader wrapper */
.loader-center {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-xl) 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   EMPTY STATE
   Shown when a list or view has no content.
   ═══════════════════════════════════════════════════════════════════════════ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-xl) var(--space-md);
  text-align: center;
}

.empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-sm);
}

.empty-state__title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.empty-state__subtitle {
  font-size: 0.88rem;
  color: var(--color-text-secondary);
  max-width: 280px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   POPUP (word translation)
   Floating card anchored near clicked word.
   ═══════════════════════════════════════════════════════════════════════════ */

.popup {
  position: fixed;
  z-index: var(--z-popup);
  background-color: var(--color-surface-elevated);
  border: 1px solid var(--color-border-active);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  min-width: 240px;
  max-width: 320px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  display: none;
}

.popup.is-visible {
  display: block;
  animation: popIn 160ms ease;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL (full-screen overlay)
   ═══════════════════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: var(--z-modal);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.is-visible {
  display: flex;
  animation: fadeIn 180ms ease;
}

.modal-sheet {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-lg) var(--space-md);
  width: 100%;
  max-width: 600px;
  max-height: 90dvh;
  overflow-y: auto;
  animation: slideUp 200ms ease;
}
