/* ===========================
   MORSE TRANSLATOR — COMPLETE CSS
   =========================== */

/* Card container */
.card-like.translator {
  position: relative;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  padding: 0;
  overflow: hidden;
  margin: 0 0 24px 0;
}

/* Header */
.translator__header {
  background: #dff1ff;
  padding: 14px 18px;
}
.translator__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #222;
}

/* --- Titles (no solid header bar inside each card) --- */
.editor-title {
  margin: 0 0 10px 0;
  font-size: 18px;
  font-weight: 700;
  color: #0b0b0b;
}

/* Remove the old absolute blue header and heavy padding */
.translator {
  position: static;
  box-shadow: none;
  border: none;
  padding: 0;
  margin: 0 0 18px 0;
}
.translator h2 {
  position: static;
  width: auto;
  height: auto;
  line-height: normal;
  background: transparent;
  color: inherit;
  padding: 0;
  border: 0;
}

/* ===========================
   EDITOR AREA (TEXT + TOOLBAR)
   - Two rows: textarea + toolbar
   - Looks like a single textarea with buttons “inside”
   =========================== */
.editor-area {
  position: relative;
  display: grid;
  grid-template-rows: auto 44px; /* text row + toolbar row */
  grid-template-columns: 1fr;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
  overflow: hidden; /* keeps rounded corners */
}

/* TEXT ROW */
.editor-area textarea {
  grid-row: 1;
  grid-column: 1;
  display: block;
  width: 100%;
  min-height: 200px;
  height: 260px;
  box-sizing: border-box;
  /* Comfortable padding; no need to reserve bottom space */
  padding: 16px 18px 16px;
  font-size: 16px;
  line-height: 1.45;
  color: #111827;
  background: #ffffff;
  resize: none;

  /* Remove textarea’s own box so the container provides the chrome */
  border: 0;
  outline: none;
}

/* Visual divider between text and toolbar (top border of toolbar) */
.editor-area textarea + .editor-toolbar {
  border-top: 1px solid #e5e7eb;
}

/* READONLY variant for the Morse side if used */
.editor-area textarea[readonly] {
  background: #f3f4f6;
}

/* Placeholder tone */
.editor-area textarea::placeholder {
  color: #9ca3af;
  opacity: 1;
}

/* Focus ring for the whole control when the textarea is focused */
.editor-area:has(textarea:focus) {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.35);
}

/* ===========================
   TOOLBAR ROW (BOTTOM)
   - Visually appears “inside” the textarea
   - Holds left icon group + right counter
   =========================== */
.editor-toolbar {
  grid-row: 2;
  grid-column: 1;
  display: grid;
  grid-template-columns: auto 1fr auto; /* left icons | spacer | counter */
  align-items: center;
  background: #ffffff;
  padding: 0 8px;
}

/* Bottom-left icon group (copy / download / share / clear) */
.editor-icons--bottom-left {
  position: static; /* NOT overlay */
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 4px;
  z-index: 1;
}

/* Character counter on the right */
.char-counter {
  position: static; /* NOT overlay */
  justify-self: end;
  align-self: center;
  padding: 0 10px;
  font-size: 12px;
  color: #9ca3af;
  user-select: none;
  pointer-events: none;
}

/* ===========================
   TOP-RIGHT OVERLAY ICONS
   (copy etc. for that row if present)
   =========================== */
.editor-icons {
  display: flex;
  gap: 8px;
  z-index: 2;
}
.editor-icons--top-right {
  position: absolute;
  top: 10px;
  right: 10px;
}

/* Icon buttons */
/* Ensure all icon buttons are true circles and content is centered */
.icon-btn {
  display: flex; /* use flexbox instead of grid */
  align-items: center; /* vertical center */
  justify-content: center; /* horizontal center */
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #f8f8f8;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.18s ease;
  padding: 0; /* remove any padding offset */
  line-height: 0; /* remove text line-height gap */
}

.icon-btn svg,
.icon-btn img {
  width: 18px;
  height: 18px;
  display: block; /* prevents extra baseline spacing */
}

.icon-btn:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.icon-btn:active {
  transform: translateY(0.5px);
}

/* Disabled state (prevents hover tooltips, clicks) */
.icon-btn[disabled],
.icon-btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* No longer need extra left padding to avoid overlays */
.has-bottom-left-icons textarea {
  padding-left: 18px;
}

/* ===========================
   ACTIONS ROW ABOVE LIGHTBOX
   =========================== */
.translator-actions-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 20px 0 30px;
}
.translator-actions-row .btn-control {
  flex: 1;
  text-align: center;
  border: 1px solid #ccc;
  background: #fff;
  padding: 12px 0;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}
.translator-actions-row .btn-control:hover {
  border-color: #888;
  background: #f8f8f8;
}

/* Repeat button visual state */
#btn_repeat[aria-pressed="true"] {
  background: #e6f3ff;
  border-color: #2b7cff;
  box-shadow: 0 0 0 2px rgba(43, 124, 255, 0.2) inset;
}

/* App error box */
.app-error {
  background: #ffecec;
  border: 1px solid #ff9b9b;
  color: #6b0000;
  padding: 10px 12px;
  border-radius: 6px;
  margin: 12px 0;
  font-size: 0.95rem;
}

/* ========== Tooltip ========== */
.ui-tooltip {
  position: fixed;
  z-index: 9999;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1;
  background: #111827;
  color: #fff;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.ui-tooltip[data-show="true"] {
  opacity: 1;
  transform: translateY(0);
}
.ui-tooltip::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  background: #111827;
  transform: rotate(45deg);
  left: 50%;
  margin-left: -4px;
  top: -4px;
}

/* ========== Toast (Copied!) ========== */
.ui-toast {
  position: fixed;
  z-index: 10000;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}
.ui-toast[data-show="true"] {
  opacity: 1;
  transform: translateY(0);
}

/* ========== Floating menu (Downloads / Share) ========== */
.ui-menu {
  position: fixed;
  z-index: 10010;
  min-width: 220px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}
.ui-menu[data-show="true"] {
  opacity: 1;
  transform: translateY(0);
}
.ui-menu__list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ui-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  color: inherit;
}
.ui-menu__item:hover,
.ui-menu__item:focus {
  background: #f8f8f8;
  outline: none;
}
.ui-menu__icon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
}

/* Share menu special casing */
.ui-menu--share {
  min-width: 240px;
}
.ui-share__title {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  padding: 6px 8px 10px;
}
.ui-share__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 8px;
}
.ui-share__btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #f8f8f8;
  border: 1px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
}
.ui-share__btn:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.ui-share__icon {
  width: 20px;
  height: 20px;
}

/* ========== Lightbox Panel ========== */
.lightbox {
  position: relative;
  width: 100%;
  min-height: 120px;
  background: #1f1f1f;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  margin-top: 12px;
}
.lightbox__inner {
  height: 120px;
  width: 100%;
  background: #1f1f1f;
  transition: background-color 0.06s ease, box-shadow 0.06s ease,
    opacity 0.12s ease;
}
.lightbox__inner.is-lit {
  background: #fff9c2;
  box-shadow: inset 0 0 160px rgba(255, 245, 180, 0.65);
}

/* Toggle (top-right) */
.lightbox__toggle {
  position: absolute;
  top: 8px;
  right: 10px;
}

.lb-toggle {
  --h: 22px;
  --w: 38px;
  --pad: 2px;
  appearance: none;
  display: inline-block;
  width: var(--w);
  height: var(--h);
  border-radius: 999px;
  background: #3a3a3a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  cursor: pointer;
  outline: none;
}
.lb-toggle__thumb {
  position: absolute;
  top: var(--pad);
  left: var(--pad);
  width: calc(var(--h) - var(--pad) * 2);
  height: calc(var(--h) - var(--pad) * 2);
  border-radius: 999px;
  background: #d1d5db;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.lb-toggle[aria-checked="true"] {
  background: #93c5fd;
  border-color: rgba(59, 130, 246, 0.35);
}
.lb-toggle[aria-checked="true"] .lb-toggle__thumb {
  transform: translateX(calc(var(--w) - var(--h)));
  background: #ffffff;
}

/* Expand (bottom-right) */
.lightbox__expand {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.lightbox__expand:hover {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
}
.lightbox__expand svg {
  width: 18px;
  height: 18px;
  fill: #e5e7eb;
}

/* Fullscreen visual state */
.lightbox.is-fullscreen {
  position: fixed;
  inset: 16px;
  z-index: 10020;
  border-radius: 14px;
}
.lightbox.is-fullscreen .lightbox__inner {
  height: 100%;
}

/* Lightbox header row */
.lightbox-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 6px;
}
.lightbox-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #111827;
}
.lightbox-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.btn-control:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}