:root {
    --bg-dark: #0f172a;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --accent: #38bdf8;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --card-radius: 16px;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

.app-container {
    display: flex;
    height: 100vh;
    background: var(--bg-gradient);
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);
}

/* Sidebar */
.sidebar {
    width: 280px;
    margin: 20px;
    display: flex;
    flex-direction: column;
    padding: 30px;
    justify-content: space-between;
}

.logo-area h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.8rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-area h1 span {
    color: var(--primary);
}

.logo-area i {
    font-size: 1.8rem;
    color: var(--accent);
}

.nav-steps {
    flex: 1;
    margin-top: 60px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.step {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.6;
}

.step.active {
    background: rgba(139, 92, 246, 0.2);
    opacity: 1;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.step-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-family: 'Outfit', sans-serif;
}

.step.active .step-icon {
    background: var(--primary);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    position: relative;
}

.step-section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.step-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    margin-bottom: 5px;
}

.section-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 40px;
}

/* Grid Layout */
.grid-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.card {
    padding: 30px;
}

.card h3 {
    margin-top: 0;
    margin-bottom: 25px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

input,
textarea {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
}

/* Template Grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.template-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    /* For absolute positioning of preview */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 120px;
}

.template-item:hover,
.template-item.selected {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--primary);
}

.template-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--text-muted);
    transition: transform 0.3s;
}

.template-item:hover .template-icon {
    transform: scale(1.1);
    color: var(--primary);
}

/* Template Actions */
.template-actions {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    gap: 10px;
}

.template-item:hover .template-actions {
    opacity: 1;
}

.action-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--primary);
    transform: scale(1.1);
}

.template-name {
    font-size: 0.9rem;
    word-break: break-word;
}

/* File Upload */
.upload-area {
    border: 2px dashed var(--glass-border);
    padding: 50px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.05);
}

.upload-area i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 20px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.file-grid {
    margin-top: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.file-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--glass-border);
}

.file-icon {
    font-size: 1.5rem;
    color: var(--accent);
}

.file-info h4 {
    margin: 0;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.file-status {
    font-size: 0.8rem;
    color: #4ade80;
}

/* Chat & Generate */
.chat-container {
    height: 500px;
    display: flex;
    flex-direction: column;
}

.chat-history {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.ai-message {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 12px 12px 12px 0;
    max-width: 80%;
    margin-bottom: 15px;
    line-height: 1.5;
}

.chat-input-area {
    padding: 20px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-input-area textarea {
    height: 80px;
    resize: none;
}

.btn-primary-lg {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.2s;
}

.btn-primary-lg:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

/* Modal */
.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;
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: 90%;
    height: 90%;
    display: flex;
    flex-direction: column;
    background: #1e293b;
}

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

.modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--glass-border);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 15px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

.tab-content {
    display: none;
    flex: 1;
    position: relative;
}

.tab-content.active {
    display: block;
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

#result-code {
    width: 100%;
    height: 100%;
    background: #0f172a;
    color: #cbd5e1;
    padding: 20px;
    font-family: monospace;
    border: none;
}

.btn-copy {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
}

/* Premium Loader */
.loading-container {
    margin-top: 30px;
    padding: 30px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s ease;
}

.loading-container.hidden {
    display: none;
}

.loader-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.spinner-premium {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(139, 92, 246, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
}

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

    100% {
        transform: rotate(360deg);
    }
}

.loader-text h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-main);
    font-weight: 600;
}

/* Button Group */
.button-group {
    display: flex;
    gap: 15px;
    align-items: stretch;
    /* Ensure buttons are same height */
    justify-content: flex-end;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-main);
    padding: 16px 24px;
    /* Adjust padding for height match */
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    /* min-height removed, rely on stretch */
    white-space: nowrap;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.btn-secondary:active {
    transform: translateY(0);
}