:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #94a3b8;
    --secondary-hover: #64748b;
    --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #3b82f6;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Basic reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
    color: var(--text-main);
    background: var(--bg-gradient);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 40px 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

h1, h2 {
    color: #0f172a;
    font-weight: 700;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-muted {
    background-color: #f1f5f9;
    color: #64748b;
}

.badge-success {
    background-color: #dcfce7;
    color: #166534;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 32px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup-content {
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease-out;
}

#task-form-popup .popup-content {
    max-width: 800px;
}

/* Tabs */
.tabs {
    display: inline-flex;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
    padding: 6px;
    border-radius: 12px;
}

.tab-btn {
    appearance: none;
    -webkit-appearance: none;
    padding: 8px 14px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 10px;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.tab-btn:hover {
    background: #eef2ff;
    color: var(--primary-color);
    border-color: #e0e7ff;
}

.tab-btn.active {
    color: #fff;
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}

.tab-content.hidden {
    display: none;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

.popup-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0;
}

.close-btn {
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.close-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.close-btn:hover {
    background: #fee2e2;
    color: var(--error-color);
}

.form-group {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

label {
    flex: 0 0 120px;
    font-weight: 500;
    color: #475569;
    padding-right: 15px;
}

.form-control {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #fff;
    -webkit-appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-control.is-invalid {
    border-color: var(--error-color);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-hint {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
}

.error-message {
    color: var(--error-color);
    font-size: 0.8rem;
    margin-top: 4px;
    margin-left: 120px;
    display: none;
    width: 100%;
}

@media (max-width: 768px) {
    .error-message {
        margin-left: 0;
    }
}

textarea.form-control {
    height: 100px;
    resize: vertical;
}

select.form-control {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.form-check {
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.mode-selection {
    background: #f1f5f9;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.radio-group {
    display: flex;
    gap: 20px;
    flex: 1;
}

.radio-label {
    flex: none;
    width: auto;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
}

.radio-label input[type="radio"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.form-check label {
    flex: none;
    width: 100%;
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--text-main);
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 12px;
    accent-color: var(--primary-color);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: #fff;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    -webkit-appearance: none;
}

.btn .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2em;
    height: 1.2em;
    margin-right: 8px;
    vertical-align: middle;
    flex-shrink: 0;
}

.btn .icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    display: block;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-secondary {
    background: var(--secondary-color);
}

.btn-secondary:hover {
    background: var(--secondary-hover);
}

#task-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.task-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
    gap: 16px;
}

.task-row:last-child {
    border-bottom: none;
}

.task-row:hover {
    background-color: #f8fafc;
}

.task-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.task-id-short {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.task-title-main {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

.task-tags-inline {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: flex-start;
    width: 210px;
}

.tag-col-anim {
    width: 90px;
    display: flex;
    justify-content: center;
}

.tag-col-type {
    width: 115px;
    display: flex;
    justify-content: center;
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
    line-height: 1;
    height: 18px;
    white-space: nowrap;
}

.tag-anim {
    background: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

.tag-type {
    background: #eef2ff;
    color: var(--primary-color);
    border-color: #e0e7ff;
}

.task-meta-actions {
    display: flex;
    align-items: center;
    gap: 12px; /* Уменьшил зазор с 24px до 12px */
    flex-shrink: 0;
}

.task-tags-inline {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
    width: 240px;
}

.task-date-inline {
    font-size: 0.8rem;
    color: var(--text-muted);
    width: 130px; /* увеличил ширину */
    text-align: left;
    white-space: nowrap; /* запретил перенос */
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
    width: 110px; /* фиксированная ширина для статуса слева */
    flex-shrink: 0;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.status-indicator.status-queued { color: var(--warning-color); }
.status-indicator.status-processing { color: var(--info-color); }
.status-indicator.status-completed { color: var(--success-color); }
.status-indicator.status-failed { color: var(--error-color); }

.btn-sm {
    padding: 4px 12px;
    font-size: 0.8rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: #fff;
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.advanced-settings-header {
    display: inline-block;
    padding: 8px 16px;
    background: #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main) !important;
    text-decoration: none !important;
    cursor: pointer;
    transition: all 0.2s;
}

.advanced-settings-header:hover {
    background: #cbd5e1;
    transform: translateY(-1px);
}

#advanced-settings {
    padding: 20px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.hidden {
    display: none;
}

/* Pagination */
.pagination-info {
    margin: 1.5rem 0 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.pagination-controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

    @media (max-width: 768px) {
        body { padding: 20px 15px; }
        h1 { flex-direction: column; align-items: flex-start; gap: 1rem; }
        h1 span { width: 100%; justify-content: space-between; }
        
        .form-group {
            flex-direction: column;
            align-items: flex-start;
        }

        label {
            flex: none;
            width: 100%;
            margin-bottom: 8px;
            padding-right: 0;
        }
        
        #task-list {
            display: flex;
            flex-direction: column;
        }
        
        .task-row {
            flex-direction: column;
            align-items: flex-start;
            gap: 12px;
            padding: 16px;
        }

        .task-info {
            width: 100%;
            flex-wrap: wrap;
        }

        .task-meta-actions {
            width: 100%;
            justify-content: space-between;
            gap: 12px;
        }

        .task-tags-inline {
            width: auto;
            justify-content: flex-start;
        }

        .task-date-inline {
            width: auto;
            text-align: left;
        }
    }


/* Danger badge */
.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Inline auth error under login form */
#login-error {
    display: none; /* shown by JS when needed */
    background: #fef2f2; /* light red */
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 8px 12px;
    border-radius: 8px;
    margin: 8px 0 16px 0;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1.1rem;
    border-radius: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4338ca 0%, #312e81 100%);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

.main-actions {
    margin-bottom: 32px;
    display: flex;
    justify-content: flex-start;
}

.main-actions .icon {
    margin-right: 8px;
    font-size: 1.2rem;
    font-weight: 700;
}

/* Task Details Styles */
.task-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.info-section {
    background: #ffffff;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.info-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.info-section h3 {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
    color: var(--primary-color);
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 10px;
}

.info-section p {
    margin-bottom: 12px;
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.info-section p:last-child {
    margin-bottom: 0;
}

.info-section strong {
    color: #64748b;
    font-weight: 500;
    flex-shrink: 0;
}

.info-value {
    color: #1e293b;
    font-weight: 600;
    text-align: right;
}

.info-group {
    margin-bottom: 12px;
}

.info-group:last-child {
    margin-bottom: 0;
}

.info-group strong {
    display: block;
    margin-bottom: 6px;
}

.info-text {
    background: #f8fafc;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #334155;
    border: 1px solid #f1f5f9;
    line-height: 1.5;
}

/* Ensure long text doesn't overflow */
.info-section p {
    word-break: break-word;
}

.info-section-full {
    grid-column: 1 / -1;
}

.info-code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    line-height: 1.5;
    margin: 0;
}

/* Status badges in details */
.status-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-badge.queued { background: #fef3c7; color: #92400e; }
.status-badge.processing { background: #dbeafe; color: #1e40af; }
.status-badge.completed { background: #dcfce7; color: #166534; }
.status-badge.failed { background: #fee2e2; color: #991b1b; }

#refresh-status {
    margin-bottom: 0;
}

#refresh-status.hidden {
    display: none !important;
}

#task-video {
    margin-bottom: 32px;
    padding-bottom: 24px;
}

#task-video h2 {
    margin-bottom: 16px;
    font-size: 1.25rem;
}

#video-container video {
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

/* Disabled button state */
.btn:disabled,
.btn[disabled] {
    background: #e2e8f0; /* gray background */
    color: #94a3b8;      /* muted text */
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Keep disabled button stable on hover */
.btn:disabled:hover,
.btn[disabled]:hover {
    background: #e2e8f0;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 8px;
    background-color: var(--card-bg);
    min-width: 160px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    z-index: 1001;
    overflow: hidden;
    padding: 6px;
}

.dropdown-content a {
    color: var(--text-main);
    padding: 10px 16px;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
}

.dropdown-content a:hover {
    background-color: #f1f5f9;
    color: var(--primary-color);
}

.dropdown-content a#menu-sign-out {
    color: var(--error-color);
}

.dropdown-content a#menu-sign-out:hover {
    background-color: #fef2f2;
}
