* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0a0a0a;
    --bg-card: #141414;
    --bg-elevated: #1a1a1a;
    --border-color: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px;
    margin-bottom: 32px;
}

.logo svg {
    color: var(--accent-primary);
}

.logo span {
    font-weight: 600;
    font-size: 1.1rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-menu {
    list-style: none;
}

.nav-menu li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-menu li:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.nav-menu li.active {
    background: var(--accent-gradient);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Create Tab */
.create-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    max-width: 1400px;
    margin: 0 auto;
}

.create-panel, .preview-panel {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 32px;
    border: 1px solid var(--border-color);
}

.create-panel h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

textarea {
    width: 100%;
    height: 140px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

textarea::placeholder {
    color: var(--text-muted);
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.char-count {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-enhance {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-enhance:hover {
    background: var(--accent-primary);
    color: white;
}

.enhanced-prompt-section {
    background: var(--bg-elevated);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    border: 1px solid var(--accent-primary);
}

.enhanced-prompt-section label {
    display: block;
    font-size: 0.85rem;
    color: var(--accent-primary);
    margin-bottom: 8px;
}

.enhanced-text {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 12px;
}

.btn-use-enhanced {
    background: var(--accent-gradient);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-use-enhanced:hover {
    opacity: 0.9;
}

.settings-row {
    display: flex;
    gap: 24px;
    margin-bottom: 32px;
}

.setting-item {
    flex: 1;
}

.setting-item label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.duration-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.duration-control input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--bg-elevated);
    border-radius: 3px;
    cursor: pointer;
}

.duration-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-gradient);
    border-radius: 50%;
    cursor: pointer;
}

.duration-control span {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 30px;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-elevated);
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: var(--accent-gradient);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.btn-generate {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--accent-gradient);
    border: none;
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);
}

.btn-generate:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Preview Panel */
.preview-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
}

.preview-placeholder {
    text-align: center;
    color: var(--text-muted);
}

.preview-placeholder svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.preview-placeholder p {
    font-size: 0.95rem;
}

/* Status Section */
.status-section {
    text-align: center;
    width: 100%;
}

.status-animation {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
}

.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid var(--accent-primary);
    border-radius: 50%;
    animation: pulse 2s ease-out infinite;
}

.pulse-core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: 50%;
    animation: glow 2s ease-in-out infinite;
}

@keyframes pulse {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px rgba(102, 126, 234, 0.5); }
    50% { box-shadow: 0 0 40px rgba(102, 126, 234, 0.8); }
}

.status-section h3 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 300px;
    margin: 0 auto;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 3px;
    transition: width 0.3s;
    width: 0%;
}

#progressText {
    font-weight: 600;
    color: var(--accent-primary);
    min-width: 40px;
}

/* Result Section */
.result-section {
    width: 100%;
}

.result-section video {
    width: 100%;
    max-height: 400px;
    border-radius: 12px;
    background: black;
    margin-bottom: 20px;
}

/* Audio Section */
.audio-section {
    background: var(--bg-elevated);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.audio-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-primary);
    font-weight: 500;
}

.audio-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.audio-header svg {
    color: var(--accent-primary);
}

.audio-content {
    margin-top: 16px;
}

.audio-content.hidden {
    display: none;
}

.small-toggle {
    width: 40px;
    height: 22px;
}

.small-toggle .toggle-slider:before {
    height: 16px;
    width: 16px;
}

.small-toggle input:checked + .toggle-slider:before {
    transform: translateX(18px);
}

.audio-upload {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.btn-select-audio {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-select-audio:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.audio-filename {
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 16px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.volume-control label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.volume-control input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    background: var(--bg-card);
    border-radius: 2px;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
}

.volume-control span {
    color: var(--text-primary);
    font-size: 0.85rem;
    min-width: 40px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
}

.btn-add-audio {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent-gradient);
    border: none;
    color: white;
    padding: 12px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-audio:hover {
    transform: translateY(-2px);
}

.btn-add-audio:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.result-actions {
    display: flex;
    gap: 12px;
}

.btn-action {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-download {
    background: var(--success);
    color: white;
}

.btn-instagram {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    color: white;
}

.btn-new {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-action:hover {
    transform: translateY(-2px);
}

/* Error Section */
.error-section {
    text-align: center;
    color: var(--error);
}

.error-section svg {
    margin-bottom: 16px;
}

.error-section p {
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.btn-retry {
    background: var(--error);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 0.95rem;
    cursor: pointer;
}

/* Library Tab */
.library-header {
    margin-bottom: 32px;
}

.library-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.video-card {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: all 0.3s;
}

.video-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-4px);
}

.video-card-header {
    padding: 16px;
    background: var(--bg-elevated);
}

.video-card-prompt {
    font-size: 0.9rem;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}

.video-card-body {
    padding: 16px;
}

.video-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.video-status {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-succeeded { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.status-running, .status-preprocessing { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.status-failed { background: rgba(239, 68, 68, 0.2); color: var(--error); }

.video-card-actions {
    display: flex;
    gap: 8px;
}

.video-card-actions button {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-card-download {
    background: var(--success);
    color: white;
}

.btn-card-delete {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-color) !important;
}

.btn-card-download:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

.btn-card-instagram {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    color: white;
}

.btn-card-instagram:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

.result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.result-actions .btn-new {
    grid-column: 1 / -1;
}

.video-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.hidden {
    display: none !important;
}

/* Instagram Modal */
.instagram-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.instagram-modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    max-width: 420px;
    width: 100%;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.instagram-modal-header {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    padding: 24px;
    text-align: center;
    color: white;
}

.instagram-modal-header svg {
    margin-bottom: 12px;
}

.instagram-modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.instagram-modal-body {
    padding: 24px;
}

.instagram-modal-body p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.instagram-modal-body ol {
    color: var(--text-primary);
    padding-left: 20px;
    line-height: 1.8;
}

.instagram-modal-body li {
    margin-bottom: 8px;
}

.instagram-modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    gap: 12px;
}

.btn-open-instagram {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    color: white;
}

.btn-close-modal {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 1024px) {
    .create-container {
        grid-template-columns: 1fr;
    }

    .preview-panel {
        min-height: 400px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        flex-direction: row;
        padding: 12px 20px;
        border-right: none;
        border-top: 1px solid var(--border-color);
        z-index: 100;
    }

    .logo {
        display: none;
    }

    .nav-menu {
        display: flex;
        width: 100%;
        justify-content: space-around;
    }

    .nav-menu li {
        flex-direction: column;
        gap: 4px;
        font-size: 0.75rem;
        padding: 8px 16px;
    }

    .main-content {
        padding: 20px;
        padding-bottom: 80px;
    }

    .settings-row {
        flex-direction: column;
    }
}
