* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Prevent inadvertent zoom on some browsers */
    touch-action: pan-x pan-y;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    /* Standard way to disable zoom in some mobile browsers */
    -webkit-text-size-adjust: 100%;
}

/* Standard fix to prevent iOS zoom on focus */
input,
textarea,
select {
    font-size: 16px !important;
}

.container {
    max-width: 95%;
    width: 95%;
    margin: 0 auto;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Mọi thứ nằm chung một hàng: không wrap, và min-width:0 để các nhóm co
       lại thay vì đẩy nhau tràn ra ngoài màn hình. */
    flex-wrap: nowrap;
    gap: 15px;
}

.header-container > * {
    min-width: 0;
}

.header-actions {
    flex-shrink: 0;
}

.tab-selectors {
    overflow-x: auto;
    scrollbar-width: none;
}

/* Scheduling Counter Styles */
.scheduling-info {
    font-size: 15px;
    font-weight: 700;
    color: white;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 50px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.5s ease;
}

.scheduling-info .count-badge {
    background: #ff4757;
    color: white;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 14px;
    min-width: 28px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(255, 71, 87, 0.4);
}

.tab-selectors,
.header-actions {
    display: flex;
    gap: 10px;
    /* wrap làm nút cuối rớt xuống hàng riêng rồi stretch full-width;
       nhóm này chỉ vài nút nhỏ nên giữ chung một hàng. */
    flex-wrap: nowrap;
    align-items: center;
}

.profile-selector-wrapper {
    display: flex;
    align-items: center;
}

.profile-select {
    padding: 8px 32px 8px 12px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-weight: 700;
    cursor: pointer;
    font-size: 14px;
    outline: none;
    min-width: 140px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.profile-select:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.profile-select:focus {
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.profile-select option {
    background: #2c2c2e;
    color: white;
    font-weight: 500;
    padding: 10px;
}

.config-toggle-btn {
    margin: 0 !important;
    font-size: 14px !important;
    padding: 10px 18px !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    min-width: auto !important;
    height: auto !important;
    width: auto !important;
    font-weight: 600 !important;
    color: white !important;
    border: none !important;
}

.config-toggle-btn.chatgpt {
    background: linear-gradient(135deg, #10a37f 0%, #0d8c6f 100%) !important;
}

.config-toggle-btn.kling {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

#textPromptArrow {
    transition: transform 0.3s ease;
    display: inline-block;
}

.white-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 25px 30px;
    margin-bottom: 30px;
}

h1 {
    display: none;
}

.subtitle {
    display: none;
}

/* Tab Navigation Styles */
.main-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 2px;
}

.tab-btn {
    padding: 12px 25px;
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92); /* nằm trên nền gradient tím: xám chìm */
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    margin-bottom: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.12); /* tab chưa chọn vẫn có nền nhẹ */
}

/* icon SVG nét, cùng style nút header (.hdr-icon-btn) */
.tab-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

.tab-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.22);
}

.tab-btn.active {
    color: #667eea;
    background: #f0f4ff;
    border-radius: 8px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Voice Section Styles */
.voice-section {
    max-width: 700px;
    margin: 0 auto;
}

.voice-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.voice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(255, 107, 107, 0.3);
}

.voice-status {
    margin-top: 20px;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    font-size: 15px;
    display: none;
}

.voice-status.show {
    display: block;
}

.voice-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.voice-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.voice-status.loading {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.voice-player {
    margin-top: 30px;
    padding: 30px;
    background: #f9f9ff;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
    text-align: center;
}

.voice-player h3 {
    margin-bottom: 20px;
    color: #333;
}

.voice-player audio {
    width: 100%;
    max-width: 500px;
    margin-bottom: 20px;
}

.download-voice-btn {
    padding: 12px 30px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.download-voice-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

.create-prompt-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 10px;
}

.create-prompt-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.prompt-status {
    margin-top: 10px;
    padding: 14px;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    display: none;
}

.prompt-status.show {
    display: block;
}

.prompt-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.prompt-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.prompt-status.loading {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    color: #333;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 15px;
}

input[type="text"],
input[type="file"],
textarea {
    width: 100%;
    padding: 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    transition: border-color 0.3s;
}

/* Specific style for main prompt input */
#textPrompt {
    min-height: 120px;
}

input[type="text"]:focus,
input[type="file"]:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
}

textarea {
    resize: vertical;
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    left: -9999px;
}

.file-input-label {
    display: inline-block;
    padding: 14px 20px;
    /* Increased from 12px */
    background: #f5f5f5;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    text-align: center;
    color: #666;
    font-size: 15px;
    /* Increased from 14px */
}

.file-input-label:hover {
    border-color: #667eea;
    background: #f9f9ff;
}

button {
    width: 100%;
    padding: 16px;
    /* Increased from 14px */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 17px;
    /* Increased from 16px */
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.status {
    padding: 16px;
    border-radius: 8px;
    font-size: 15px;
    display: none;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.status.show {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status.loading {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.status-close-btn {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 22px;
    height: 22px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    padding: 0;
    margin: 0;
    transition: all 0.2s;
    z-index: 10;
    line-height: 1;
}

.status-close-btn:hover {
    background: #bd2130;
    transform: scale(1.1);
    opacity: 1;
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* Task table styles */
.tasks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}

.tasks-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    max-width: 400px;
}

.tasks-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-wrapper {
    position: relative;
    flex: 1;
}

#taskSearchInput {
    width: 100%;
    padding: 8px 12px 8px 32px;
    font-size: 13px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    outline: none;
    transition: all 0.2s;
    background: white;
}

#taskSearchInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 14px;
    pointer-events: none;
}

.refresh-btn {
    margin: 0;
    padding: 6px 10px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.refresh-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.filter-btn {
    background: #f1f3f5;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    justify-content: center;
    transition: all 0.2s;
    min-width: 47px;
    height: 42px;
}
.filter-btn .ic { margin-right: 0; }

.filter-btn:hover {
    background: #e9ecef;
    border-color: #ced4da;
}

.task-filter-select {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    background: white;
    color: #495057;
    min-width: 144px;
    height: 42px;
    outline: none;
    transition: all 0.2s;
}

.task-filter-select:focus {
    border-color: #667eea;
}

.tasks-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tasks-table th {
    background: #f5f5f5;
    padding: 14px;
    /* Increased from 12px */
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    /* Increased from 13px */
    color: #333;
    border-bottom: 2px solid #e0e0e0;
}

.tasks-table td {
    padding: 20px 14px;
    border-bottom: 2px solid #e0e0e0;
    vertical-align: top;
    font-size: 14px;
}

.tasks-table tr:nth-child(even) {
    background-color: #fbfbfb;
}

.tasks-table tr:hover {
    background-color: #f5f7ff;
    transition: background-color 0.2s ease;
}

.tasks-table tr:last-child td {
    border-bottom: none;
}

.task-images {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 8px;
    max-width: 350px;
}

/* Custom scrollbar for small image list */
.task-images::-webkit-scrollbar {
    height: 6px;
}

.task-images::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.task-images::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.task-images::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.task-image-thumb {
    width: 70px;
    height: 124px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid #e0e0e0;
    transition: transform 0.2s;
}

.task-prompt {
    max-width: 400px;
    /* Increased from 300px */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    /* Increased from 13px */
    color: #555;
}

.task-prompt-edit {
    width: 100%;
    max-width: 400px;
    padding: 6px 8px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    color: #333;
    resize: vertical;
    min-height: 40px;
    transition: border-color 0.3s;
}

.task-prompt-edit:focus {
    outline: none;
    border-color: #667eea;
    background: #f9f9ff;
}

.task-prompt-url {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

.task-prompt-url a {
    color: #667eea;
    text-decoration: none;
}

.task-prompt-url a:hover {
    text-decoration: underline;
}

.task-status {
    padding: 7px 14px;
    /* Increased from 6px 12px */
    border-radius: 12px;
    font-size: 13px;
    /* Increased from 12px */
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.task-status.pending {
    background: #fff3cd;
    color: #856404;
}

.task-status.processing {
    background: #d1ecf1;
    color: #0c5460;
}

.task-status.completed {
    background: #d4edda;
    color: #155724;
}

.task-status.failed {
    background: #f8d7da;
    color: #721c24;
}

.task-status-message {
    font-size: 12px;
    /* Increased from 11px */
    color: #666;
    margin-top: 3px;
}

.task-generated-image {
    width: 100px;
    height: 178px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid #28a745;
    cursor: pointer;
    transition: transform 0.2s;
}

.task-generated-image:hover,
.downloaded-thumb:hover,
.task-image-thumb:hover {
    transform: scale(1.1);
    z-index: 5;
}

#displayProductDesc::-webkit-scrollbar {
    width: 6px;
}

#displayProductDesc::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#displayProductDesc::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

#displayProductDesc::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.task-actions {
    display: flex;
    gap: 8px;
    flex-direction: column;
    /* Stack buttons vertically for better space */
}

.action-btn {
    padding: 8px 14px;
    /* Increased from 6px 12px */
    border: none;
    border-radius: 6px;
    font-size: 13px;
    /* Increased from 12px */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.edit-btn {
    background: #667eea;
    color: white;
}

.edit-btn:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

.kling-btn {
    background: #ff6b6b;
    color: white;
}

.kling-btn:hover {
    background: #ee5a5a;
    transform: translateY(-1px);
}

.retry-btn {
    background: #ffc107;
    color: #333;
}

.retry-btn:hover {
    background: #e0a800;
    transform: translateY(-1px);
}

.download-btn {
    background: #28a745;
    color: white;
}

.download-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

.delete-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

/* Cùng style nút xoá video (script.js deleteCustomVideo) */
.delete-btn-x {
    background: #ff4d4d;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
    margin: 0 auto;
}

.delete-btn-x:hover {
    background: #ff4d4d;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    transform: scale(1.1);
}

/* Image Preview Removal Button */
.remove-img-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4d4f;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
    z-index: 10;
    padding: 0;
    line-height: 1;
}

.remove-img-btn:hover {
    background: #ff7875;
    transform: scale(1.1);
}

.preview-item {
    transition: transform 0.2s;
}

.preview-item:hover {
    transform: translateY(-2px);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Result Buttons (Stacked next to image) */
.mini-btn {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

.mini-btn.down {
    background: #28a745;
    color: white;
}

.mini-btn.down:hover {
    background: #218838;
}

/* Nút task: icon + chữ, màu theo vai trò (chính / phụ / đã xong / đang chạy) */
/* Regen = nút phụ: viền, khác hẳn Create Video (nền tím đặc) */
.mini-btn.edit {
    background: #fff;
    color: #4b3f8f;
    box-shadow: inset 0 0 0 1.5px #667eea;
}

.mini-btn.edit:hover {
    background: #f4f2fb;
}

.mini-btn.showcase { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: #fff; }
.mini-btn.post { background: #111; color: #fff; }
.mini-btn.post:hover { background: #333; }
.mini-btn.done { background: #2e9e5b; color: #fff; }
.mini-btn.done:hover { background: #268a4e; }
.mini-btn.busy { background: #f39c12; color: #fff; cursor: not-allowed; }
.mini-btn.showcase:hover, .mini-btn.create-video:hover { filter: brightness(1.08); }

.mini-btn.kling {
    background: #ff6b6b;
    color: white;
}

.mini-btn.kling:hover {
    background: #ee5a5a;
}

.mini-btn.create-video {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.no-tasks {
    text-align: center;
    padding: 50px;
    /* Increased from 40px */
    color: #999;
    font-size: 15px;
    /* Increased from 14px */
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.kling-video-status {
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    max-width: 620px;
    /* Show up to 4 videos at once */
    overflow: hidden;
}

.video-grid {
    display: flex;
    flex-direction: row;
    gap: 12px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px 5px;
    width: 100%;
    scrollbar-width: thin;
    scrollbar-color: #667eea #f0f0f0;
}

.video-grid::-webkit-scrollbar {
    height: 6px;
}

.video-grid::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 10px;
}

.video-grid::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.video-item {
    flex-shrink: 0;
    /* Prevent items from shrinking */
    width: 100px;
}

.video-placeholder {
    width: 100px;
    height: 178px;
    background: #f0f0f0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
    font-weight: 500;
    border: 2px dashed #ddd;
    text-align: center;
    padding: 10px;
    flex-shrink: 0;
    /* Prevent placeholders from shrinking */
}

.disabled-link {
    opacity: 0.5;
    pointer-events: none;
    cursor: default;
    color: #999 !important;
}

.form-group.full-width {
    grid-column: span 2;
}

.config-grid label {
    font-size: 13px;
    margin-bottom: 5px;
}

.config-grid input,
.config-grid select,
.config-grid textarea {
    padding: 8px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 100%;
}

.checkbox-group {
    display: flex;
    gap: 20px;
    align-items: center;
    height: 100%;
    margin-top: 25px;
    /* Align with inputs */
}

.checkbox-group label {
    display: flex;
    align-items: center;
    font-weight: normal;
    cursor: pointer;
    margin-bottom: 0;
}

.checkbox-group input {
    margin-right: 8px;
    width: auto;
}

.config-actions {
    margin-top: 20px;
    text-align: right;
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
}

/* Cùng style nút chính (Download / Schedule Ready) */
.save-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    height: 42px;
    padding: 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

/* Table Prompt Column - Wider and Taller */
.task-prompt {
    width: 350px;
    min-width: 250px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 13px;
    line-height: 1.4;
    color: #444;
    max-height: 300px;
    overflow-y: auto;
}

.task-prompt-edit {
    width: 350px;
    min-height: 150px;
    font-size: 12px;
    padding: 5px;
    resize: vertical;
}

/* Kling Configuration Styles */
.config-section {
    margin: 12px 0;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.config-section.active {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.config-header {
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
    padding: 12px 20px;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
}

.config-header:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-bottom-color: rgba(102, 126, 234, 0.3);
}

.config-header:hover h2,
.config-header:hover .toggle-icon {
    color: white;
}

.config-header h2 {
    margin: 0;
    font-size: 20px;
    color: #333;
    font-weight: 700;
    transition: color 0.3s ease;
}

.toggle-icon {
    font-size: 16px;
    color: #667eea;
    transition: all 0.3s ease;
    font-weight: bold;
}

.config-section.active .toggle-icon {
    transform: rotate(180deg);
}

.config-body {
    padding: 16px;
    background: #fafbfc;
    border-top: 1px solid #e8ecf1;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

/* Responsive Layout Classes */
.main-flex-container {
    display: flex;
    gap: 40px;
}

.form-side {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.config-panel {
    flex: 1.3;
    padding-left: 20px;
    border-left: 1px solid #eee;
    display: none;
    flex-direction: column;
}

#uploadForm {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Spinner animation for video creation */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Responsive Layout Classes */
.main-flex-container {
    display: flex;
    gap: 40px;
}

.form-side {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.config-panel {
    flex: 1.3;
    padding-left: 20px;
    border-left: 1px solid #eee;
    display: none;
    flex-direction: column;
}

#uploadForm {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-id-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.product-id-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.input-with-button {
    position: relative;
    width: 100%;
    max-width: 400px;
    display: flex;
    align-items: center;
}

#productId {
    width: 100%;
    padding: 12px 16px !important;
    padding-right: 85px !important;
    font-size: 16px !important;
    border: 2px solid #e0e0e0 !important;
    border-radius: 8px !important;
    min-height: 44px !important;
}

.inner-paste-btn {
    position: absolute;
    right: 8px;
    width: auto !important;
    padding: 6px 12px !important;
    font-size: 13px !important;
    background: #f0f0f0 !important;
    color: #444 !important;
    border: 1px solid #ccc !important;
    border-radius: 6px !important;
    margin: 0 !important;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.inner-paste-btn svg { flex-shrink: 0; }

.inner-paste-btn:hover {
    background: #e0e0e0 !important;
    transform: none !important;
    box-shadow: none !important;
}

.submit-container {
    margin-top: 10px;
    display: flex;
    justify-content: flex-start;
}

#submitBtn {
    width: 300px !important;
    margin: 0;
    padding: 14px;
    font-size: 16px;
    font-weight: 700;
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    letter-spacing: 0.5px;
    border-radius: 30px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 20px;
    border-radius: 8px;
}

/* Media Queries for Mobile Responsiveness */
@media (max-width: 992px) {
    .main-flex-container {
        flex-direction: column;
        gap: 30px;
    }

    .config-panel {
        padding-left: 0;
        border-left: none;
        border-top: 1px solid #eee;
        padding-top: 20px;
    }

    #submitBtn {
        width: 100% !important;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .white-card {
        padding: 15px;
    }

    .header-container {
        flex-direction: column;
        align-items: stretch;
    }

    .container { max-width: 100%; width: 100%; }

    .tab-selectors,
    .header-actions {
        justify-content: center;
    }

    /* mobile: profile select giãn lấp hàng, nút icon giữ 40px */
    .profile-selector-wrapper { flex: 1; }
    .profile-select { width: 100%; min-width: 0; }

    .config-toggle-btn {
        flex: 1;
        text-align: center;
        width: 100% !important;
    }

    /* mobile: 4 tab chia đều tuyệt đối */
    .tab-selectors { display: grid; grid-template-columns: repeat(4, 1fr); }

    .tab-btn {
        padding: 10px 0;
        font-size: 14px;
    }

    /* mobile: tab chỉ hiện icon, label vẫn còn qua title/aria */
    .tab-btn span { display: none; }

    /* Multiple: bảng không co theo màn hình, để .table-responsive cuộn ngang */
    #multipleResultsContainer .tasks-table { min-width: 640px; }

    .product-id-input-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .input-with-button {
        width: 100%;
    }

    #productId {
        width: 100%;
    }

    #downloadProductBtn,
    #addToShowcaseBtn,
    .file-input-label,
    .file-input-wrapper {
        width: 100% !important;
        min-width: unset !important;
        box-sizing: border-box !important;
    }

    /* Tasks Header Mobile Styles */
    .tasks-header {
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
        padding-bottom: 5px;
        flex-wrap: nowrap !important;
    }

    .tasks-header-left {
        flex: 1 !important;
        width: auto !important;
    }

    .tasks-header-right {
        width: auto !important;
        flex-shrink: 0;
        gap: 6px !important;
    }

    #taskSearchInput {
        padding: 6px 8px 6px 28px !important;
        font-size: 11px !important;
    }

    .search-icon {
        left: 8px !important;
        font-size: 11px !important;
    }

    .task-filter-select {
        min-width: 80px !important;
        padding: 6px 8px !important;
        font-size: 11px !important;
    }

    .filter-btn {
        padding: 6px 8px !important;
        font-size: 11px !important;
        min-width: unset !important;
    }
}

.copyable-product-id:hover {
    color: #667eea !important;
    background-color: #f8f9ff;
}

.copyable-product-id {
    transition: all 0.2s ease;
    border-radius: 4px;
    padding: 2px 4px !important;
}

[id^="prompt-toggle-btn-"]:hover {
    background-color: #e9ecef !important;
    border-color: #ccc !important;
    color: #333 !important;
}

.task-prompt-edit {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    font-size: 13px;
    line-height: 1.4;
    transition: border-color 0.2s;
}

.task-prompt-edit:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

/* Check Stock Button - Mobile only */
.check-stock-btn {
    display: none !important;
}

/* Increased breakpoint to 896px to cover iPhone 14 Pro Max (430px) and similar devices */
@media (max-width: 896px) {
    .check-stock-btn {
        display: flex !important;
        background: #000 !important;
        color: white !important;
        margin-top: 4px;
        width: 100%;
        padding: 5px 2px;
        font-size: 11px;
        text-align: center;
        border: none;
        border-radius: 4px;
        cursor: pointer;
    }
}
/* ===== Settings: collapsible sections + engine switch ===== */
.cfg-toggle { cursor: pointer; }
.config-section.collapsed .config-body { display: none; }
.config-section .toggle-icon { font-size: 13px; color: #94a3b8; }

.engine-switch { display: inline-flex; background: #eef2f7; border-radius: 10px; padding: 4px; gap: 4px; }
.engine-switch .engine-btn {
    border: none; background: transparent; color: #475569; font-size: 13px; font-weight: 600;
    padding: 8px 16px; border-radius: 8px; cursor: pointer; width: auto; margin: 0; transition: all .15s ease;
}
.engine-switch .engine-btn:hover { color: #1e293b; }
.engine-switch .engine-btn.active {
    background: #fff; color: #6d28d9; box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.engine-block {
    border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; background: #fcfcfd;
}

/* Nút icon trên header (Engage / Serverless / Settings): cùng cỡ, cùng style */
.hdr-icon-btn {
    width: auto; /* chặn button{width:100%} toàn cục: mobile bị kéo to */
    height: 40px; min-width: 40px; padding: 0 10px; box-sizing: border-box;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: rgba(255, 255, 255, 0.9); color: #4b3f8f;
    border: none; border-radius: 8px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.hdr-icon-btn:hover { background: #fff; }
.hdr-icon-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
#engageBtn.running { background: #f5576c; color: #fff; }
/* Nút trong popup (engage play/stop, serverless Set/Refresh): nền nhạt hơn header vì popup trắng */
.engage-toggle, #slPopup .hdr-icon-btn { background: #f4f2fb; box-shadow: none; }
.engage-toggle:hover, #slPopup .hdr-icon-btn:hover { background: #ebe7fa; }
/* Play/stop: nền đặc màu + icon trắng đặc cho nổi (nét mảnh trên nền nhạt bị chìm) */
.engage-toggle { width: 40px; padding: 0; flex-shrink: 0; color: #fff; background: #2e9e5b; }
.engage-toggle:hover { background: #268a4e; }
.engage-toggle.running { background: #f5576c; }
.engage-toggle.running:hover { background: #e0445a; }
.engage-toggle svg { fill: currentColor; }

/* Icon SVG nét trong bảng Settings, thay emoji: cỡ theo chữ, căn giữa dòng */
.ic { width: 1.1em; height: 1.1em; vertical-align: -0.18em; margin-right: 6px; flex-shrink: 0; }
/* Mobile: neo theo nút (absolute) kiểu gì cũng tràn 1 mép tuỳ vị trí nút.
   Ghim fixed giữa màn, cách 2 mép 16px -> luôn thấy đủ. !important vì style inline trong index.ejs. */
@media (max-width: 768px) {
    #engagePopup {
        position: fixed !important; left: 16px !important; right: 16px !important;
        top: 50% !important; transform: translateY(-50%); width: auto !important;
    }
}

/* ponytail: dark dùng invert toàn phần; nền/accent đổi theo phép đảo màu.
   Muốn bảng màu dark riêng thì thay bằng CSS tokens, không thêm contrast/hue-rotate gây mất màu media. */
html[data-theme="dark"] { filter: invert(1); background: #fff; }
html[data-theme="dark"] :is(img, video, canvas, iframe, .video-thumbnail) { filter: invert(1); }
html[data-theme="dark"] .video-thumbnail :is(img, video, canvas, iframe) { filter: none; }
/* Widget vốn tối sẵn đảo lại; media bên trong không đảo thêm lần nữa. */
html[data-theme="dark"] :is(#logPanel, #logPanelToggle, #phoneStreamContainer, #phonePanelToggle) { filter: invert(1); }
html[data-theme="dark"] :is(#logPanel, #phoneStreamContainer) :is(img, video, canvas, iframe) { filter: none; }

/* Manage Accounts: nút/ô nhỏ gọn, không ăn style button toàn cục (full-width gradient). */
#accountsTab td { vertical-align: middle; padding: 10px 14px; }
#accountsTab input { padding: 6px 8px; border: 1px solid #ddd; border-radius: 6px; font: inherit; font-size: 14px !important; background: transparent; }
