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

:root {
    --bg-primary: #120B1B;
    --bg-secondary: #130d1a;
    --bg-card: #1a1225;
    --bg-input: #1e1529;
    --border-color: #2d1f3d;
    --border-hover: #3d2a52;
    --accent: #9333EA;
    --accent-hover: #7c22ce;
    --accent-glow: rgba(147, 51, 234, 0.3);
    --text-primary: #ffffff;
    --text-secondary: #D4D4D4;
    --text-muted: #737380;
    --text-hint: #52525b;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-secondary);
    line-height: 1.6;
    background-image: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(147, 51, 234, 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(147, 51, 234, 0.08), transparent);
}

/* App Container */
.app-container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px 30px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0 24px 0;
    margin-bottom: 8px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 36px;
    height: 36px;
    filter: drop-shadow(0 0 8px rgba(147, 51, 234, 0.4));
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(147, 51, 234, 0.1);
    border: 1px solid rgba(147, 51, 234, 0.2);
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent);
}

.badge-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Main Two-Column Layout */
.main-layout {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 30px;
    flex: 1;
}

/* Left Panel */
.left-panel {
    display: flex;
    flex-direction: column;
}

/* Navigation Tabs */
.navigation {
    margin-bottom: 20px;
}

.nav-tabs {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
}

.nav-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border-radius: 8px;
    border: none;
}

.nav-tab svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.nav-tab:hover {
    color: var(--text-secondary);
    background: rgba(147, 51, 234, 0.08);
}

.nav-tab:hover svg {
    opacity: 1;
}

.nav-tab.active {
    color: var(--text-primary);
    background: var(--accent);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.nav-tab.active svg {
    opacity: 1;
}

/* Controls Card */
.controls-card {
    background: var(--bg-card);
    padding: 28px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 420px;
    min-height: 420px;
    max-height: 420px;
    overflow-y: auto;
}

.card-header {
    margin-bottom: 24px;
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.card-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Tab Content */
.tab-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Input Groups */
.try-input-group {
    margin-bottom: 20px;
}

.try-input-group:last-of-type {
    margin-bottom: 24px;
}

.try-input-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 10px;
}

.try-input-group label svg {
    color: var(--accent);
    opacity: 0.8;
}

.try-input-group textarea {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    min-height: 130px;
    transition: all 0.2s ease;
    background: var(--bg-input);
    color: var(--text-secondary);
    line-height: 1.6;
}

.try-input-group textarea::placeholder {
    color: var(--text-hint);
}

.try-input-group textarea:hover {
    border-color: var(--border-hover);
}

.try-input-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-secondary);
}

/* File Upload */
.file-upload-wrapper {
    position: relative;
}

.file-upload-wrapper input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.file-upload-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px 20px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    background: var(--bg-input);
    transition: all 0.2s ease;
    cursor: pointer;
}

.file-upload-text svg {
    color: var(--text-muted);
}

.file-upload-text span {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.file-upload-text .file-hint {
    font-size: 0.75rem;
    color: var(--text-hint);
}

.file-upload-wrapper:hover .file-upload-text {
    border-color: var(--accent);
    background: rgba(147, 51, 234, 0.05);
}

.file-upload-wrapper:hover .file-upload-text svg {
    color: var(--accent);
}

/* Generate Button */
.generate-button {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 20px var(--accent-glow);
    margin-top: auto;
}

.generate-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--accent-glow);
}

.generate-button:active {
    transform: translateY(0);
}

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

.generate-button svg {
    width: 20px;
    height: 20px;
}

/* Controls Footer */
.controls-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-top: 16px;
    font-size: 0.8rem;
}

.footer-info {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-hint);
}

.footer-info svg {
    opacity: 0.6;
}

.generation-counter {
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Right Panel - Preview */
.right-panel {
    display: flex;
    flex-direction: column;
}

.preview-container {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    height: 600px;
    min-height: 600px;
    max-height: 600px;
}

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

.preview-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.preview-status {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 10px;
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border-radius: 100px;
}

/* Image Container */
.image-container {
    height: 500px;
    min-height: 500px;
    max-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: 
        linear-gradient(var(--bg-secondary), var(--bg-secondary)) padding-box,
        linear-gradient(135deg, rgba(147, 51, 234, 0.2) 0%, transparent 50%, rgba(147, 51, 234, 0.1) 100%) border-box;
    margin: 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    overflow: hidden;
    position: relative;
}

.image-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(ellipse at 30% 20%, rgba(147, 51, 234, 0.08), transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(147, 51, 234, 0.05), transparent 50%);
    pointer-events: none;
}

.image-container img:not(.placeholder-logo) {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    position: relative;
    z-index: 1;
}

/* Placeholder Content */
.placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px;
    position: relative;
    z-index: 1;
}

.placeholder-icon {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(147, 51, 234, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(147, 51, 234, 0.2);
}

.placeholder-logo {
    width: 48px;
    height: auto;
    opacity: 0.6;
}

.placeholder-text {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
}

.placeholder-hint {
    color: var(--text-hint);
    font-size: 0.85rem;
    text-align: center;
}

/* Output Actions */
.output-actions {
    padding: 16px 20px;
    display: flex;
    gap: 12px;
    justify-content: center;
    border-top: 1px solid var(--border-color);
}

.action-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.action-button svg {
    width: 18px;
    height: 18px;
}

/* Image Previews for Edit Tab */
.image-previews-container {
    margin-top: 16px;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 12px;
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: 8px;
    position: relative;
    z-index: 20;
}

.image-preview-item {
    flex: 0 0 auto !important;
    position: relative;
}

.image-preview-item:first-child .image-preview-container::before {
    content: 'Main';
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--accent);
    color: white;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 600;
    z-index: 5;
    pointer-events: none;
}

.image-preview-container {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 6px;
    background: var(--bg-input);
    width: 100px;
    height: 100px;
    transition: all 0.2s ease;
    cursor: pointer;
    overflow: hidden;
    z-index: 25;
}

.image-preview-container:hover {
    border-color: var(--error);
}

.image-preview-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.image-preview-container:hover img {
    opacity: 0.3;
    transform: scale(1.05);
}

.image-remove-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    opacity: 0;
    transition: all 0.2s ease;
    color: var(--error);
    pointer-events: none;
}

.image-remove-overlay svg {
    width: 24px;
    height: 24px;
}

.image-remove-overlay span {
    font-size: 0.65rem;
    font-weight: 500;
    white-space: nowrap;
}

.image-preview-container:hover .image-remove-overlay {
    opacity: 1;
}

/* Loading State */
.loading {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.placeholder-content .loading {
    margin-bottom: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error State */
.error {
    color: var(--error) !important;
}

/* Responsive Design */
@media (max-width: 1100px) {
    .main-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .right-panel {
        order: -1;
    }
    
    .preview-container {
        height: 500px;
        min-height: 500px;
        max-height: 500px;
    }
    
    .image-container {
        height: 400px;
        min-height: 400px;
        max-height: 400px;
    }
}
    
@media (max-width: 640px) {
    .app-container {
        padding: 16px;
    }
    
    .app-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .nav-tab {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
    
    .nav-tab svg {
        display: none;
    }
    
    .controls-card {
        padding: 20px;
    }
    
    .card-header h2 {
        font-size: 1.1rem;
    }
    
    .generate-button {
        padding: 14px 20px;
        font-size: 0.9rem;
    }
    
    .controls-footer {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .preview-container {
        height: 420px;
        min-height: 420px;
        max-height: 420px;
    }
    
    .image-container {
        height: 300px;
        min-height: 300px;
        max-height: 300px;
        margin: 12px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-content {
    animation: fadeIn 0.3s ease-out;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* Selection */
::selection {
    background: var(--accent);
    color: white;
}

/* Limit Reached Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

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

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px var(--accent-glow);
    animation: slideUp 0.3s ease;
}

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

.modal-icon {
    width: 80px;
    height: 80px;
    background: rgba(147, 51, 234, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    color: var(--accent);
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.modal-message {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 28px;
}

.modal-button {
    width: 100%;
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.modal-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px var(--accent-glow);
}

.modal-button:active {
    transform: translateY(0);
}
