/* =====================================================================
 * Tober Translator — frontend switcher
 *
 * 4 variant style:
 *   .tobertr-style-1 → bendera + nama
 *   .tobertr-style-2 → bendera saja (compact)
 *   .tobertr-style-3 → kode bahasa (ID/EN) saja
 *   .tobertr-style-4 → dropdown <select>
 *
 * Plus floating widget (.tobertr-floating) & loader bar (.tobertr-loader).
 * Warna aktif lewat CSS variable --tobertr-active (di-inject di PHP).
 * ===================================================================== */

.tobertr-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  vertical-align: middle;
  line-height: 1.3;
}

.tobertr-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  color: inherit;
  text-decoration: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  line-height: 1.3;
  font-family: inherit;
}
.tobertr-btn:hover {
  background: rgba(0,0,0,.05);
  color: var(--tobertr-active, #C0392B);
}
.tobertr-btn:focus-visible {
  outline: 2px solid var(--tobertr-active, #C0392B);
  outline-offset: 2px;
}
.tobertr-btn.active {
  color: var(--tobertr-active, #C0392B);
  font-weight: 700;
}

.tobertr-flag {
  font-size: 16px;
  line-height: 1;
  /* Pakai font emoji yang bagus di tiap OS */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", system-ui, sans-serif;
}

.tobertr-label {
  font-size: inherit;
  white-space: nowrap;
}

/* === Style 2: bendera saja === */
.tobertr-style-2 .tobertr-btn {
  padding: 4px 7px;
}
.tobertr-style-2 .tobertr-flag {
  font-size: 18px;
}
.tobertr-style-2 .tobertr-btn.active {
  background: rgba(192, 57, 43, .08);
  background: color-mix(in srgb, var(--tobertr-active, #C0392B) 10%, transparent);
  border-color: var(--tobertr-active, #C0392B);
}

/* === Style 5: "Language" prefix + dropdown bendera saja === */
.tobertr-style-5 {
  gap: 8px;
}
.tobertr-prefix {
  font-size: 13px;
  font-weight: 600;
  color: var(--tobertr-active, #C0392B);
  white-space: nowrap;
  letter-spacing: .2px;
}
/* Dropdown bendera saja → sedikit lebih compact karena tidak butuh nama panjang.
   Ukuran font emoji dinaikkan supaya bendera terlihat jelas saat collapsed. */
.tobertr-style-5 .tobertr-dropdown {
  padding: 5px 24px 5px 10px;
  font-size: 15px;
  line-height: 1.2;
  min-width: 56px;
}

/* === Style 3: kode bahasa saja (ID/EN) === */
.tobertr-style-3 .tobertr-btn {
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #777;
}
.tobertr-style-3 .tobertr-btn.active {
  color: var(--tobertr-active, #C0392B);
  font-weight: 700;
}

/* === Style 4: dropdown === */
.tobertr-dropdown {
  padding: 6px 28px 6px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23777' d='M0 0l5 6 5-6z'/></svg>") no-repeat right 10px center;
  background-size: 9px;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  color: #333;
  font-family: inherit;
  line-height: 1.3;
}
.tobertr-dropdown:hover { border-color: var(--tobertr-active, #C0392B); }
.tobertr-dropdown:focus {
  outline: none;
  border-color: var(--tobertr-active, #C0392B);
  box-shadow: 0 0 0 3px rgba(192,57,43,.12);
}

/* === Floating widget (bottom-right) === */
.tobertr-floating {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: #fff;
  padding: 7px 9px;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12), 0 1px 3px rgba(0,0,0,.06);
  z-index: 9999;
  border: 1px solid #ececec;
  backdrop-filter: blur(6px);
}
.tobertr-floating.tobertr-style-4 {
  padding: 0;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  border: none;
}
.tobertr-floating.tobertr-style-4 .tobertr-dropdown {
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

@media (max-width: 480px) {
  .tobertr-floating {
    bottom: 12px;
    right: 12px;
    padding: 5px 7px;
  }
  .tobertr-btn { font-size: 12px; padding: 4px 8px; }
  .tobertr-flag { font-size: 15px; }
  .tobertr-style-2 .tobertr-flag { font-size: 17px; }
}

/* === Top loader bar (saat translate sedang jalan) === */
.tobertr-loader {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--tobertr-active, #C0392B) 0%, color-mix(in srgb, var(--tobertr-active, #C0392B) 60%, white) 100%);
  z-index: 99999;
  opacity: 0;
  transition: width .35s ease, opacity .35s ease;
  pointer-events: none;
  box-shadow: 0 0 8px var(--tobertr-active, #C0392B);
}
.tobertr-loader.active {
  opacity: 1;
  width: 90%;
  transition: width 1.2s ease-out, opacity .15s;
}
.tobertr-loader.done {
  width: 100% !important;
  opacity: 0;
  transition: width .25s ease, opacity .35s ease .15s;
}

/* RTL support — saat translate ke Arabic, sebagian tema set dir=rtl */
html[dir="rtl"] .tobertr-floating { right: auto; left: 18px; }
@media (max-width: 480px) {
  html[dir="rtl"] .tobertr-floating { left: 12px; }
}

/* ===== Toast notification (visual feedback) ===== */
.tobertr-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1f1f1f;
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  z-index: 99998;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  max-width: 90vw;
  text-align: center;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.tobertr-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.tobertr-toast--success { background: #2E7D32; }
.tobertr-toast--error   { background: #C62828; }
.tobertr-toast--info    { background: #1565C0; }
