:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --bg-overlay: rgba(255, 255, 255, 0.8);
    
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --text-accent: #0056b3;
    
    --accent-primary: #0056b3;
    --accent-secondary: #004494;
    --accent-light: #e3f2fd;
    
    --border-color: #dee2e6;
    --border-light: #f1f3f4;
    
    --success: #28a745;
    --warning: #ffc107;
    --error: #dc3545;
    --info: #17a2b8;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --shadow-focus: 0 0 0 3px rgba(0, 86, 179, 0.1);
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

html[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3d3d3d;
    --bg-overlay: rgba(26, 26, 26, 0.8);
    
    --text-primary: #f5f5f5;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --text-accent: #6ba3ff;
    
    --accent-primary: #0066ff;
    --accent-secondary: #0052cc;
    --accent-light: #1a3a66;
    
    --border-color: #404040;
    --border-light: #2a2a2a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
    font-weight: 400;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.modern-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    transition: background 0.3s ease;
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(var(--border-light) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-light) 1px, transparent 1px);
    background-size: 50px 50px;
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

.floating-shape {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-light), transparent);
    animation: float 20s infinite linear;
    transition: background 0.3s ease;
}

.shape-1 {
    width: 200px;
    height: 200px;
    top: 10%;
    left: 5%;
    animation-delay: 0s;
}

.shape-2 {
    width: 150px;
    height: 150px;
    top: 60%;
    right: 10%;
    animation-delay: -7s;
}

.shape-3 {
    width: 100px;
    height: 100px;
    bottom: 20%;
    left: 20%;
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    25% {
        transform: translateY(-20px) rotate(90deg);
    }
    50% {
        transform: translateY(0px) rotate(180deg);
    }
    75% {
        transform: translateY(20px) rotate(270deg);
    }
}

.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 86, 179, 0.3);
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(20deg);
    box-shadow: 0 6px 20px rgba(0, 86, 179, 0.4);
}

.theme-toggle:active {
    transform: scale(0.95) rotate(20deg);
}

.theme-toggle i {
    transition: transform 0.3s ease;
}

.theme-toggle:hover i {
    transform: rotate(180deg);
}

.app {
    display: flex;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
    transition: background-color 0.3s ease;
}

.sidebar {
    width: 280px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-light);
    transition: border-color 0.3s ease;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    transition: background 0.3s ease;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
}

.logo-primary {
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.logo-accent {
    color: var(--accent-primary);
    transition: color 0.3s ease;
}

.platform-tag {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
    transition: color 0.3s ease;
}

.nav-tabs {
    flex: 1;
    padding: 20px 0;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-tab:hover {
    background: var(--bg-secondary);
}

.nav-tab.active {
    background: var(--accent-light);
    border-right: 3px solid var(--accent-primary);
}

.nav-tab.active .nav-icon {
    color: var(--accent-primary);
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 14px;
    transition: color 0.3s ease;
}

.nav-text {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.nav-badge {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.nav-divider {
    height: 1px;
    background: var(--border-light);
    margin: 16px 20px;
    transition: background-color 0.3s ease;
}

.tab-content {
    display: none;
    padding: 0 20px 20px;
}

.tab-content.active {
    display: block;
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    transition: color 0.3s ease;
}

.model-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.model-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid var(--border-light);
    position: relative;
    background: var(--bg-primary);
}

.model-option:hover {
    border-color: var(--border-color);
    transform: translateY(-1px);
}

.model-option.active {
    border-color: var(--accent-primary);
    background: var(--accent-light);
}

.model-marker {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-muted);
}

.model-option.active .model-marker {
    background: var(--accent-primary);
}

.model-icon {
    width: 32px;
    height: 32px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 14px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.model-option.active .model-icon {
    background: var(--accent-primary);
    color: white;
}

.model-info {
    flex: 1;
}

.model-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.model-desc {
    font-size: 12px;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.model-badge {
    background: var(--accent-primary);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.options-panel {
    margin-top: 20px;
}

.option-group {
    margin-bottom: 16px;
}

.option-row {
    display: flex;
    gap: 12px;
}

.option-group.compact {
    flex: 1;
}

.option-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    transition: color 0.3s ease;
}

.modern-select {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    transition: var(--transition-fast);
    cursor: pointer;
}

.modern-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-focus);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-light);
    transition: border-color 0.3s ease;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    margin-bottom: 16px;
    transition: background-color 0.3s ease;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    transition: background-color 0.3s ease;
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.user-status {
    font-size: 11px;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.user-menu {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: color 0.3s ease;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    width: 100%;
}

.action-btn:hover {
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.action-btn.primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.action-btn.primary:hover {
    background: var(--accent-secondary);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    transition: background-color 0.3s ease;
    min-height: 0;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
    transition: border-color 0.3s ease;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    transition: color 0.3s ease;
}

.current-context h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
    transition: color 0.3s ease;
}

.context-badge {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    width: 32px;
    height: 32px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.messages-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    min-height: 0;
}

.welcome-section {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    padding: 40px 0;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.welcome-icon {
    font-size: 64px;
    color: var(--accent-primary);
    margin-bottom: 24px;
    transition: color 0.3s ease;
}

.welcome-section h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    transition: color 0.3s ease;
}

.welcome-section p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 40px;
    transition: color 0.3s ease;
}

.message {
    margin-bottom: 24px;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    display: flex;
    justify-content: flex-end;
}

.bot-message {
    display: flex;
    justify-content: flex-start;
}

.system-message {
    display: flex;
    justify-content: center;
}

.message-bubble {
    max-width: 70%;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    line-height: 1.5;
    position: relative;
}

.user-message .message-bubble {
    background: var(--accent-primary);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.bot-message .message-bubble {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: var(--radius-sm);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.system-message .message-bubble {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    max-width: 400px;
}

.message-meta {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 6px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px 20px;
    color: var(--text-muted);
    font-size: 13px;
    transition: color 0.3s ease;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing 1.4s infinite ease-in-out;
    transition: background-color 0.3s ease;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { 
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% { 
        transform: scale(1);
        opacity: 1;
    }
}

.generation-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 24px;
    overflow-y: auto;
}

.generation-header {
    text-align: center;
    margin-bottom: 24px;
}

.generation-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

.generation-header p {
    font-size: 14px;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.image-preview,
.video-preview {
    flex: 1;
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.placeholder {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    transition: color 0.3s ease;
}

.placeholder i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.placeholder p {
    font-size: 14px;
}

.generation-status {
    font-size: 13px;
    color: var(--text-secondary);
    transition: color 0.3s ease;
    margin-bottom: 12px;
}

.video-progress {
    margin-top: 20px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
    transition: background-color 0.3s ease;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.input-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 24px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
    background: var(--bg-primary);
    transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

.input-hint {
    flex: 1;
}

.char-count {
    margin-left: 16px;
}

.input-area {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-light);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.message-input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
    resize: vertical;
    max-height: 120px;
    min-height: 44px;
    outline: none;
    font-family: inherit;
    line-height: 1.5;
    transition: var(--transition-fast);
}

.message-input:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-focus);
}

.message-input::placeholder {
    color: var(--text-muted);
}

.send-button {
    width: 44px;
    height: 44px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.send-button:hover {
    background: var(--accent-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 86, 179, 0.3);
}

.send-button:active {
    transform: translateY(0);
}

.send-button:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .menu-toggle {
        display: flex;
    }

    .theme-toggle {
        top: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
}

@media (max-width: 640px) {
    .sidebar {
        width: 100%;
    }

    .message-bubble {
        max-width: 85%;
    }

    .theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .input-area {
        padding: 12px 16px;
    }

    .message-input {
        min-height: 40px;
        padding: 10px 12px;
    }

    .send-button {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }

    .generation-container {
        padding: 16px;
    }

    .generation-header h2 {
        font-size: 20px;
    }
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

::selection {
    background: var(--accent-primary);
    color: white;
}