/* F24: Document Translation Panel */

/* ---- Slide-in panel ---- */
.mybutler-translate-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    max-width: 100vw;
    height: 100vh;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}
.mybutler-translate-panel.open {
    right: 0;
}

/* ---- Header ---- */
.mybutler-translate-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}
.mybutler-translate-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}
.mybutler-translate-close {
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: #475569;
    padding: 4px 12px;
}
.mybutler-translate-close:hover {
    background: #cbd5e1;
    color: #1e293b;
}

/* ---- Body (scrollable) ---- */
.mybutler-translate-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* ---- Language selector ---- */
.mybutler-translate-lang-label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
}
.mybutler-translate-lang-search {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 4px;
    box-sizing: border-box;
}
.mybutler-translate-lang-search:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}
.mybutler-translate-lang-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-bottom: 16px;
}
.mybutler-translate-lang-item {
    padding: 7px 12px;
    font-size: 13px;
    cursor: pointer;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 6px;
}
.mybutler-translate-lang-item:last-child {
    border-bottom: none;
}
.mybutler-translate-lang-item:hover {
    background: #eff6ff;
}
.mybutler-translate-lang-item.selected {
    background: #dbeafe;
    font-weight: 600;
    color: #1e40af;
}
.mybutler-translate-lang-item .lang-star {
    color: #f59e0b;
    font-size: 10px;
}
.mybutler-translate-lang-divider {
    padding: 4px 12px;
    font-size: 11px;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
}

/* ---- Page range ---- */
.mybutler-translate-range {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.mybutler-translate-range label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
}
.mybutler-translate-range input {
    width: 60px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
}
.mybutler-translate-range input:focus {
    outline: none;
    border-color: #3b82f6;
}
.mybutler-translate-range-dash {
    color: #94a3b8;
}

/* ---- Translate button ---- */
.mybutler-translate-start {
    width: 100%;
    padding: 10px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 16px;
    transition: background 0.15s;
}
.mybutler-translate-start:hover:not(:disabled) {
    background: #2563eb;
}
.mybutler-translate-start:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

/* ---- Progress ---- */
.mybutler-translate-progress {
    margin-bottom: 16px;
    display: none;
}
.mybutler-translate-progress.visible {
    display: block;
}
.mybutler-translate-progress-label {
    font-size: 13px;
    color: #475569;
    margin-bottom: 6px;
}
.mybutler-translate-progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}
.mybutler-translate-progress-fill {
    height: 100%;
    background: #3b82f6;
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

/* ---- Result preview ---- */
.mybutler-translate-result {
    margin-bottom: 16px;
    display: none;
}
.mybutler-translate-result.visible {
    display: block;
}
.mybutler-translate-result-label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
}
.mybutler-translate-preview {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px;
    background: #fafafa;
    font-size: 13px;
    line-height: 1.6;
}

/* ---- Result actions ---- */
.mybutler-translate-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    display: none;
}
.mybutler-translate-actions.visible {
    display: flex;
}
.mybutler-translate-actions .mybutler-btn {
    flex: 1;
    min-width: 100px;
    font-size: 12px;
    padding: 8px 10px;
    text-align: center;
}

/* ---- Usage counter ---- */
.mybutler-translate-usage {
    font-size: 12px;
    color: #64748b;
    text-align: center;
    padding: 8px 0;
    border-top: 1px solid #f1f5f9;
    margin-top: 8px;
}

/* ---- History ---- */
.mybutler-translate-history {
    border-top: 1px solid #e2e8f0;
    padding-top: 12px;
    margin-top: 8px;
}
.mybutler-translate-history-label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
}
.mybutler-translate-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 12px;
    color: #475569;
    border-bottom: 1px solid #f1f5f9;
}
.mybutler-translate-history-item:last-child {
    border-bottom: none;
}
.mybutler-translate-history-item .history-lang {
    font-weight: 600;
    color: #1e293b;
}
.mybutler-translate-history-item .history-time {
    color: #94a3b8;
    font-size: 11px;
}
.mybutler-translate-history-item .history-view {
    font-size: 11px;
    color: #3b82f6;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
}
.mybutler-translate-history-item .history-view:hover {
    text-decoration: underline;
}

/* ---- Error state ---- */
.mybutler-translate-error {
    color: #dc2626;
    font-size: 13px;
    padding: 8px 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    margin-bottom: 12px;
    display: none;
}
.mybutler-translate-error.visible {
    display: block;
}

/* ---- Translation pills in job history ---- */
.mybutler-tag-translation {
    display: inline-block;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    border-radius: 3px;
    text-decoration: none;
    cursor: pointer;
    margin-left: 3px;
    transition: background 0.15s;
}
.mybutler-tag-translation:hover {
    background: #bfdbfe;
    color: #1e3a8a;
    text-decoration: none;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    .mybutler-translate-panel {
        width: 100vw;
        right: -100vw;
    }
    .mybutler-translate-actions .mybutler-btn {
        min-width: 80px;
    }
}
