/* 🎨 Autobot App Builder - Premium Dark Glassmorphism Styling */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
    --bg-color: #080c14;
    --card-bg: rgba(17, 24, 39, 0.65);
    --card-border: rgba(255, 255, 255, 0.08);
    --border-color: rgba(255, 255, 255, 0.1);
    
    /* Neon Accents */
    --accent-cyan: #06b6d4;
    --accent-cyan-glow: rgba(6, 182, 212, 0.4);
    --accent-purple: #a855f7;
    --accent-purple-glow: rgba(168, 85, 247, 0.4);
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.4);
    --accent-rose: #f43f5e;
    --accent-rose-glow: rgba(244, 63, 94, 0.4);
    
    /* Text colors */
    --text-primary: #f3f4f6;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    /* Active dynamic theme variable */
    --theme-color: var(--accent-cyan);
    --theme-glow: var(--accent-cyan-glow);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Inter', 'Sarabun', sans-serif;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(168, 85, 247, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.15) 0%, transparent 40%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* 🧭 Navigation Bar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    background: rgba(8, 12, 20, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: -0.5px;
}

.logo-icon {
    width: 2.2rem;
    height: 2.2rem;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.3);
}

.logo-icon svg {
    width: 1.4rem;
    height: 1.4rem;
    fill: #fff;
}

.logo span {
    background: linear-gradient(135deg, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--card-border);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-emerald);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-emerald);
    animation: pulse 2s infinite;
}

/* 🖥️ Dashboard Layout */
.dashboard-container {
    max-width: 1600px;
    margin: 2rem auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 2rem;
    align-items: start;
}

/* 🎛️ Control Panel (Left Column) */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
}

.card-title svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: var(--theme-color);
}

/* Generator Form elements */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.prompt-textarea {
    width: 100%;
    height: 120px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    color: #fff;
    font-size: 0.9rem;
    resize: none;
    transition: all 0.3s ease;
}

.prompt-textarea:focus {
    outline: none;
    border-color: var(--theme-color);
    box-shadow: 0 0 10px var(--theme-glow);
}

/* Theme selector buttons */
.theme-selector {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.theme-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
}

.theme-btn:hover {
    transform: scale(1.15);
}

.theme-btn.active {
    border-color: #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.theme-cyan { background-color: var(--accent-cyan); }
.theme-purple { background-color: var(--accent-purple); }
.theme-emerald { background-color: var(--accent-emerald); }
.theme-rose { background-color: var(--accent-rose); }

/* Option Slider */
.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.slider-container input[type="range"] {
    flex: 1;
    accent-color: var(--theme-color);
}

.slider-value {
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    min-width: 35px;
    text-align: center;
}

/* Neon pulsing button */
.btn-generate {
    width: 100%;
    background: linear-gradient(135deg, var(--theme-color), var(--accent-purple));
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0.9rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--theme-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--theme-glow), 0 0 10px var(--accent-purple-glow);
}

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

.btn-generate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 📁 Template Library */
.template-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.template-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.template-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--theme-color);
    transform: translateY(-2px);
}

.template-icon {
    font-size: 1.25rem;
}

.template-card h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
}

.template-card p {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* 🖥️ Preview / Editor Center (Right Column) */
.preview-center {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: calc(100vh - 120px);
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Tab Switcher */
.tabs-container {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem;
    border-radius: 10px;
    border: 1px solid var(--card-border);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tab-btn.active {
    background: var(--card-border);
    color: #fff;
}

/* Editor / Preview Body */
.workspace-wrapper {
    flex: 1;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--theme-color);
    box-shadow: 0 0 20px var(--theme-glow);
    background: #000;
}

.workspace-tab {
    display: none;
    width: 100%;
    height: 100%;
}

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

/* Live Iframe */
.preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background-color: #fff;
}

/* Code Editor Window */
.code-editor-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.code-textarea {
    width: 100%;
    height: 100%;
    background: #0e131f;
    color: #38bdf8;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    padding: 1.5rem;
    border: none;
    resize: none;
    line-height: 1.5;
    outline: none;
}

/* Action controls bottom */
.workspace-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.status-indicator {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.status-indicator-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.status-indicator-dot.active {
    background-color: var(--theme-color);
    box-shadow: 0 0 6px var(--theme-color);
}

.action-buttons {
    display: flex;
    gap: 0.75rem;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: var(--theme-color);
}

.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary-action {
    background: var(--theme-color);
    border: none;
    color: #fff;
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 10px var(--theme-glow);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-primary-action:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--theme-color), var(--accent-purple));
    box-shadow: 0 6px 15px var(--theme-glow);
}

.btn-primary-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* 🌀 Pulse & Loading Keyframes */
@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.loading-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 12, 20, 0.9);
    backdrop-filter: blur(8px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    z-index: 10;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    border-top-color: var(--theme-color);
    border-bottom-color: var(--accent-purple);
    animation: spin 1s linear infinite;
    box-shadow: 0 0 15px var(--theme-glow);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1rem;
    color: #fff;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

/* ☁️ Cloudflare Deployment Simulator Popup */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-card {
    background: #0f172a;
    border: 1px solid var(--theme-color);
    border-radius: 20px;
    width: 500px;
    padding: 2rem;
    box-shadow: 0 10px 40px var(--theme-glow);
    animation: modalSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    font-size: 1.25rem;
    color: #fff;
    font-weight: 600;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-modal:hover {
    color: #fff;
}

.deploy-step {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
    opacity: 0.4;
    transition: opacity 0.3s;
}

.deploy-step.active {
    opacity: 1;
}

.step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.deploy-step.active .step-num {
    background: var(--theme-color);
    color: #fff;
    border-color: var(--theme-color);
    box-shadow: 0 0 8px var(--theme-color);
}

.deploy-step.completed .step-num {
    background: var(--accent-emerald);
    color: #fff;
    border-color: var(--accent-emerald);
}

.step-details h4 {
    font-size: 0.9rem;
    color: #fff;
    margin-bottom: 0.25rem;
}

.step-details p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.deploy-success-box {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid var(--accent-emerald);
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
    margin-top: 1.5rem;
    display: none;
}

.deploy-url {
    background: rgba(0, 0, 0, 0.4);
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--accent-cyan);
    margin: 0.75rem 0;
    word-break: break-all;
    display: block;
    text-decoration: none;
}

.deploy-url:hover {
    text-decoration: underline;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .dashboard-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    .preview-center {
        height: 600px;
    }
}

/* 📱 Phone Bezel Simulator Upgrade */
.phone-bezel-hidden {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.phone-bezel-active {
    width: 375px;
    height: 680px;
    border: 12px solid #1e293b;
    border-radius: 36px;
    box-shadow: 0 0 0 4px #475569, 0 25px 50px -12px rgba(0,0,0,0.5), 0 0 25px var(--theme-color);
    background: #000;
    overflow: hidden;
    padding-top: 10px; /* space for notch */
}

.phone-bezel-active .phone-screen-notch {
    display: block !important;
}

