.flag-circle {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    vertical-align: middle;
}
/* Cost display (giống STT) */
.dub-cost-display {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    justify-content: flex-end;
}
.dub-cost-label {
    font-size: 11px;
    color: var(--text-secondary);
}
.dub-cost-amount {
    font-size: 16px;
    font-weight: 700;
    color: #fbbf24;
}

/* Option rows (speaker + toggle) */
.option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 60;
}
.option-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}
.option-divider {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin: 4px 0;
}
/* Dropup: menu mở lên trên */
.custom-dropdown.dropup .dropdown-menu {
    top: auto;
    bottom: calc(100% + 6px);
    margin-top: 0;
}
/* Credits counter kế bên button */
.dub-credits-counter {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-secondary);
    flex: 1;
}

/* 1. Thiết lập vùng chứa để định vị */
.custom-tooltip {
    position: relative; /* Quan trọng để tooltip con bay theo nó */
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 2. Cái bảng Popup (Mặc định ẩn) */
.tooltip-popup {
    visibility: hidden;
    opacity: 0;
    
    /* Vị trí: Bay lên trên */
    position: absolute;
    bottom: 130%; /* Cách nút một đoạn lên trên */
    left: 50%;
    transform: translateX(-50%); /* Căn giữa */
    
    /* Giao diện cái bảng */
    width: 280px;
    background-color: #222; /* Nền tối */
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.5;
    text-align: left;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    border: 1px solid #444;
    z-index: 1000;
    
    /* Hiệu ứng mượt */
    transition: all 0.3s ease;
}

/* Mũi tên nhỏ trỏ xuống */
.tooltip-popup::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: #222 transparent transparent transparent;
}

/* 3. Khi rê chuột vào vùng chứa thì hiện bảng */
.custom-tooltip:hover .tooltip-popup {
    visibility: visible;
    opacity: 1;
    bottom: 110%; /* Bay nhẹ xuống một chút cho mượt */
}


/* Container của Dropdown */
.custom-dropdown {
    position: relative;
    width: 100%;
}

/* Nút bấm (Trigger) */
.dropdown-trigger {
    width: 100%;
    padding: 12px 16px;
    background: #1a1a1a; /* Màu nền tối */
    border: 1px solid #333;
    border-radius: 12px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    user-select: none;
}

.dropdown-trigger:hover {
    border-color: #555;
    background: #222;
}

/* Menu xổ xuống */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    margin-top: 6px;
    max-height: 300px;
    overflow-y: auto;
    
    /* 🔥 Z-index cao để đè lên các phần tử khác bên dưới */
    z-index: 99999 !important; 
    
    display: none;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}



.dropdown-menu.show {
    display: block;
}

/* Từng dòng Item */
.dropdown-item {
    padding: 10px 16px;
    font-size: 14px;
    color: #ddd;
    cursor: pointer;
    transition: 0.15s;
    border-bottom: 1px solid #222;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: #2a2a2a;
    color: #fff;
    padding-left: 20px; /* Hiệu ứng đẩy chữ sang phải */
}

.dropdown-item.selected {
    background: rgba(102, 126, 234, 0.1); /* Màu xanh nhạt */
    color: #667eea; /* Màu chữ xanh */
    font-weight: 600;
}

/* Tùy chỉnh thanh cuộn (Scrollbar) */
.dropdown-menu::-webkit-scrollbar {
    width: 6px;
}
.dropdown-menu::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 0 12px 12px 0;
}
.dropdown-menu::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}
.dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #666;
}
    /* --- DARK THEME VARIABLES --- */
    :root {
        --bg-main: #0b0b0b;
        --bg-card: #1c1c1c;
        --border-color: #333;
        --text-primary: #fff;
        --text-secondary: #aaa;
        --accent-pink: #ff0066;
        --accent-blue: #667eea;
        --success: #22c55e;
        --warning: #f59e0b;
        --error: #ef4444;
    }

    body { 
        background-color: var(--bg-main); 
        color: var(--text-primary); 
        font-family: "Inter", sans-serif; 
    }

    .dub-container { 
        display: grid; 
        grid-template-columns: 1fr 1fr; 
        gap: 24px; 
        min-height: 85vh; 
        padding: 24px; 
    }

    /* ========== LEFT PANEL ========== */
/* ========== SETTINGS PANEL (Viền Gradient Xoay) ========== */
.settings-panel {
    /* 1. Layout nội dung */
    height: fit-content;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 24px;
    
    /* 2. Cấu hình khung */
    position: relative;
    background: transparent; /* 🔥 QUAN TRỌNG: Để trong suốt để thấy gradient bên dưới */
    border-radius: 16px; 
    border: none; /* Bỏ viền cũ */
    
    /* 3. Đảm bảo hiển thị */
    z-index: 0; /* Tạo tầng xếp lớp */
    overflow: hidden; /* Bo tròn góc gradient */
    box-shadow: 0 10px 40px rgba(0,0,0,0.5); /* Đổ bóng cho đẹp */
    
}

/* LỚP 1: Gradient 7 màu (Nằm dưới cùng - Full kích thước) */
.settings-panel::before {
    content: '';
    position: absolute;
    inset: -150%; /* Phủ rộng ra ngoài để khi xoay không bị hở góc */
    background: conic-gradient(
        from 0deg,
        #1a1a2e 0deg,
        oklch(54.6% .245 262.881) 45deg,
        oklch(62.3% .214 259.815) 90deg,
        oklch(70.7% .165 254.624) 135deg,
        oklch(29.1% .149 302.717) 180deg,
        oklch(48.8% .243 264.376) 225deg,
        oklch(54.6% .245 262.881) 270deg,
        oklch(42.4% .199 265.638) 315deg,
        #1a1a2e 360deg
    );
    animation: spin 8s linear infinite, colorChange 16s ease-in-out infinite;
    z-index: -2;
}

/* LỚP 2: Nền đen (Nằm đè lên Gradient, nhưng thụt vào 1.5px) */
.settings-panel::after {
    content: '';
    position: absolute;
    /* 🔥 inset: 1.5px chính là độ dày của viền */
    inset: 1.5px; 
    
    background: #0f0f0f; /* 🔥 MÀU NỀN CỦA KHUNG (Chỉnh màu này nếu muốn đen hơn/xám hơn) */
    border-radius: 14.5px; /* 16px - 1.5px */
    z-index: -1;
}

/* Đảm bảo nội dung (chữ, nút) nổi lên trên cùng */
.settings-panel > * {
    position: relative;
    z-index: 2;
}


/* Animation Keyframes (Nếu file CSS chưa có thì thêm vào cuối file) */
@keyframes spin { 
    100% { transform: rotate(360deg); } 
}

@keyframes colorChange {
    0% { filter: hue-rotate(0deg) saturate(1); }
    50% { filter: hue-rotate(80deg) saturate(1.2); }
    100% { filter: hue-rotate(0deg) saturate(1); }
}

    .panel-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 10px;
    }

    .panel-title {
        font-size: 18px;
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .credits-badge {
        background: linear-gradient(135deg, var(--accent-blue), #212121);
        color: white;
        padding: 6px 14px;
        border-radius: 20px;
        font-size: 12px;
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 6px;
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    }

    .alert-box {
        background: rgba(255, 0, 102, 0.1); 
        border: 1px solid var(--accent-pink);
        color: var(--accent-pink); 
        padding: 16px; 
        border-radius: 12px; 
        font-size: 13px; 
        line-height: 1.6;
        display: flex; 
        gap: 12px; 
        align-items: flex-start;
    }
    .alert-box i { 
        font-size: 18px; 
        margin-top: 2px; 
        flex-shrink: 0;
    }
    .alert-box ul {
        margin: 8px 0 0 0;
        padding-left: 20px;
    }
    .alert-box li {
        margin: 4px 0;
    }

    /* Language Selector */
    .lang-row { 
        display: flex; 
        gap: 16px; 
        align-items: flex-end; 
        position: relative;
    z-index: 50; /* Số lớn để đè lên các thằng bên dưới */
    align-items: flex-start !important;
    }
    .lang-group { 
        flex: 1; 
    }
    .lang-label { 
        display: block; 
        font-size: 13px; 
        font-weight: 600; 
        color: var(--text-primary); 
        margin-bottom: 8px; 
    }
    .lang-label .required {
        color: var(--accent-pink);
    }
    
    .form-select { 
        width: 100%; 
        padding: 12px 16px; 
        background: var(--bg-main); 
        border: 1px solid var(--border-color); 
        color: var(--text-primary); 
        border-radius: 12px; 
        outline: none; 
        appearance: none; 
        cursor: pointer; 
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23aaaaaa' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e"); 
        background-repeat: no-repeat; 
        background-position: right 12px center; 
        background-size: 16px 12px;
        font-size: 14px;
        transition: 0.2s;
    }
    .form-select:hover {
        border-color: #555;
    }
    .form-select:focus {
        border-color: var(--accent-blue);
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    }
    .form-select:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        background-color: rgba(255,255,255,0.03);
    }
    
    .lang-arrow { 
        display: flex; 
        align-items: center; 
        color: var(--text-secondary); 
        font-size: 24px; 
        padding-bottom: 0 !important;
    margin-top: 32px; /* Đẩy xuống cho ngang tầm với dropdown */
    }

    /* Upload Zone */
    .upload-zone-wrap { 
        position: relative; 
    }
    .upload-label { 
        font-size: 13px; 
        font-weight: 600; 
        color: var(--text-primary); 
        margin-bottom: 8px; 
        display: block; 
    }
    .upload-zone {
        border: 2px dashed var(--border-color); 
        border-radius: 16px; 
        padding: 50px 20px;
        text-align: center; 
        background: var(--bg-main); 
        transition: 0.3s; 
        cursor: pointer;
        display: flex; 
        flex-direction: column; 
        align-items: center; 
        justify-content: center; 
        min-height: 250px;
        position: relative;
    }
    /* --- 1. Tạo Animation di chuyển --- */
@keyframes borderFlow {
    0% {
        background-position: 0 0, 0% 50%;
    }
    100% {
        background-position: 0 0, 100% 50%;
    }
}

/* --- 2. Áp dụng vào nút Upload khi Hover --- */
.upload-zone:hover {
    border: 1px solid transparent;

    /* Lớp 1: Nền đen giữ nguyên | Lớp 2: Gradient lặp lại màu đầu tiên ở cuối để loop mượt */
    background-image: 
        linear-gradient(var(--bg-main), var(--bg-main)), 
        linear-gradient(60deg, #667eea, #764ba2, #ff0066, #fbbf24, #667eea); 

    background-origin: border-box;
    background-clip: padding-box, border-box;

    /* Kéo dài background ra gấp 3 lần để có chỗ cho nó chạy */
    background-size: 100% 100%, 300% 300%;

    /* Chạy animation trong 3 giây, lặp vô tận, tốc độ đều */
    animation: borderFlow 12s linear infinite;

    /* Hiệu ứng phụ */
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.25);
    transform: translateY(-2px);
}
    .upload-zone.drag-over {
        border-color: var(--accent-blue);
        background: rgba(102, 126, 234, 0.1);
        transform: scale(1.02);
    }
    .upload-zone.has-file {
    border-color: var(--border-color); /* Giữ nguyên màu viền cũ */
    background: rgba(255, 255, 255, 0.03); /* Màu nền tối nhẹ thay vì xanh */
}
    .upload-icon { 
        font-size: 48px; 
        color: var(--text-secondary); 
        margin-bottom: 16px;
        transition: 0.3s;
    }
    .upload-zone:hover .upload-icon {
        color: var(--accent-blue);
        transform: translateY(-5px);
    }
    
    .upload-title { 
        font-weight: 600; 
        margin-bottom: 8px; 
        font-size: 16px;
        color: var(--text-primary);
    }
    .upload-desc { 
        font-size: 12px; 
        color: var(--text-secondary); 
        line-height: 1.6; 
    }
    /* --- Giao diện Preview Audio giống ảnh --- */
.file-preview-card {
    background: transparent; /* Hoặc màu nền nhẹ nếu muốn */
    padding-top: 10px;
    animation: fadeIn 0.3s ease;
}

.file-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

/* Icon Loa tròn tròn bên trái */
.file-icon-box {
    width: 42px;
    height: 42px;
    background: #2a2a2a; /* Màu nền xám của icon */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-icon-box i {
    font-size: 20px;
    color: #bbb; /* Màu icon xám nhạt */
}

/* Thông tin tên file và dung lượng */
.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 12px;
    color: #777; /* Màu xám tối cho dung lượng */
    margin-top: 2px;
}

/* Nút xóa thùng rác */
.btn-trash {
    background: transparent;
    border: none;
    color: #777;
    font-size: 16px;
    cursor: pointer;
    padding: 8px;
    transition: 0.2s;
}

.btn-trash:hover {
    color: #ef4444; /* Màu đỏ khi hover */
}

/* Thanh Audio Player */
.custom-audio-player {
    width: 100%;
    height: 40px;
    border-radius: 8px;
    outline: none;
    /* Custom màu thanh player cho hợp dark mode */
    filter: invert(0.9) hue-rotate(180deg); 
    /* Mẹo nhỏ: Đảo màu player mặc định để nó thành màu tối, 
       nếu không thích mày xóa dòng filter đi là về mặc định */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}
    .file-info {
    display: none;
    position: absolute;
    /* Đổi vị trí từ giữa (top 50%) xuống dưới đáy */
    top: auto;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    
    /* Style lại cho gọn */
    width: 90%; /* Chiều rộng bằng 90% khung cha */
    min-width: auto;
    background: #252525; /* Nền xám đậm nổi bật hơn nền upload */
    padding: 12px 16px;
    border-radius: 12px;
    
    /* Bỏ viền xanh, dùng viền xám mỏng */
    border: 1px solid var(--border-color); 
    z-index: 10;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); /* Đổ bóng sâu hơn để nổi lên */
}
    .file-info.show {
    display: flex;
    flex-direction: row; /* Xếp ngang cho gọn */
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}
    
    .file-name-display {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px; /* Giới hạn chiều dài tên file */
}
    .file-name-display i {
        color: var(--success);
        font-size: 20px;
    }
    
    .file-meta {
    padding-top: 0;
    border-top: none;
    margin-left: auto; /* Đẩy sang phải */
    display: none; /* Ẩn bớt meta thừa nếu muốn gọn, hoặc để flex nếu muốn hiện */
}
    
    .btn-remove-file {
    background: rgba(255,255,255,0.1);
    border: none;
    padding: 6px 10px;
    color: #fff;
}
 .btn-remove-file:hover {
    background: var(--error);
    color: white;
}

    /* Options Row */
    .options-row { 
        display: flex; 
        justify-content: space-between; 
        align-items: flex-end; 
        gap: 20px; 
        /* 🔥 THÊM 2 DÒNG NÀY */
    position: relative; 
    z-index: 100; /* Số lớn để đè lên nút bấm bên dưới */
    }
    .speaker-group { 
        flex: 1; 
    }
    .bottom-actions {
    display: flex;
    justify-content: space-between; /* Đẩy 2 thằng ra 2 mép */
    align-items: flex-end; /* Căn đáy cho thẳng hàng ngang */
    gap: 20px;
    margin-top: 24px; /* Cách phần trên ra */
}
    .toggle-group { 
        display: flex; 
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
        flex: 1; /* Cho nó chiếm phần không gian còn lại nếu cần */
    justify-content: flex-end;
    }
    
    .toggle-control {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    .toggle-label { 
        font-size: 13px; 
        font-weight: 600; 
        color: var(--text-primary);
        cursor: pointer;
        user-select: none;
    }
    .toggle-hint {
    display: block;       /* Bắt buộc hiện ra */
    font-size: 11px;      /* Chữ nhỏ */
    color: #888;          /* Màu xám nhạt (text-secondary) */
    margin-top: 6px;      /* Cách nút gạt ra một chút */
    line-height: 1.4;     /* Giãn dòng cho dễ đọc nếu chữ dài */
    font-style: italic;   /* In nghiêng nhẹ (tùy chọn) */
}
    
    .toggle-switch { 
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    }
    .toggle-switch input { 
        opacity: 0; 
        width: 0; 
        height: 0; 
    }
    .toggle-slider { 
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333; /* Màu tắt */
    transition: .3s;
    border-radius: 34px;
    }
    .toggle-slider:before { 
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    }
    input:checked + .toggle-slider { 
    background-color: #fff; /* Màu bật (Trắng) */
    }
    input:checked + .toggle-slider:before { 
    transform: translateX(18px);
    background-color: #000; /* Chấm tròn chuyển đen */
    }

    /* Submit Button */
    /* --- NÚT SUBMIT (STYLE ĐƠN GIẢN) --- */
.btn-dub {
    /* 1. Layout & Vị trí */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    
    width: auto;       /* Quan trọng: Để nút co gọn lại theo chữ */
    flex-shrink: 0;    /* Chống bị bóp méo */
    
    height: 42px;      /* Cao bằng với cái toggle bên cạnh */
    margin-top: 0;     /* Bỏ margin đi (vì thằng bao ngoài bottom-actions đã lo rồi) */
    
    /* 2. Style giao diện */
    padding: 0 24px;   /* Độ rộng 2 bên nút */
    background: #444;  /* Màu nền */
    color: #e0e0e0;    /* Màu chữ */
    border: none;
    border-radius: 8px;
    
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: none;
}

/* Hiệu ứng khi di chuột */
.btn-dub:hover:not(:disabled) {
    background: #555;
    color: #fff;
}

/* Khi nút bị tắt (đang xử lý) */
.btn-dub:disabled {
    background: #333;
    color: #777;
    cursor: not-allowed;
}

/* Icon bên trong nút */
.btn-dub i {
    font-size: 16px;
}

    /* ========== RIGHT PANEL ========== */
.history-panel {
    background: var(--bg-card); 
    border: 1px solid var(--border-color);
    border-radius: 16px; 
    padding: 0;
    display: flex; 
    flex-direction: column;
    max-height: 85vh;
    overflow: hidden;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.history-title {
    display: none;
}

.history-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: flex-start;
    align-items: center;
}
.btn-check-all {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 13px;
    font-weight: 500;
}

.btn-check-all:hover {
    border-color: #888;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

/* Khi active - NỀN TRẮNG CHỮ ĐEN */
.btn-check-all.active {
    background: #fff; /* Nền trắng */
    border-color: #fff; /* Viền trắng */
    color: #000; /* Chữ đen */
}

.btn-check-all.active:hover {
    background: #f0f0f0; /* Hover thì xám nhạt */
}

.btn-check-all i {
    font-size: 16px;
}

/* Icon của button check all khi active cũng đen */
.btn-check-all.active i {
    color: #000;
}
/* Bulk Actions (Hiện khi có item được chọn) */

.bulk-actions {
    display: none;
    gap: 8px;
    align-items: center;
}

.bulk-actions.show {
    display: flex;
}

.bulk-actions .separator {
    width: 1px;
    height: 20px;
    background: var(--border-color);
}

.btn-bulk {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 12px;
    font-weight: 500;
}

.btn-bulk:hover {
    border-color: #fff; /* Viền trắng khi hover */
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.btn-bulk.delete:hover {
    border-color: var(--error);
    color: var(--error);
    background: rgba(239, 68, 68, 0.05);
}

.btn-bulk i {
    font-size: 14px;
}
    .btn-icon {
    display: none;
}
    .btn-icon:hover {
        border-color: var(--accent-blue);
        color: var(--accent-blue);
        background: rgba(102, 126, 234, 0.1);
    }
    .btn-icon.refreshing {
        animation: spin 0.6s linear;
    }
    @keyframes spin {
        to { transform: rotate(360deg); }
    }
    
    /* Bỏ Filter Tabs */
.filter-tabs {
    display: none;
}

.filter-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    position: relative;
}

.filter-tab:hover {
    color: var(--text-primary);
}

.filter-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}
    
    /* History List */
    .history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}


/* Scrollbar */
.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}
.history-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 13px;
    flex-direction: column;
    gap: 12px;
    padding: 60px 20px;
}

.history-empty i {
    font-size: 48px;
    opacity: 0.3;
}
    
/* History Item - Minimal Design */
.history-item {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: 0.15s;
    gap: 16px;
}
.history-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.history-item:last-child {
    border-bottom: none;
}
.item-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid #555; /* Viền xám đậm thay vì border-color */
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    transition: 0.2s;
    position: relative;
    background: transparent;
}

.item-checkbox:hover {
    border-color: #888; /* Hover sáng hơn chút */
}

/* Khi checked - NỀN TRẮNG */
.item-checkbox.checked {
    background: #fff; /* Nền trắng */
    border-color: #fff; /* Viền trắng */
}

/* Dấu tick ĐEN */
.item-checkbox.checked::after {
    content: '\F26E'; /* Bootstrap icon check */
    font-family: 'bootstrap-icons';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #000; /* Màu đen */
    font-size: 12px;
    font-weight: bold;
}
    
   .item-info {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.item-title {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


.item-title i {
    display: none; /* Bỏ icon file */
}
    

.item-meta {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.item-meta i {
    display: none; /* Bỏ icon trong meta */
}
    .meta-separator {
        color: var(--border-color);
    }
    
    .item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all 0.3s ease; /* Thêm transition để chuyển trạng thái mượt hơn */
}

/* 1. Trạng thái Xong (Tĩnh hoặc sáng nhẹ) */
.status-indicator.done {
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    /* Nếu muốn xanh lá cũng nhấp nháy nhẹ thì thêm animation vào đây */
    
    animation: breathing 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* 2. Trạng thái Đang xử lý (Hiệu ứng Hít thở - Breathing) */
.status-indicator.pending,
.status-indicator.doing {
    background: #f59e0b;
    /* Dùng animation mới tên là 'breathing' */
    animation: breathing 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* 3. Trạng thái Lỗi (Tĩnh) */
.status-indicator.failed,
.status-indicator.error {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    
    animation: breathing 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* --- KEYFRAMES MƯỢT HƠN --- */
@keyframes breathing {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); /* Bóng đậm sát viền */
    }
    50% {
        transform: scale(1.1); /* Phóng to nhẹ */
        box-shadow: 0 0 10px 4px rgba(245, 158, 11, 0); /* Bóng lan ra xa và mờ dần */
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

    /* Status Badges */
.status-badge {
    display: none;
}

.status-pending, .status-doing {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.status-done {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.status-failed, .status-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border: 1px solid var(--error);
}
    
.action-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}
/* Ẩn các nút download/SRT đơn lẻ ở mỗi item */
.action-buttons .btn-download {
    display: inline-flex;
}

/* Chỉ giữ lại nút Play */
.action-buttons .btn-play {
    display: inline-flex;
}
.btn-play {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    /* Viền xám nhẹ mặc định */
    border: 1px solid var(--border-color); 
    background: transparent;
    /* Icon màu xám */
    color: var(--text-secondary); 
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 12px;
}

/* Khi rê chuột: Sáng lên màu trắng */
.btn-play:hover {
    border-color: #fff; /* Viền trắng */
    color: #fff;        /* Icon trắng */
    background: rgba(255, 255, 255, 0.1); /* Nền trắng mờ 10% */
    transform: scale(1.1); /* Phóng to nhẹ cho mượt */
}

/* Khi đang phát: Nền trắng - Icon đen (Đảo ngược) */
.btn-play.playing {
    background: #fff;   /* Nền trắng tinh */
    border-color: #fff;
    color: #000;        /* Icon màu đen tuyền */
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3); /* Phát sáng nhẹ màu trắng */
}

/* Căn chỉnh icon tam giác cho cân giữa */
.btn-play i {
    margin-left: 2px;
}

/* Khi icon chuyển thành Pause (||) hoặc Stop, cần bỏ margin để nó cân */
.btn-play.playing i {
    margin-left: 0;
}
.btn-download {
    color: var(--text-secondary);
    font-size: 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    transition: 0.2s;
}

.btn-download:hover {
    color: var(--accent-blue);
    background: rgba(102, 126, 234, 0.1);
}

.btn-metadata {
    display: none;
}

.btn-metadata:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: rgba(102, 126, 234, 0.05);
}
.btn-delete {
    display: none;
}

.btn-delete:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}
.item-credits {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 80px;
    text-align: right;
}

.credits-amount {
    font-weight: 600;
    color: var(--text-primary);
}

.credits-status {
    font-size: 10px;
    color: var(--text-secondary);
}
    
.processing-indicator {
    color: var(--text-secondary);
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 8px;
}

    /* Toast Notification */
    .toast {
        position: fixed;
        bottom: -100px;
        left: 50%;
        transform: translateX(-50%);
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        padding: 16px 24px;
        border-radius: 12px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.4);
        z-index: 9999;
        transition: bottom 0.3s ease;
        display: flex;
        align-items: center;
        gap: 12px;
        min-width: 300px;
        max-width: 500px;
    }
    .toast.show {
        bottom: 30px;
    }
    .toast.success {
        border-color: var(--success);
    }
    .toast.error {
        border-color: var(--error);
    }
    .toast.warning {
        border-color: var(--warning);
    }
    .toast i {
        font-size: 20px;
        flex-shrink: 0;
    }
    .toast.success i {
        color: var(--success);
    }
    .toast.error i {
        color: var(--error);
    }
    .toast.warning i {
        color: var(--warning);
    }
    .toast-text {
        color: var(--text-primary);
        font-size: 14px;
        font-weight: 500;
        flex: 1;
    }

    /* Responsive */
    @media (max-width: 1024px) {
        .dub-container {
            grid-template-columns: 1fr;
        }
        .history-panel {
            max-height: 60vh;
        }
    }

    @media (max-width: 768px) {
        .lang-row {
            flex-direction: column;
        }
        .lang-arrow {
            transform: rotate(90deg);
            padding: 0;
        }
        .options-row {
            flex-direction: column;
            align-items: stretch;
        }
        .toggle-group {
            align-items: stretch;
        }
        .filter-tabs {
            overflow-x: auto;
            flex-wrap: nowrap;
        }
    }

