/* TIV2V Studio styles */

body.tiv2v-page {
    --accent-primary: #1e3a5f;
    --accent-secondary: #2c4a6e;
    --accent-light: rgba(30, 58, 95, 0.18);
    --accent-gradient: linear-gradient(135deg, #1e3a5f 0%, #2c4a6e 50%, #3d5a80 100%);
}

.editor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-top: 40px;
}

.editor-layout.api-docs-active {
    grid-template-columns: 1fr;
    gap: 0;
}

.editor-layout.api-docs-active .editor-panel {
    min-height: auto;
}

.editor-layout.api-docs-active .preview-panel {
    display: none;
}

.editor-panel,
.preview-panel {
    min-height: 520px;
}

.editor-panel {
    display: flex;
}

.editor-panel > .side-tabs {
    flex: 1;
}

section {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.section-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
}

.prompts-section textarea {
    width: 100%;
    min-height: 150px;
    resize: vertical;
    font-size: 15px;
    line-height: 1.55;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.92);
    box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.05);
}

.prompts-section textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 18px;
}

.input-group:first-of-type {
    margin-top: 0;
}

.input-group label {
    font-weight: 500;
    color: var(--text-secondary);
}

.input-group input,
.input-group select,
.input-group textarea {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: rgba(255, 255, 255, 0.94);
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.input-hint {
    font-size: 13px;
    color: var(--text-muted);
}

.advanced-section {
    margin-top: 12px;
    margin-bottom: 24px;
}

.advanced-header {
    cursor: pointer;
    user-select: none;
    padding: 6px 0;
}

.advanced-header:hover .fold-icon {
    color: var(--accent-primary);
}

.advanced-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.fold-icon {
    font-size: 14px;
    color: var(--text-muted);
    transition: transform 0.2s ease, color 0.2s ease;
}

.fold-icon.collapsed {
    transform: rotate(0deg);
}

.fold-icon:not(.collapsed) {
    transform: rotate(90deg);
}

.advanced-content {
    max-height: 400px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
    opacity: 1;
    margin-top: 16px;
}

.advanced-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.media-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    background: linear-gradient(155deg, rgba(124, 58, 237, 0.07), transparent 60%);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.media-card__header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.media-card__header p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: var(--bg-tertiary);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent-primary);
    background-color: var(--accent-light);
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    font-size: 42px;
    margin-bottom: 12px;
}

.upload-text {
    font-size: 15px;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.file-status {
    color: var(--text-muted);
    font-size: 12px;
}

.media-preview {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.media-preview img,
.media-preview video {
    width: 100%;
    display: block;
    border-radius: var(--radius-lg);
    object-fit: cover;
    max-height: 220px;
}

.remove-media {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: rgba(15, 23, 42, 0.75);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.remove-media:hover {
    background-color: var(--error);
}

.panel-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Generate button */
.generate-button {
    width: 100%;
    background-color: var(--accent-primary);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.generate-button:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.generate-button:disabled {
    background-color: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.history-button {
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-secondary);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-button:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}


.preview-panel {
    display: flex;
    align-items: flex-start;
}

.preview-panel section {
    width: 100%;
    height: auto;
}



.preview-container {
    position: relative;
    min-height: 320px;
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-color);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-container video {
    width: 100%;
    height: auto;
    display: block;
    max-height: 520px;
    background-color: #000;
}

.result-placeholder {
    text-align: center;
    padding: 40px;
}

.placeholder-icon {
    font-size: 52px;
    margin-bottom: 12px;
}

.placeholder-headline {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.placeholder-text {
    color: var(--text-secondary);
    font-size: 14px;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.72);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    padding: 20px;
}

.spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    animation: spin 0.9s linear infinite;
}

.loading-text {
    font-size: 16px;
    font-weight: 600;
}

.loading-subtext {
    font-size: 14px;
    opacity: 0.85;
}

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

.download-button {
    margin-top: 16px;
    width: 100%;
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-md);
    padding: 12px;
    font-weight: 600;
    background: transparent;
    color: var(--accent-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.download-button:hover {
    background: var(--accent-primary);
    color: #fff;
}

.generation-metrics,
.video-info {
    margin-top: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    border: 1px solid var(--border-color);
}

.generation-metrics {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.video-info {
    display: flex;
    gap: 20px;
}

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

.metric-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.metric-value {
    font-weight: 600;
    color: var(--text-primary);
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.info-value {
    font-weight: 600;
    color: var(--text-primary);
}

.code-section {
    position: relative;
}

.copy-code-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.copy-code-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent-primary);
}

/* History panel */
.history-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: historyFadeIn 0.2s ease-out;
}

@keyframes historyFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.history-panel-content {
    background: var(--bg-card);
    border-radius: 20px;
    width: 92%;
    max-width: 620px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
    border: 1px solid var(--border-color);
    overflow: hidden;
    animation: historySlideUp 0.25s ease-out;
}

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

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

.history-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.history-close-btn {
    background: none;
    border: none;
    font-size: 30px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.history-close-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.history-list {
    padding: 0 26px 22px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s ease;
}

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

.history-item:hover {
    background: rgba(124, 58, 237, 0.05);
}

.history-item-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-item-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.history-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.history-meta {
    font-size: 13px;
    color: var(--text-muted);
}

.history-status {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(124, 58, 237, 0.12);
    color: #7c3aed;
}

.history-status.done {
    background: rgba(34, 197, 94, 0.14);
    color: #16a34a;
}

.history-status.error {
    background: rgba(239, 68, 68, 0.14);
    color: #dc2626;
}

.history-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.history-delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.no-history {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
}

.output-cost-note {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}
@media (max-width: 1100px) {
    .editor-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .preview-panel {
        order: -1;
    }

    .side-tabs {
        padding: 18px;
    }
}

@media (max-width: 768px) {
    .page-title {
        font-size: 28px;
    }

    .page-description {
        font-size: 15px;
    }

    .editor-layout {
        gap: 18px;
    }

    section {
        padding: 18px;
        margin-bottom: 18px;
    }

    .side-tabs {
        padding: 16px;
        gap: 14px;
    }

    .side-tabs__button {
        font-size: 14px;
        padding: 10px 14px;
    }

    .side-tabs__body {
        padding: 18px 16px;
    }

    .section-title {
        font-size: 18px;
    }

    .section-description {
        font-size: 13px;
    }

    .upload-area {
        padding: 20px;
        min-height: 150px;
    }

    .upload-icon {
        font-size: 32px;
    }

    .upload-text {
        font-size: 15px;
    }

    .upload-hint {
        font-size: 13px;
    }

    .video-preview-container {
        gap: 12px;
    }

    .video-preview {
        max-height: 250px;
    }

    .input-group label {
        font-size: 14px;
    }

    .input-group textarea {
        min-height: 100px;
        font-size: 14px;
    }

    .slider-group label {
        font-size: 14px;
    }

    .slider-container {
        gap: 10px;
    }

    .slider-label {
        font-size: 14px;
    }

    .slider-value {
        font-size: 13px;
    }

    .aspect-ratio-buttons {
        flex-wrap: wrap;
        gap: 8px;
    }

    .aspect-button {
        font-size: 13px;
        padding: 8px 14px;
        flex: 1 1 calc(33.333% - 6px);
        min-width: 80px;
    }

    .generate-button {
        padding: 14px 24px;
        font-size: 15px;
        width: 100%;
    }

    .status-message {
        font-size: 14px;
        padding: 12px;
    }

    .preview-container {
        min-height: 250px;
        padding: 16px;
    }

    .generated-video {
        max-height: 400px;
    }

    .video-info {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
        text-align: center;
    }

    .video-info-item {
        font-size: 13px;
    }

    .video-actions {
        flex-direction: column;
        gap: 10px;
    }

    .download-button, .new-generation-button {
        width: 100%;
        font-size: 14px;
        padding: 12px 20px;
    }

    .code-block pre {
        font-size: 12px;
        padding: 16px;
    }

    .copy-button {
        top: 12px;
        right: 12px;
        padding: 6px 12px;
        font-size: 11px;
    }

    /* History panel improvements for mobile */
    .history-panel-content {
        width: 95%;
        max-height: 85vh;
    }

    .history-header {
        padding: 18px 20px;
    }

    .history-header h3 {
        font-size: 18px;
    }

    .history-list {
        padding: 12px;
    }

    .history-item {
        padding: 12px;
    }

    .history-meta {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .editor-layout {
        gap: 16px;
    }

    .page-title {
        font-size: 24px;
    }

    .page-description {
        font-size: 14px;
    }

    section {
        padding: 14px;
        margin-bottom: 14px;
    }

    .side-tabs {
        padding: 12px;
        gap: 12px;
    }

    .side-tabs__button {
        font-size: 13px;
        padding: 9px 12px;
    }

    .side-tabs__body {
        padding: 16px 14px;
    }

    .upload-area {
        padding: 18px;
        min-height: 130px;
    }

    .upload-icon {
        font-size: 28px;
    }

    .upload-text {
        font-size: 14px;
    }

    .upload-hint {
        font-size: 12px;
    }

    .aspect-button {
        flex: 1 1 calc(50% - 4px);
        font-size: 12px;
        padding: 8px 10px;
    }

    .slider-container {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .slider-value {
        text-align: left;
    }

    .preview-container {
        min-height: 200px;
    }

    .generated-video, .video-preview {
        max-height: 250px;
    }
}
