/**
 * Çeviri Versiyonu Sekmeleri
 * Birden fazla motor ile çevrilmiş bölümleri sekmeli göstermek için.
 * WTR Lab tarzı: üstte sekme bandı, her sekme motor rengini taşır.
 */

/* ---- Kapsayıcı ---- */
.chapter-translation-tabs {
    margin: 0;
}

/* ---- Sekme Bandı ---- */
.translation-tab-header {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    border-bottom: 2px solid var(--color-border, #e5e7eb);
    margin-bottom: 0;
    padding: 0;
    list-style: none;
    background: var(--color-surface, #f8f9fa);
}

/* ---- Sekme Butonu ---- */
.translation-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    border: none;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--color-muted, #6b7280);
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    white-space: nowrap;
    border-radius: 4px 4px 0 0;
    position: relative;
    bottom: -2px;
}

.translation-tab-btn:hover {
    color: var(--color-foreground, #111827);
    background: var(--color-hover, rgba(0,0,0,.04));
}

.translation-tab-btn.active {
    color: var(--color-foreground, #111827);
    border-bottom-color: var(--tab-engine-color, #4285f4);
    background: var(--color-background, #fff);
    font-weight: 600;
}

/* ---- Renk Noktası ---- */
.tab-engine-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ---- Panel ---- */
.translation-tab-panel {
    display: none;
}

.translation-tab-panel.active {
    display: block;
}

/* hidden attribute desteği */
.translation-tab-panel[hidden] {
    display: none !important;
}

/* ---- İçerik: klasik chapter-content-wrapper ile aynı stil ---- */
.translation-tab-panel .chapter-content-wrapper {
    /* Mevcut tema stillerini miras alır */
}

/* ---- Dark Mode ---- */
body.dark-mode .translation-tab-header,
.dark .translation-tab-header {
    background: var(--color-surface-dark, #1f2937);
    border-bottom-color: var(--color-border-dark, #374151);
}

body.dark-mode .translation-tab-btn,
.dark .translation-tab-btn {
    color: var(--color-muted-dark, #9ca3af);
}

body.dark-mode .translation-tab-btn.active,
.dark .translation-tab-btn.active {
    background: var(--color-background-dark, #111827);
    color: #fff;
}

/* ---- Kuyruk Butonu ---- */
.btn-add-to-translation-queue {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 6px;
    border: 1px solid var(--color-border, #e5e7eb);
    background: var(--color-surface, #f8f9fa);
    color: var(--color-foreground, #374151);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-add-to-translation-queue:hover:not(:disabled) {
    background: var(--color-hover, #f3f4f6);
    border-color: var(--color-primary, #4285f4);
    color: var(--color-primary, #4285f4);
}

.btn-add-to-translation-queue:disabled,
.btn-add-to-translation-queue.queue-success {
    opacity: 0.7;
    cursor: default;
}

/* ---- Slot sayacı rozeti ---- */
.queue-slot-badge {
    display: inline-block;
    background: rgba(0, 0, 0, 0.10);
    border-radius: 20px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    margin-left: 2px;
}

.btn-add-to-translation-queue.queue-full {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-add-to-translation-queue.queue-success {
    border-color: #10b981;
    color: #10b981;
}

/* ---- Kuyruk bilgi satırı (bölüm altı) ---- */
.chapter-retranslate-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    margin-top: 12px;
    background: var(--color-surface, #f8f9fa);
    border: 1px dashed var(--color-border, #e5e7eb);
    border-radius: 8px;
    font-size: 13px;
    color: var(--color-muted, #6b7280);
}

.chapter-retranslate-bar .retranslate-label {
    flex: 1;
}

/* =============================================================
   Toplu Çeviri Kuyruğu Modalı
   ============================================================= */

.bulk-translate-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.bulk-translate-overlay[hidden] {
    display: none;
}

body.bulk-translate-open {
    overflow: hidden;
}

.bulk-translate-modal {
    background: var(--color-card, #1e1e2e);
    color: var(--color-text, #e5e7eb);
    border: 1px solid var(--color-border, rgba(255,255,255,.1));
    border-radius: 12px;
    width: 100%;
    max-width: 680px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0,0,0,.5);
}

/* Header */
.bulk-translate-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--color-border, rgba(255,255,255,.1));
    flex-shrink: 0;
}

.bulk-translate-header h2 {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-text, #e5e7eb);
}

.bulk-translate-header h2 i {
    color: #1565c0;
}

.bulk-translate-subtitle {
    font-size: 13px;
    opacity: .7;
    margin: 0;
    line-height: 1.5;
}

.bulk-translate-close {
    background: none;
    border: none;
    color: var(--color-muted, #9ca3af);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    flex-shrink: 0;
    border-radius: 4px;
    transition: color .15s;
}

.bulk-translate-close:hover {
    color: var(--color-text, #e5e7eb);
}

/* Toolbar */
.bulk-translate-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 24px;
    border-bottom: 1px solid var(--color-border, rgba(255,255,255,.08));
    flex-shrink: 0;
    flex-wrap: wrap;
}

.bulk-translate-filters {
    display: flex;
    gap: 4px;
}

.bulk-filter-btn {
    background: none;
    border: 1px solid var(--color-border, rgba(255,255,255,.15));
    color: var(--color-muted, #9ca3af);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all .15s;
}

.bulk-filter-btn.active,
.bulk-filter-btn:hover {
    border-color: #1565c0;
    color: #64b5f6;
    background: rgba(21, 101, 192, .12);
}

.bulk-action-link {
    background: none;
    border: none;
    color: #64b5f6;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.bulk-action-link:hover {
    color: #90caf9;
}

/* Chapter list */
.bulk-translate-chapter-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.bulk-chapter-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.bulk-chapter-item {
    border-bottom: 1px solid var(--color-border, rgba(255,255,255,.06));
    transition: background .12s;
}

.bulk-chapter-item:hover {
    background: rgba(255,255,255,.03);
}

.bulk-chapter-item.in-queue {
    opacity: .55;
}

.bulk-chapter-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 24px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
}

.bulk-chapter-item.in-queue .bulk-chapter-label {
    cursor: default;
}

.bulk-chapter-label input[type="checkbox"] {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: #1565c0;
    cursor: pointer;
}

.bulk-chapter-label input[type="checkbox"]:disabled {
    cursor: not-allowed;
}

.bulk-chapter-num {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-muted, #9ca3af);
    min-width: 58px;
}

.bulk-chapter-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text, #e5e7eb);
}

.bulk-engine-badge {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    padding: 2px 7px;
    border-radius: 20px;
    letter-spacing: .3px;
    text-transform: uppercase;
}

.bulk-in-queue-badge {
    flex-shrink: 0;
    font-size: 10px;
    color: #fbbf24;
    display: flex;
    align-items: center;
    gap: 3px;
}

/* Canlı durum: işleniyor / başarısız */
.bulk-chapter-item.queue-processing {
    background: rgba(66, 133, 244, .07);
}

.bulk-badge-processing {
    color: #64b5f6;
}

.bulk-chapter-item.queue-failed {
    opacity: 1;
    background: rgba(244, 67, 54, .08);
}

.bulk-badge-failed {
    color: #f44336;
    cursor: help;
}

/* Toolbar: canlı güncelleme göstergesi + manuel yenile butonu */
.bulk-live-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--color-muted, #9ca3af);
}

.bulk-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #555;
    transition: background .2s;
    flex-shrink: 0;
}

.bulk-live-indicator.is-live .bulk-live-dot {
    background: #4caf50;
    animation: bulk-live-pulse 1.6s infinite;
}

@keyframes bulk-live-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(76, 175, 80, .55); }
    70%  { box-shadow: 0 0 0 6px rgba(76, 175, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

#bulk-refresh-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    line-height: 1;
}

#bulk-refresh-btn:hover {
    color: #90caf9;
}

/* Anlık bildirim (toast) — kalıcı başarı mesajından ayırt etmek için hafif giriş animasyonu */
.bulk-live-toast {
    animation: bulk-toast-in .2s ease;
}

@keyframes bulk-toast-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Loading / messages */
.bulk-translate-loading,
.bulk-translate-error,
.bulk-translate-empty {
    padding: 32px 24px;
    text-align: center;
    font-size: 13px;
    color: var(--color-muted, #9ca3af);
}

.bulk-translate-error { color: #f87171; }

.bulk-success-msg {
    margin: 8px 24px;
    padding: 10px 14px;
    background: rgba(16,185,129,.12);
    border: 1px solid rgba(16,185,129,.3);
    border-radius: 6px;
    font-size: 13px;
    color: #6ee7b7;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Footer */
.bulk-translate-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 24px;
    border-top: 1px solid var(--color-border, rgba(255,255,255,.1));
    flex-shrink: 0;
    flex-wrap: wrap;
}

.bulk-translate-summary {
    font-size: 13px;
    color: var(--color-muted, #9ca3af);
}

.bulk-translate-summary #bulk-selected-count {
    font-weight: 700;
    color: var(--color-text, #e5e7eb);
}

.bulk-slot-warning {
    color: #fbbf24;
}

.btn-primary-action {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    background: #1565c0;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s, background .15s;
}

.btn-primary-action:hover:not(:disabled) {
    background: #1976d2;
}

.btn-primary-action:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.btn-secondary-action {
    background: none;
    border: 1px solid var(--color-border, rgba(255,255,255,.2));
    color: var(--color-muted, #9ca3af);
    padding: 9px 16px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}

.btn-secondary-action:hover {
    border-color: rgba(255,255,255,.35);
    color: var(--color-text, #e5e7eb);
}

/* Toplu Çeviri butonu (Reader Settings içi) */
.btn-bulk-translate {
    transition: opacity .2s, background .15s;
}

.btn-bulk-translate:hover {
    background: #1976d2 !important;
}

/* =============================================================
   Qi Onay Paneli (modal footer üstünde gösterilir)
   ============================================================= */

.bulk-qi-confirm {
    margin: 0 0 2px;
    padding: 16px 24px;
    background: rgba(21, 101, 192, 0.08);
    border-top: 1px solid rgba(21, 101, 192, 0.2);
    border-bottom: 1px solid rgba(21, 101, 192, 0.2);
}

.bulk-qi-confirm h3 {
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--color-text, #e5e7eb);
}

.bulk-qi-summary {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}

.bulk-qi-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    padding: 3px 0;
    color: var(--color-muted, #9ca3af);
}

.bulk-qi-row strong {
    color: var(--color-text, #e5e7eb);
}

.bulk-qi-row--ok strong  { color: #4caf50; }
.bulk-qi-row--danger strong { color: #f44336; }

.bulk-queue-estimate {
    font-size: 12px;
    margin: 8px 0 0;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--color-muted, #9ca3af);
    line-height: 1.4;
}

.bulk-warn-msg {
    font-size: 12px;
    color: #fbbf24;
    margin: 0 0 10px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    line-height: 1.4;
}

.bulk-error-msg {
    margin: 0 0 2px;
    padding: 10px 24px;
    background: rgba(244, 67, 54, 0.08);
    border-top: 1px solid rgba(244, 67, 54, 0.25);
    font-size: 13px;
    color: #ef9a9a;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Mobil */
@media (max-width: 480px) {
    .bulk-translate-header,
    .bulk-translate-toolbar,
    .bulk-translate-footer,
    .bulk-qi-confirm,
    .bulk-error-msg { padding-left: 16px; padding-right: 16px; }
    .bulk-chapter-label { padding-left: 16px; padding-right: 16px; }
    .bulk-translate-modal { border-radius: 8px; }
}
