/* 🌐 Translator Module — V4 + EN senior-friendly layout */

.trl-module {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 20px 40px;
    color: var(--radim-text);
    font-family: inherit;
}

.trl-header {
    margin-bottom: 20px;
    text-align: center;
}

.trl-header h2 {
    font-size: 1.7rem;
    margin: 0 0 6px;
    font-weight: 700;
    color: var(--radim-text);
}

.trl-subtitle {
    color: var(--radim-text-subtle);
    font-size: 1rem;
    margin: 0 0 12px;
}

/* ── Mode tabs ─────────────────────────────────────────────────── */
.trl-modes {
    display: inline-flex;
    gap: 4px;
    background: #eef2f5;
    padding: 4px;
    border-radius: var(--radim-radius-md);
    margin-top: 4px;
}

.trl-mode-tab {
    padding: 8px 18px;
    border: none;
    background: transparent;
    color: var(--radim-text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radim-radius-sm);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.trl-mode-tab:hover {
    color: var(--radim-text);
}

.trl-mode-active {
    background: var(--radim-surface);
    color: var(--radim-text);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ── Glossary chips ────────────────────────────────────────────── */
.trl-glossary {
    margin-bottom: 18px;
    background: var(--radim-surface-sunken);
    border: 1px solid var(--radim-border);
    border-radius: var(--radim-radius-lg);
    padding: 0 14px;
}

.trl-glossary summary {
    cursor: pointer;
    padding: 12px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--radim-text);
    display: flex;
    align-items: center;
    gap: 10px;
    list-style: none;
}

.trl-glossary summary::-webkit-details-marker { display: none; }

.trl-glossary summary::before {
    content: '▸';
    display: inline-block;
    font-size: 0.9rem;
    color: var(--radim-text-faded);
    transition: transform 0.15s;
}

.trl-glossary[open] summary::before {
    transform: rotate(90deg);
}

.trl-chip-count {
    margin-left: auto;
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--radim-text-faded);
}

.trl-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0 14px;
}

.trl-chip {
    padding: 7px 14px;
    border: 1.5px solid var(--radim-border);
    background: var(--radim-surface);
    color: var(--radim-text);
    border-radius: var(--radim-radius-2xl);
    font-size: 0.88rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}

.trl-chip:hover {
    border-color: var(--radim-primary);
    background: var(--radim-surface-hover);
}

/* ── Rozhovor (talk) mode ─────────────────────────────────────── */
.trl-talk-module {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 180px);
}

.trl-talk-log {
    flex: 1;
    min-height: 260px;
    max-height: 460px;
    overflow-y: auto;
    padding: 14px;
    background: var(--radim-surface-sunken);
    border: 1px solid var(--radim-border);
    border-radius: var(--radim-radius-lg);
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.trl-talk-empty {
    margin: auto;
    color: var(--radim-text-faded);
    font-style: italic;
    text-align: center;
    max-width: 360px;
    line-height: 1.5;
}

.trl-talk-msg {
    padding: 12px 14px;
    border-radius: var(--radim-radius-lg);
    max-width: 85%;
    line-height: 1.45;
    border: 1.5px solid var(--radim-border);
    background: var(--radim-surface);
}

.trl-talk-a {
    align-self: flex-start;
    border-left: 4px solid var(--radim-primary);
}

.trl-talk-b {
    align-self: flex-end;
    border-right: 4px solid #9F7AEA;
    background: #faf6ff;
}

.trl-talk-msg-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--radim-text-subtle);
    margin-bottom: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.trl-talk-msg-flag {
    font-size: 0.95rem;
}

.trl-talk-msg-src {
    color: var(--radim-text-muted);
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.trl-talk-msg-tr {
    color: var(--radim-text);
    font-size: 1.05rem;
    font-weight: 600;
}

.trl-talk-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}

.trl-talk-panel {
    background: var(--radim-surface);
    border: 1.5px solid var(--radim-border);
    border-radius: var(--radim-radius-lg);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.trl-talk-panel-a { border-top: 3px solid var(--radim-primary); }
.trl-talk-panel-b { border-top: 3px solid #9F7AEA; }

.trl-talk-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.trl-talk-who {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--radim-text-subtle);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.trl-talk-lang {
    flex: 1;
    max-width: 180px;
    padding: 8px 10px;
    font-size: 0.9rem;
    border: 1.5px solid var(--radim-border);
    border-radius: var(--radim-radius-sm);
    background: var(--radim-surface);
    font-family: inherit;
    cursor: pointer;
}

.trl-talk-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 12px;
    background: var(--radim-primary);
    color: var(--radim-surface);
    border: none;
    border-radius: var(--radim-radius-lg);
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.12s, transform 0.05s, box-shadow 0.12s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.trl-talk-btn-b {
    background: #9F7AEA;
}

.trl-talk-btn:active,
.trl-talk-btn-recording {
    transform: scale(0.97);
    box-shadow: 0 0 0 4px var(--radim-primary-ring),
                0 0 20px var(--radim-primary-ring);
}

.trl-talk-btn-b:active,
.trl-talk-btn-b.trl-talk-btn-recording {
    box-shadow: 0 0 0 4px rgba(159, 122, 234, 0.25),
                0 0 20px rgba(159, 122, 234, 0.35);
}

.trl-talk-btn-recording {
    animation: trl-pulse 0.9s ease-in-out infinite;
}

@keyframes trl-pulse {
    0%, 100% { filter: brightness(1); }
    50%      { filter: brightness(1.18); }
}

.trl-talk-icon {
    font-size: 2rem;
    line-height: 1;
}

.trl-talk-btn-label {
    font-size: 0.95rem;
    text-align: center;
}

.trl-talk-actions {
    display: flex;
    justify-content: center;
    padding: 4px 0 12px;
}

.trl-btn-ghost {
    padding: 10px 20px;
    background: transparent;
    color: var(--radim-text-subtle);
    border: 1.5px solid var(--radim-border);
    border-radius: var(--radim-radius-md);
    font-family: inherit;
    font-size: 0.92rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.trl-btn-ghost:hover {
    border-color: var(--radim-primary);
    color: var(--radim-primary);
}

/* ── Foto (OCR) mode ──────────────────────────────────────────── */
.trl-photo-module {
    display: flex;
    flex-direction: column;
}

.trl-photo-target {
    margin-bottom: 18px;
}

.trl-photo-target label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--radim-text-subtle);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.trl-photo-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 18px;
}

.trl-photo-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 12px;
    background: var(--radim-surface);
    color: var(--radim-text);
    border: 2px dashed var(--radim-border-strong);
    border-radius: var(--radim-radius-xl);
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.trl-photo-btn:hover {
    border-color: var(--radim-primary);
    background: var(--radim-surface-hover);
    color: var(--radim-text);
}

.trl-photo-btn:active { transform: scale(0.98); }

.trl-photo-btn-camera {
    border-color: var(--radim-primary);
    background: var(--radim-surface-hover);
}

.trl-photo-btn-icon {
    font-size: 2.2rem;
    line-height: 1;
}

.trl-photo-result {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.trl-photo-preview-wrap {
    position: relative;
    max-height: 320px;
    overflow: hidden;
    border-radius: var(--radim-radius-lg);
    background: var(--radim-surface-sunken);
    border: 1px solid var(--radim-border);
}

.trl-photo-preview {
    display: block;
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    background: #000;
}

.trl-photo-retake {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--radim-surface);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
}

.trl-photo-retake:hover {
    background: rgba(0, 0, 0, 0.8);
}

.trl-photo-panes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.trl-photo-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 18px;
    background: var(--radim-surface-hover);
    border: 1.5px solid var(--radim-teal-light);
    border-radius: var(--radim-radius-md);
    color: var(--radim-text);
    font-size: 0.95rem;
    margin-top: 14px;
}

.trl-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--radim-primary-ring);
    border-top-color: var(--radim-primary);
    border-radius: 50%;
    animation: trl-spin 0.8s linear infinite;
}

@keyframes trl-spin {
    to { transform: rotate(360deg); }
}

/* ── Frázník (offline phrasebook) ─────────────────────────────── */
.trl-book-module {
    display: flex;
    flex-direction: column;
}

.trl-book-toolbar {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
}

.trl-book-lang label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--radim-text-subtle);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.trl-book-search input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 1.5px solid var(--radim-border);
    border-radius: var(--radim-radius-md);
    background: var(--radim-surface);
    color: var(--radim-text);
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.trl-book-search input:focus { border-color: var(--radim-primary); }

.trl-book-content {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.trl-book-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: var(--radim-text-subtle);
}

.trl-book-error,
.trl-book-empty {
    text-align: center;
    padding: 28px;
    color: var(--radim-text-subtle);
    font-style: italic;
}

.trl-book-cat {
    background: var(--radim-surface-sunken);
    border: 1px solid var(--radim-border);
    border-radius: var(--radim-radius-xl);
    padding: 16px;
}

.trl-book-cat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--radim-text);
}

.trl-book-cat-icon {
    font-size: 1.45rem;
    line-height: 1;
}

.trl-book-cat-count {
    margin-left: auto;
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--radim-text-faded);
    background: var(--radim-surface);
    padding: 3px 10px;
    border-radius: var(--radim-radius-md);
    border: 1px solid var(--radim-border);
}

.trl-book-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trl-book-phrase {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 4px 12px;
    padding: 14px 16px;
    background: var(--radim-surface);
    border: 1.5px solid var(--radim-border);
    border-radius: var(--radim-radius-md);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    align-items: center;
}

.trl-book-phrase:hover {
    border-color: var(--radim-primary);
    background: var(--radim-surface-hover);
}

.trl-book-phrase-cs {
    grid-column: 1;
    grid-row: 1;
    font-size: 0.88rem;
    color: var(--radim-text-subtle);
}

.trl-book-phrase-tr {
    grid-column: 1;
    grid-row: 2;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--radim-text);
    line-height: 1.4;
}

.trl-book-phrase-actions {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: flex;
    gap: 2px;
    align-self: center;
}

@media (max-width: 640px) {
    .trl-book-toolbar {
        grid-template-columns: 1fr;
    }
    .trl-book-phrase {
        grid-template-columns: 1fr;
    }
    .trl-book-phrase-actions {
        grid-column: 1;
        grid-row: 3;
        justify-content: flex-end;
        padding-top: 4px;
    }
}

/* ── Language bar ──────────────────────────────────────────────── */
.trl-lang-bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
    gap: 12px;
    margin-bottom: 18px;
}

.trl-lang-col label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--radim-text-subtle);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.trl-lang-select {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border: 1.5px solid var(--radim-border);
    border-radius: var(--radim-radius-md);
    background: var(--radim-surface);
    color: var(--radim-text);
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color 0.18s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%23718096' stroke-width='1.5'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.trl-lang-select:focus {
    border-color: var(--radim-primary);
}

.trl-swap-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1.5px solid var(--radim-border);
    background: var(--radim-surface);
    color: var(--radim-primary);
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.25s, border-color 0.18s, box-shadow 0.18s;
    align-self: center;
    margin-bottom: 4px;
}

.trl-swap-btn:hover {
    border-color: var(--radim-primary);
    transform: rotate(180deg);
    box-shadow: 0 3px 10px var(--radim-primary-ring);
}

/* ── I/O panes ─────────────────────────────────────────────────── */
.trl-io {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 18px;
}

.trl-pane {
    background: var(--radim-surface);
    border: 1.5px solid var(--radim-border);
    border-radius: var(--radim-radius-xl);
    padding: 14px;
    display: flex;
    flex-direction: column;
    min-height: 240px;
}

.trl-pane-target {
    background: var(--radim-surface-hover);
    border-color: var(--radim-teal-light);
}

.trl-pane-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.trl-pane-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--radim-text-muted);
}

.trl-pane-actions {
    display: flex;
    gap: 4px;
}

.trl-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid transparent;
    color: var(--radim-text-subtle);
    font-size: 1.05rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.trl-icon:hover {
    background: var(--radim-primary-tint);
    color: var(--radim-text);
}

.trl-icon:active {
    transform: scale(0.94);
}

.trl-textarea {
    flex: 1;
    min-height: 180px;
    resize: vertical;
    border: none;
    outline: none;
    background: transparent;
    font-size: 1.15rem;
    line-height: 1.5;
    color: var(--radim-text);
    font-family: inherit;
    padding: 0;
}

.trl-textarea::placeholder {
    color: var(--radim-text-faded);
}

.trl-charcount {
    align-self: flex-end;
    font-size: 0.8rem;
    color: var(--radim-text-faded);
    margin-top: 6px;
}

.trl-output {
    flex: 1;
    min-height: 180px;
    font-size: 1.15rem;
    line-height: 1.5;
    color: var(--radim-text-faded);
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 0;
}

.trl-output.trl-has-text {
    color: var(--radim-text);
    font-weight: 500;
}

.trl-provider {
    font-size: 0.75rem;
    color: var(--radim-text-faded);
    margin-top: 8px;
    text-align: right;
    font-style: italic;
}

/* ── Actions ───────────────────────────────────────────────────── */
.trl-actions {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.trl-btn-primary {
    padding: 14px 32px;
    font-size: 1.05rem;
    font-weight: 600;
    background: var(--radim-primary);
    color: var(--radim-surface);
    border: none;
    border-radius: var(--radim-radius-lg);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.18s, box-shadow 0.18s;
}

.trl-btn-primary:hover:not(:disabled) {
    background: var(--radim-primary-hover);
    box-shadow: 0 4px 14px var(--radim-primary-ring);
}

.trl-btn-primary:disabled {
    opacity: 0.6;
    cursor: default;
}

/* ── History ───────────────────────────────────────────────────── */
.trl-history {
    margin-top: 12px;
}

.trl-history h3 {
    font-size: 1rem;
    color: var(--radim-text);
    margin: 0 0 12px;
    font-weight: 700;
}

.trl-history-item {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: var(--radim-surface);
    border: 1.5px solid var(--radim-border);
    border-radius: var(--radim-radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    text-align: left;
    font-family: inherit;
    align-items: center;
}

.trl-history-item:hover {
    border-color: var(--radim-primary);
    background: var(--radim-surface-hover);
}

.trl-history-langs {
    font-size: 1rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.trl-history-src,
.trl-history-tr {
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trl-history-src {
    color: var(--radim-text-muted);
}

.trl-history-tr {
    color: var(--radim-text);
    font-weight: 500;
}

/* ── Toast ─────────────────────────────────────────────────────── */
.trl-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 22px;
    background: var(--radim-text);
    color: var(--radim-surface);
    border-radius: 24px;
    font-size: 0.95rem;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
    animation: trl-toast-in 0.25s ease-out;
}

.trl-toast-out {
    opacity: 0;
    transition: opacity 0.5s;
}

@keyframes trl-toast-in {
    from { transform: translate(-50%, 20px); opacity: 0; }
    to   { transform: translate(-50%, 0);    opacity: 1; }
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 720px) {
    .trl-io {
        grid-template-columns: 1fr;
    }
    .trl-lang-bar {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .trl-swap-btn {
        transform: rotate(90deg);
        margin: 4px auto;
    }
    .trl-swap-btn:hover {
        transform: rotate(270deg);
    }
    .trl-pane {
        min-height: 160px;
    }
    .trl-textarea,
    .trl-output {
        min-height: 140px;
    }
    .trl-history-item {
        grid-template-columns: auto 1fr;
    }
    .trl-history-tr {
        grid-column: 1 / -1;
        padding-top: 4px;
    }
    .trl-talk-panels {
        grid-template-columns: 1fr;
    }
    .trl-talk-log {
        max-height: 300px;
    }
    .trl-modes {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    .trl-photo-picker {
        grid-template-columns: 1fr;
    }
    .trl-photo-panes {
        grid-template-columns: 1fr;
    }
}
