/**
 * LearnDash Translator - Estilos del Frontend
 */

/* =========================================
   Contenedor principal del widget
   ========================================= */
.ldt-translator-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    z-index: 99999;
}

/* Posición flotante */
.ldt-translator-container.ldt-position-floating {
    position: fixed;
    bottom: 20px;
    right: 20px;
}

.ldt-translator-container.ldt-position-floating.ldt-position-bottom-left {
    right: auto;
    left: 20px;
}

/* Posición en header/contenido */
.ldt-translator-container.ldt-position-header,
.ldt-translator-container.ldt-position-content-top {
    position: relative;
    display: inline-flex;
    margin: 15px 0;
}

/* Posición inline (shortcode) */
.ldt-translator-container.ldt-position-inline {
    position: relative;
    display: inline-flex;
    margin: 10px 0;
}

.ldt-translator-container.ldt-position-inline .ldt-dropdown {
    bottom: auto;
    top: calc(100% + 10px);
    left: 0;
    right: auto;
}

/* =========================================
   Botón principal
   ========================================= */
.ldt-translate-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0;
    background: transparent !important;
    background-color: transparent !important;
    border: none;
    cursor: pointer;
    outline: none;
    position: relative;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.ldt-translate-btn:hover,
.ldt-translate-btn:focus,
.ldt-translate-btn:active,
.ldt-translate-btn:focus-visible {
    background: transparent !important;
    background-color: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.ldt-translate-btn .ldt-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--ldt-bg-color, #0073aa) 0%, color-mix(in srgb, var(--ldt-bg-color, #0073aa) 80%, #000) 100%);
    border-radius: 50%;
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.25),
        0 2px 6px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    position: relative;
}

.ldt-translate-btn .ldt-icon::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.ldt-translate-btn .ldt-icon-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
    position: relative;
    z-index: 1;
}

.ldt-translate-btn .ldt-text {
    margin-top: 6px;
    padding: 4px 12px;
    background-color: var(--ldt-bg-color, #0073aa);
    color: var(--ldt-text-color, #ffffff);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-radius: 10px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

/* Hover effects */
.ldt-translate-btn:hover .ldt-icon {
    transform: scale(1.1);
    box-shadow:
        0 8px 25px rgba(0, 0, 0, 0.3),
        0 4px 12px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.ldt-translate-btn:hover .ldt-text {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.ldt-translate-btn:active .ldt-icon {
    transform: scale(1.05);
}

.ldt-translate-btn:active .ldt-text {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Estado activo (traducción habilitada) */
.ldt-translate-btn.ldt-active .ldt-icon {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
}

.ldt-translate-btn.ldt-active .ldt-text {
    background-color: #28a745;
}

.ldt-translate-btn.ldt-active .ldt-icon::before {
    content: "✓";
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #28a745;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #fff;
    border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

/* Estado cargando */
.ldt-translate-btn.ldt-loading {
    pointer-events: none;
}

.ldt-translate-btn.ldt-loading .ldt-icon {
    animation: ldt-pulse-ring 1.5s ease-in-out infinite;
}

.ldt-translate-btn.ldt-loading .ldt-icon-img {
    animation: ldt-pulse-img 1.5s ease-in-out infinite;
}

@keyframes ldt-pulse-ring {
    0%, 100% {
        box-shadow:
            0 4px 15px rgba(0, 0, 0, 0.25),
            0 0 0 0 rgba(0, 115, 170, 0.4);
    }
    50% {
        box-shadow:
            0 4px 15px rgba(0, 0, 0, 0.25),
            0 0 0 10px rgba(0, 115, 170, 0);
    }
}

@keyframes ldt-pulse-img {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(0.9); }
}

/* =========================================
   Panel desplegable
   ========================================= */
.ldt-dropdown {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    overflow: hidden;
}

.ldt-position-header .ldt-dropdown,
.ldt-position-content-top .ldt-dropdown {
    bottom: auto;
    top: calc(100% + 10px);
}

.ldt-dropdown.ldt-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Header del dropdown */
.ldt-dropdown-header {
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.ldt-dropdown-header h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

/* Toggle de activación */
.ldt-toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ldt-toggle-label {
    font-size: 13px;
    color: #666;
}

.ldt-toggle {
    position: relative;
    width: 50px;
    height: 26px;
}

.ldt-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ldt-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.ldt-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.ldt-toggle input:checked + .ldt-toggle-slider {
    background-color: #28a745;
}

.ldt-toggle input:checked + .ldt-toggle-slider:before {
    transform: translateX(24px);
}

/* Lista de idiomas */
.ldt-language-list {
    max-height: 250px;
    overflow-y: auto;
    padding: 10px 0;
}

.ldt-language-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
    color: #333;
}

/*
.ldt-language-item:hover {
    background-color: #f0f0f0;
}

*/

.ldt-language-item.ldt-selected {
    background-color: #e7f3ff;
    color: #0073aa;
    font-weight: 500;
}

.ldt-language-item .ldt-check {
    margin-left: auto;
    color: #28a745;
    opacity: 0;
}

.ldt-language-item.ldt-selected .ldt-check {
    opacity: 1;
}

/* =========================================
   Indicador de estado
   ========================================= */
.ldt-status-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    background: #333;
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999999;
}

.ldt-status-indicator.ldt-show {
    opacity: 1;
    visibility: visible;
}

.ldt-status-indicator.ldt-success {
    background: #28a745;
}

.ldt-status-indicator.ldt-error {
    background: #dc3545;
}

/* =========================================
   Contenedor de Google Translate (oculto visualmente pero funcional)
   ========================================= */
.ldt-google-translate-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0.01;
    pointer-events: none;
    z-index: -1;
}

/* El selector de Google Translate dentro de nuestro contenedor debe ser accesible */
.ldt-google-translate-container .goog-te-combo {
    pointer-events: auto;
}

/* =========================================
   Ocultar barra y elementos UI de Google Translate
   ========================================= */
.goog-te-banner-frame,
#goog-gt-tt,
.goog-te-balloon-frame,
div#goog-gt-,
.goog-te-ftab-link {
    display: none !important;
}

/* Ocultar el gadget de Google Translate pero NO el select interno */
.skiptranslate {
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    left: -9999px !important;
    visibility: hidden !important;
}

/* Pero mantener el select funcional (sin visibility hidden) */
.skiptranslate .goog-te-combo {
    visibility: visible !important;
    position: relative !important;
}

body {
    top: 0 !important;
}

.goog-text-highlight {
    background-color: transparent !important;
    box-shadow: none !important;
}

/* Ocultar el iframe de la barra superior de Google */
iframe.goog-te-banner-frame {
    display: none !important;
}

/* Evitar el salto de contenido causado por Google Translate */
.translated-ltr, .translated-rtl {
    margin-top: 0 !important;
}

/* Remover estilos de highlight de traducción */
font[style*="vertical-align: inherit"] {
    vertical-align: baseline !important;
}

/* =========================================
   Responsive
   ========================================= */
@media (max-width: 768px) {
    .ldt-translator-container.ldt-position-floating {
        bottom: 15px;
        right: 15px;
    }

    .ldt-translate-btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .ldt-dropdown {
        min-width: 200px;
        right: -10px;
    }
}

@media (max-width: 480px) {
    .ldt-translate-btn .ldt-icon {
        width: 50px;
        height: 50px;
    }

    .ldt-translate-btn .ldt-icon-img {
        width: 30px;
        height: 30px;
    }

    .ldt-translate-btn .ldt-text {
        font-size: 9px;
        padding: 3px 10px;
    }

    .ldt-translate-btn.ldt-active .ldt-icon::before {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }
}

/* =========================================
   Compatibilidad con BuddyBoss Theme
   ========================================= */
.buddyboss-theme .ldt-translator-container {
    font-family: inherit;
}

.buddyboss-theme .ldt-translate-btn {
    font-family: inherit;
}

.buddyboss-theme .ldt-dropdown {
    font-family: inherit;
}

/* Ajuste para el panel lateral de BuddyBoss */
.bb-lessons-list ~ .ldt-translator-container.ldt-position-floating {
    bottom: 80px;
}
