/* --- RESET & BASE STYLES --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #111827; /* gray-900 */
    color: #D1D5DB; /* gray-300 */
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

button, input, select {
    font-family: inherit;
    font-size: 100%;
    border: none;
    border-radius: 8px;
    transition: all 0.2s ease-in-out;
}

button {
    cursor: pointer;
}

/* --- UTILITY CLASSES --- */
.is-hidden {
    display: none !important;
}

/* --- LAYOUT & MAIN CONTAINERS --- */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
}

.main-content {
    width: 100%;
    max-width: 1024px;
    margin: 0 auto;
}

.editor-panel {
    background-color: rgba(31, 41, 55, 0.5); /* gray-800/50 */
    backdrop-filter: blur(4px);
    border: 1px solid #374151; /* gray-700 */
    border-radius: 16px;
    padding: 24px;
    margin-top: 32px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.ad-placeholder {
    width: 100%;
    min-height: 90px;
    background-color: #374151;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 24px 0;
    font-size: 14px;
    color: #6B7280;
}
.ad-placeholder::before {
    content: "Ad Placeholder";
}

/* --- HEADER --- */
.app-header {
    text-align: center;
}

.header-icon-wrapper {
    display: inline-block;
    background-color: rgba(99, 102, 241, 0.2);
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.header-icon {
    width: 40px;
    height: 40px;
    color: #818CF8; /* indigo-400 */
}

.app-title {
    font-size: 36px;
    font-weight: 800;
    background: linear-gradient(to right, #818CF8, #A78BFA); /* from-indigo-400 to-purple-500 */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
}

.app-description {
    margin-top: 16px;
    max-width: 672px; /* max-w-2xl */
    margin-left: auto;
    margin-right: auto;
    font-size: 18px;
    color: #9CA3AF; /* gray-400 */
}

/* --- TABS --- */
.tabs-container {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #374151;
}

.tabs-navigation {
    flex-grow: 1;
    display: flex;
    gap: 8px;
}

.scene-tab-wrapper {
    position: relative;
}

.scene-tab-button {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px 8px 0 0;
    background-color: transparent;
    color: #9CA3AF; /* gray-400 */
}
.scene-tab-button:hover {
    color: #F9FAFB; /* white */
    background-color: rgba(55, 65, 81, 0.5); /* gray-700/50 */
}
.scene-tab-button.is-active {
    background-color: #374151; /* gray-700 */
    color: #F9FAFB; /* white */
}

.remove-tab-button {
    position: absolute;
    top: -4px;
    right: -4px;
    padding: 2px;
    background-color: #4B5563; /* gray-600 */
    border-radius: 9999px;
    color: #D1D5DB; /* gray-300 */
    display: flex;
    align-items: center;
    justify-content: center;
}
.remove-tab-button:hover {
    background-color: #EF4444; /* red-500 */
    color: #F9FAFB; /* white */
}
.remove-tab-icon {
    width: 12px;
    height: 12px;
}

.add-tab-button {
    margin-left: 16px;
    padding: 8px;
    background-color: rgba(79, 70, 229, 0.5); /* indigo-600/50 */
    color: #A5B4FC; /* indigo-300 */
    border-radius: 9999px;
}
.add-tab-button:hover {
    background-color: #4F46E5; /* indigo-600 */
    color: #F9FAFB; /* white */
}
.add-tab-icon {
    width: 20px;
    height: 20px;
}

/* --- GRIDS --- */
.main-grid, .options-preview-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    padding-top: 24px;
}

/* --- CONTROLS COLUMN --- */
.controls-column, .media-column, .options-column, .preview-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.control-group {
    width: 100%;
}

.control-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #D1D5DB; /* gray-300 */
}
.control-label-sub {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 500;
    color: #9CA3AF; /* gray-400 */
}

.text-input, .select-input {
    background-color: #374151; /* gray-700 */
    border: 1px solid #4B5563; /* gray-600 */
    color: #F9FAFB; /* white */
    font-size: 14px;
    border-radius: 8px;
    width: 100%;
    padding: 10px;
}
.text-input:focus, .select-input:focus {
    outline: none;
    border-color: #6366F1; /* indigo-500 */
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.5);
}
.text-input:disabled {
    background-color: #1F2937; /* gray-800 */
    cursor: not-allowed;
    color: #6B7280; /* gray-400 */
}

.help-text {
    margin-top: 4px;
    font-size: 12px;
    color: #6B7280; /* gray-500 */
}

.duration-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.max-button {
    padding: 0 12px;
    height: 42px; /* match input height */
    font-size: 12px;
    font-weight: 700;
    color: #F9FAFB;
    background-color: #4F46E5; /* indigo-600 */
    border-radius: 6px;
}
.max-button:hover {
    background-color: #6366F1; /* indigo-500 */
}
.max-button:disabled {
    background-color: #4B5563; /* gray-600 */
    cursor: not-allowed;
}

.info-box {
    font-size: 14px;
    background-color: rgba(17, 24, 39, 0.5); /* gray-900/50 */
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #374151; /* gray-700 */
}

.info-value {
    font-family: monospace;
    color: #A5B4FC; /* indigo-400 */
}
.info-value.is-invalid {
    color: #F87171; /* red-400 */
    font-weight: 700;
}

/* --- FILE UPLOADERS --- */
.file-uploader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}
.file-uploader-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 128px;
    border: 2px dashed #4B5563; /* gray-600 */
    border-radius: 8px;
    cursor: pointer;
    background-color: #1F2937; /* gray-800 */
    transition: background-color 0.3s, border-color 0.3s;
}
.file-uploader-dropzone:hover, .file-uploader-dropzone.is-dragging-over {
    background-color: rgba(55, 65, 81, 0.5); /* gray-700/50 */
    border-color: #6366F1; /* indigo-500 */
}
.file-uploader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px;
}
.file-uploader-icon {
    color: #818CF8; /* indigo-400 */
    margin-bottom: 12px;
}
.file-uploader-icon.is-selected {
    color: #34D399; /* green-400 */
}
.file-uploader-icon svg {
    width: 32px;
    height: 32px;
}
.file-uploader-text-main {
    margin-bottom: 8px;
    font-size: 14px;
    color: #D1D5DB; /* gray-300 */
    font-weight: 600;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-uploader-text-sub {
    font-size: 12px;
    color: #6B7280; /* gray-500 */
}
.file-uploader-input {
    display: none;
}

/* --- MEDIA LIST --- */
.media-preview-list-wrapper {
    /* Intentionally empty to allow child to have fixed height */
}
.media-preview-list {
    width: 100%;
    height: 250px; /* Base fixed height */
    background-color: rgba(17, 24, 39, 0.5); /* gray-900/50 */
    border-radius: 8px;
    border: 1px solid #374151; /* gray-700 */
    display: flex;
    flex-direction: column;
}
.media-list-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border: 2px dashed #374151; /* gray-700 */
    border-radius: 8px;
}
.placeholder-text {
    text-align: center;
    color: #6B7280; /* gray-500 */
    font-size: 14px;
}
.media-list-ul {
    list-style: none;
    padding: 8px;
    flex-grow: 1; /* Fills parent container */
    overflow-y: auto;
}
/* Custom Scrollbar */
.media-list-ul::-webkit-scrollbar {
    width: 8px;
}
.media-list-ul::-webkit-scrollbar-track {
    background: transparent;
}
.media-list-ul::-webkit-scrollbar-thumb {
    background-color: #4B5563; /* gray-600 */
    border-radius: 4px;
}
.media-list-ul::-webkit-scrollbar-thumb:hover {
    background-color: #6B7280; /* gray-500 */
}

.media-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 6px;
    background-color: #1F2937; /* gray-800 */
    margin-bottom: 8px;
}
.media-item.is-dragging {
    opacity: 0.5;
}
.drag-placeholder {
    height: 40px;
    background-color: rgba(79, 70, 229, 0.2);
    border-radius: 6px;
    margin-bottom: 8px;
}
.media-item-index {
    color: #6B7280;
    font-weight: 700;
    width: 24px;
    text-align: center;
    margin-right: 4px;
}
.media-item-thumbnail {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    margin-right: 16px;
    flex-shrink: 0;
    background-color: #111827;
}
.media-item-info {
    flex-grow: 1;
    font-size: 14px;
    color: #D1D5DB;
    overflow: hidden;
    margin-right: 8px;
}
.media-item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.media-item-duration {
    display: block;
    font-size: 12px;
    color: #9CA3AF;
    font-family: monospace;
}
.animation-select {
    margin-top: 4px;
    padding: 4px;
    font-size: 12px;
}
.remove-media-btn {
    margin-left: auto;
    padding: 4px;
    color: #F87171; /* red-400 */
    border-radius: 9999px;
    flex-shrink: 0;
}
.remove-media-btn:hover {
    color: #FCA5A5; /* red-300 */
    background-color: rgba(153, 27, 27, 0.5); /* red-900/50 */
}
.remove-media-icon {
    width: 20px;
    height: 20px;
    pointer-events: none;
}
.drag-handle {
    margin-left: 8px;
    cursor: grab;
    color: #6B7280; /* gray-500 */
    touch-action: none;
    flex-shrink: 0;
}
.drag-handle:hover {
    color: #D1D5DB; /* gray-300 */
}
.media-item:active .drag-handle {
    cursor: grabbing;
}
.drag-handle-icon {
    width: 20px;
    height: 20px;
    pointer-events: none;
}


/* --- OPTIONS & PREVIEW --- */
.aspect-ratio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.radio-label {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 1px solid #4B5563; /* gray-600 */
    border-radius: 8px;
    cursor: pointer;
}
.radio-label:hover {
    background-color: rgba(55, 65, 81, 0.5); /* gray-700/50 */
}
.radio-input {
    width: 16px;
    height: 16px;
    accent-color: #4F46E5;
}
.radio-text {
    margin-left: 12px;
    font-size: 14px;
    font-weight: 500;
    color: #D1D5DB;
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background-color: rgba(17, 24, 39, 0.5); /* gray-900/50 */
    border-radius: 8px;
    border: 1px solid #374151; /* gray-700 */
}
.slider-input {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: #374151;
    border-radius: 4px;
    cursor: pointer;
}
.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #818CF8;
    border-radius: 50%;
    border: 2px solid #1F2937;
}
.slider-input::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #818CF8;
    border-radius: 50%;
    border: 2px solid #1F2937;
}

.slider-value {
    font-family: monospace;
    color: #818CF8; /* indigo-400 */
    font-size: 18px;
    width: 48px;
    text-align: center;
}

/* --- SUBTITLE POSITIONER --- */
.subtitle-options-box {
    padding: 16px;
    background-color: rgba(17, 24, 39, 0.5);
    border-radius: 8px;
    border: 1px solid #374151;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.subtitle-preset-btn {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    background-color: #4338CA; /* indigo-700 */
    color: #E0E7FF; /* indigo-200 */
}
.subtitle-preset-btn:hover {
    background-color: #4F46E5; /* indigo-600 */
    color: #F9FAFB; /* white */
}

.subtitle-grid, .position-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.subtitle-position-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.align-button-group {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}
.subtitle-align-btn {
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 6px;
    background-color: #374151;
    color: #D1D5DB;
}
.subtitle-align-btn:hover {
    background-color: #4B5563;
}
.subtitle-align-btn.is-active {
    background-color: #4F46E5;
    color: #F9FAFB;
    font-weight: 600;
}


/* --- PREVIEW --- */
.preview-box {
    width: 100%;
    background-color: #111827;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 2px solid #374151;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}
.preview-media-container, .preview-placeholder {
    width: 100%;
    height: 100%;
}
.preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #6B7280;
    padding: 16px;
}
.preview-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.preview-subtitle {
    position: absolute;
    white-space: pre;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 3px #000, -1px -1px 3px #000, 1px -1px 3px #000, -1px 1px 3px #000;
    pointer-events: none;
}

/* --- ACTIONS FOOTER --- */
.actions-footer {
    margin-top: 32px;
    text-align: center;
}

.action-button {
    width: 100%;
    padding: 16px 48px;
    background-color: #4F46E5; /* indigo-600 */
    color: #F9FAFB;
    font-weight: 700;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}
.action-button:hover {
    background-color: #6366F1; /* indigo-500 */
    transform: scale(1.02);
}
.action-button:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.5);
}
.action-button:disabled {
    background-color: #4B5563; /* gray-600 */
    cursor: not-allowed;
    transform: none;
}

.error-message {
    margin-top: 24px;
    padding: 16px;
    background-color: rgba(153, 27, 27, 0.2); /* red-900/50 */
    border: 1px solid #7f1d1d; /* red-700 */
    color: #F87171; /* red-300 */
    border-radius: 8px;
}

.progress-container {
    margin-top: 32px;
    text-align: center;
}
.progress-bar-wrapper {
    width: 100%;
    background-color: #374151; /* gray-700 */
    border-radius: 9999px;
    height: 10px;
}
.progress-bar {
    background-color: #6366F1; /* indigo-500 */
    height: 10px;
    border-radius: 9999px;
    transition: width 0.3s ease-in-out;
}
.progress-text {
    margin-top: 8px;
    font-size: 14px;
    color: #9CA3AF;
}

.video-result-container {
    margin-top: 40px;
    padding: 24px;
    background-color: rgba(17, 24, 39, 0.5); /* gray-900/50 */
    border-radius: 16px;
    border: 1px solid #374151;
}

.result-title {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 16px;
    color: #34D399; /* green-400 */
}
.result-video {
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}
.result-actions {
    margin-top: 24px;
    text-align: center;
}
.download-button {
    display: inline-block;
    padding: 12px 32px;
    background-color: #16A34A; /* green-600 */
    color: #F9FAFB;
    font-weight: 700;
    border-radius: 8px;
    text-decoration: none;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}
.download-button:hover {
    background-color: #22C55E; /* green-500 */
    transform: scale(1.05);
}

#footer {
	height: 90px;
    color: #fff;
    text-align: center;
    padding: 10px 0;
}

/* --- RESPONSIVE STYLES --- */

/* Small screens (default, mobile-first) */
@media (max-width: 767px) {
    .app-title { font-size: 30px; }
    .app-description { font-size: 16px; }
    .editor-panel { padding: 16px; }
    .main-grid, .options-preview-grid { gap: 16px; padding-top: 16px; }
    .action-button { padding: 12px 24px; }
    .aspect-ratio-group { flex-direction: column; }
}


/* Medium screens (tablets) */
@media (min-width: 640px) {
    .app-container { padding: 24px; }
    .app-title { font-size: 40px; }
    .aspect-ratio-group { flex-direction: row; }
}

@media (min-width: 768px) {
    .main-grid {
        grid-template-columns: 1fr 2fr;
        gap: 24px;
    }
    .action-button {
        width: auto;
    }
    .media-preview-list {
        height: 450px; /* Taller on larger screens */
    }
}

/* Large screens (desktops) */
@media (min-width: 1024px) {
    .app-container { padding: 32px; }
    .app-title { font-size: 48px; }
    .options-preview-grid {
        grid-template-columns: 1fr 1fr;
        gap: 32px;
        align-items: flex-start;
    }
}
