/**
 * Cultouring Translate — Floating translation panel
 *
 * Teal/amber palette, mobile-first, accessible.
 * Ported from mod_traductor_sclc with ct- prefix.
 *
 * @package  mod_cultouring_translate
 * @since    1.0.0
 */

/* --- CSS Custom Properties --- */
:root {
    --ct-teal-700: #0f766e;
    --ct-teal-600: #0d9488;
    --ct-teal-500: #14b8a6;
    --ct-teal-400: #2dd4bf;
    --ct-teal-100: #ccfbf1;
    --ct-amber-600: #d97706;
    --ct-amber-500: #f59e0b;
    --ct-slate-900: #0f172a;
    --ct-slate-800: #1e293b;
    --ct-slate-700: #334155;
    --ct-slate-600: #475569;
    --ct-slate-400: #94a3b8;
    --ct-slate-200: #e2e8f0;
    --ct-slate-100: #f1f5f9;
    --ct-slate-50: #f8fafc;
    --ct-white: #ffffff;
    --ct-radius: 16px;
    --ct-radius-sm: 12px;
    --ct-radius-xs: 8px;
    --ct-shadow: 0 20px 60px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.05);
    --ct-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --ct-font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===================================================================
   FLOATING ACTION BUTTON (FAB)
   =================================================================== */
.ct-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ct-teal-600), var(--ct-teal-700));
    color: var(--ct-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(13, 148, 136, 0.4), 0 0 0 4px rgba(13, 148, 136, 0.15);
    transition: var(--ct-transition);
    animation: ct-pulse 3s ease-in-out infinite;
}

.ct-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(13, 148, 136, 0.5), 0 0 0 6px rgba(13, 148, 136, 0.2);
}

.ct-fab:active {
    transform: scale(0.95);
}

.ct-fab.ct-fab-hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

@keyframes ct-pulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(13, 148, 136, 0.4), 0 0 0 4px rgba(13, 148, 136, 0.15); }
    50%      { box-shadow: 0 8px 32px rgba(13, 148, 136, 0.4), 0 0 0 12px rgba(13, 148, 136, 0.05); }
}

/* ===================================================================
   TRANSLATION PANEL
   =================================================================== */
.ct-panel {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    z-index: 10000;
    width: 380px;
    max-height: calc(100vh - 8rem);
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--ct-radius);
    box-shadow: var(--ct-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--ct-font);
    color: var(--ct-white);
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: var(--ct-transition);
}

.ct-panel.ct-panel-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.ct-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ct-header-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ct-teal-400);
}

.ct-close {
    background: none;
    border: none;
    color: var(--ct-slate-400);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    transition: var(--ct-transition);
}

.ct-close:hover {
    color: var(--ct-white);
    background: rgba(255, 255, 255, 0.1);
}

/* Tabs */
.ct-tabs {
    display: flex;
    padding: 0 1.25rem;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ct-tab {
    padding: 0.7rem 1rem;
    background: none;
    border: none;
    color: var(--ct-slate-400);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--ct-transition);
    font-family: var(--ct-font);
}

.ct-tab:hover { color: var(--ct-white); }
.ct-tab-active {
    color: var(--ct-teal-400);
    border-bottom-color: var(--ct-teal-400);
}

/* Content */
.ct-content {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

/* Language row */
.ct-lang-row {
    margin-bottom: 1rem;
}

.ct-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ct-slate-400);
    margin-bottom: 0.5rem;
}

.ct-select {
    width: 100%;
    padding: 0.6rem 1rem;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--ct-radius-xs);
    color: #f1f5f9;
    font-size: 0.9rem;
    font-family: var(--ct-font);
    cursor: pointer;
    color-scheme: dark;
}

.ct-select:focus {
    outline: none;
    border-color: var(--ct-teal-500);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.ct-select option {
    background: #1e293b;
    color: #f1f5f9;
}

/* Language pills */
.ct-lang-pills {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.ct-pill {
    padding: 0.35rem 0.75rem;
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--ct-slate-400);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--ct-transition);
    font-family: var(--ct-font);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.ct-pill:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--ct-white);
}

.ct-pill-active {
    background: var(--pill-color, var(--ct-teal-600));
    color: var(--ct-white);
    border-color: var(--pill-color, var(--ct-teal-500));
}

.ct-pill-flag { font-size: 1rem; }

/* Input */
.ct-input-wrap {
    position: relative;
    margin-bottom: 1rem;
}

.ct-textarea {
    width: 100%;
    padding: 0.9rem 1rem;
    padding-right: 3rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--ct-radius-xs);
    color: var(--ct-white);
    font-size: 0.95rem;
    font-family: var(--ct-font);
    resize: none;
    line-height: 1.5;
}

.ct-textarea:focus {
    outline: none;
    border-color: var(--ct-teal-500);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.ct-textarea::placeholder {
    color: var(--ct-slate-600);
}

.ct-mic {
    position: absolute;
    right: 0.5rem;
    bottom: 0.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: var(--ct-slate-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--ct-transition);
}

.ct-mic:hover {
    background: var(--ct-teal-600);
    color: var(--ct-white);
}

.ct-mic.ct-mic-recording {
    background: #ef4444;
    color: var(--ct-white);
    animation: ct-mic-pulse 1s ease-in-out infinite;
}

@keyframes ct-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50%      { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* Submit button */
.ct-submit {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--ct-teal-600), var(--ct-teal-700));
    color: var(--ct-white);
    border: none;
    border-radius: var(--ct-radius-xs);
    font-size: 0.9rem;
    font-weight: 700;
    font-family: var(--ct-font);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--ct-transition);
    margin-bottom: 1rem;
}

.ct-submit:hover {
    background: linear-gradient(135deg, var(--ct-teal-500), var(--ct-teal-600));
    transform: translateY(-1px);
}

/* Result */
.ct-result {
    background: rgba(20, 184, 166, 0.08);
    border: 1px solid rgba(20, 184, 166, 0.15);
    border-radius: var(--ct-radius-xs);
    padding: 1rem;
}

.ct-result-lang {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ct-teal-400);
    margin-bottom: 0.5rem;
}

.ct-result-text {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--ct-white);
    line-height: 1.3;
    margin-bottom: 0.4rem;
}

.ct-result-phonetic {
    font-size: 0.85rem;
    color: var(--ct-amber-500);
    font-style: italic;
    margin-bottom: 0.75rem;
}

.ct-result-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ct-action {
    padding: 0.4rem 0.8rem;
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--ct-slate-400);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: var(--ct-transition);
    font-family: var(--ct-font);
}

.ct-action:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--ct-white);
}

.ct-action-clone {
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--ct-amber-500);
}

.ct-action-clone:hover {
    background: rgba(245, 158, 11, 0.15);
    color: var(--ct-amber-500);
}

/* Loading */
.ct-loading {
    text-align: center;
    padding: 1.5rem;
    color: var(--ct-slate-400);
    font-size: 0.85rem;
}

.ct-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--ct-teal-400);
    border-radius: 50%;
    animation: ct-spin 0.8s linear infinite;
    margin: 0 auto 0.75rem;
}

@keyframes ct-spin {
    to { transform: rotate(360deg); }
}

/* Phrasebook */
.ct-phrase-cat {
    margin-bottom: 1.25rem;
}

.ct-phrase-cat-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ct-teal-400);
    margin-bottom: 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ct-phrase {
    display: flex;
    flex-direction: column;
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.75rem;
    background: none;
    border: none;
    border-radius: var(--ct-radius-xs);
    color: var(--ct-white);
    cursor: pointer;
    transition: var(--ct-transition);
    font-family: var(--ct-font);
    gap: 0.15rem;
}

.ct-phrase:hover {
    background: rgba(255, 255, 255, 0.06);
}

.ct-phrase-es {
    font-size: 0.88rem;
    font-weight: 600;
}

.ct-phrase-maya {
    font-size: 0.82rem;
    color: var(--ct-teal-400);
}

.ct-phrase-phonetic {
    font-size: 0.72rem;
    color: var(--ct-amber-500);
    font-style: italic;
}

/* Offline */
.ct-offline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background: rgba(239, 68, 68, 0.1);
    border-top: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    font-size: 0.78rem;
    font-weight: 600;
}

/* Footer */
.ct-footer {
    padding: 0.6rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.68rem;
    color: var(--ct-slate-600);
    text-align: center;
}

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 480px) {
    .ct-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 85vh;
        border-radius: var(--ct-radius) var(--ct-radius) 0 0;
    }

    .ct-fab {
        bottom: 1.25rem;
        right: 1.25rem;
        width: 54px;
        height: 54px;
    }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    .ct-fab { animation: none; }
    .ct-mic.ct-mic-recording { animation: none; }
    .ct-spinner { animation-duration: 1.5s; }
    .ct-panel, .ct-fab, .ct-pill, .ct-action { transition: none !important; }
}

/* ============================================================
   CONVERSATION MODE
   ============================================================ */

/* Auto-detection indicator */
.ct-conv-auto-detect {
    text-align: center;
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(20, 184, 166, 0.08);
    border: 1px solid rgba(20, 184, 166, 0.15);
}

.ct-conv-auto-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ct-teal-400);
    margin-bottom: 8px;
}

.ct-conv-detected-langs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 28px;
}

.ct-conv-lang-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 13px;
    font-weight: 500;
}

.ct-conv-lang-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.ct-conv-lang-dot-a { background: var(--ct-teal-400); }
.ct-conv-lang-dot-b { background: #fbbf24; }

.ct-conv-auto-hint {
    font-size: 11px;
    color: var(--ct-slate-400);
    margin: 8px 0 0;
    line-height: 1.3;
}

/* Conversation log */
.ct-conv-log {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 12px;
    min-height: 180px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 12px;
    scroll-behavior: smooth;
}

.ct-conv-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    color: var(--ct-slate-400);
    text-align: center;
}

.ct-conv-empty p {
    margin: 8px 0 0;
    font-size: 13px;
}

/* Chat bubbles */
.ct-conv-bubble {
    margin-bottom: 10px;
    animation: ct-convFadeIn 0.3s ease;
}

.ct-conv-bubble-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ct-slate-400);
    margin-bottom: 3px;
}

.ct-conv-bubble-original {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px 12px 12px 4px;
    padding: 8px 12px;
    font-size: 14px;
    color: var(--ct-slate-200);
    margin-bottom: 4px;
}

.ct-conv-bubble-translation {
    background: var(--ct-teal-700);
    border-radius: 4px 12px 12px 12px;
    padding: 8px 12px;
    font-size: 14px;
    color: white;
    font-weight: 500;
}

.ct-conv-bubble-phonetic {
    font-size: 11px;
    color: var(--ct-teal-400);
    margin-top: 2px;
    font-style: italic;
}

.ct-conv-bubble.ct-conv-them .ct-conv-bubble-original {
    border-radius: 12px 12px 4px 12px;
}

.ct-conv-bubble.ct-conv-them .ct-conv-bubble-translation {
    border-radius: 12px 4px 12px 12px;
    background: var(--ct-amber-600);
}

/* Speaker indicator */
.ct-conv-speaker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px;
    color: var(--ct-teal-400);
    font-size: 13px;
}

.ct-conv-speaker-waves {
    display: flex;
    gap: 3px;
    align-items: center;
    height: 20px;
}

.ct-conv-speaker-waves span {
    width: 3px;
    background: var(--ct-teal-400);
    border-radius: 2px;
    animation: ct-convWave 1s ease-in-out infinite;
}

.ct-conv-speaker-waves span:nth-child(1) { height: 6px; animation-delay: 0s; }
.ct-conv-speaker-waves span:nth-child(2) { height: 12px; animation-delay: 0.1s; }
.ct-conv-speaker-waves span:nth-child(3) { height: 18px; animation-delay: 0.2s; }
.ct-conv-speaker-waves span:nth-child(4) { height: 12px; animation-delay: 0.3s; }
.ct-conv-speaker-waves span:nth-child(5) { height: 6px; animation-delay: 0.4s; }

/* Controls */
.ct-conv-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

.ct-conv-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ct-conv-btn:active { transform: scale(0.96); }

.ct-conv-btn-start {
    background: var(--ct-teal-600);
    color: white;
    width: 100%;
}

.ct-conv-btn-start:hover { background: var(--ct-teal-500); }

.ct-conv-btn-stop {
    background: #dc2626;
    color: white;
    width: 100%;
    animation: ct-convPulse 2s ease-in-out infinite;
}

/* Tips */
.ct-conv-tips {
    text-align: center;
    font-size: 11px;
    color: var(--ct-slate-400);
    padding: 4px 0;
}

.ct-conv-tips p { margin: 0; }

/* Animations */
@keyframes ct-convFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes ct-convWave {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(2); }
}

@keyframes ct-convPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}
