/* Modern Professional Overhaul for BuildVerse v0.7 */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-app: #fcfcfd;
    --bg-sidebar: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --accent-game: #ec4899;
    --accent-app: #0ea5e9;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

body.dark-theme {
    --bg-app: #0b0f1a;
    --bg-sidebar: #111827;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border-color: #1f2937;
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.container {
    display: flex;
    height: 100%;
    width: 100%;
}

/* Sidebar Overhaul */
.sidebar {
    width: 380px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 24px;
    overflow-y: auto;
    z-index: 10;
}

.workspace-title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-badge {
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.mode-game .mode-badge { background: #fdf2f8; color: #db2777; }
.mode-app .mode-badge { background: #f0f9ff; color: #0284c7; }

.switch-container input:checked {
    accent-color: var(--primary);
}

/* Buttons & Inputs */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn-secondary {
    background: var(--bg-sidebar);
    border-color: var(--border-color);
    color: var(--text-main);
}
.btn-secondary:hover { background: var(--bg-app); }

.prompt-input {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-app);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    transition: border-color 0.2s;
}
.prompt-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Main Content Area */
.game-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000; /* Backdrop for IFRAMEs */
    position: relative;
}

.game-header {
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.game-iframe {
    flex: 1;
    border: none;
    background: #fff;
}

/* Versions / Project Cards */
.version-item {
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.version-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}
.version-item.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.03);
}

/* App Store Modern Grid */
.store-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding: 24px;
}

.store-card {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}
.store-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

/* Generating Overlay - High End */
.generating-overlay {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
}
body.dark-theme .generating-overlay { background: rgba(11, 15, 26, 0.85); }

/* Integrations Section */
.integrations-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.integration-chip {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.integration-chip input { cursor: pointer; }

/* Responsive Adjustments */
@media (max-width: 1024px) {
    .sidebar { width: 320px; }
}

@media (max-width: 768px) {
    .container { flex-direction: column; }
    .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border-color); }
}

/* Custom UI for App vs Game */
.mode-app .sidebar { border-left: 4px solid var(--accent-app); }
.mode-game .sidebar { border-left: 4px solid var(--accent-game); }

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-sidebar);
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
}

.patch-item {
    margin-bottom: 24px;
}
.patch-tag {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--primary);
    color: white;
    margin-bottom: 8px;
    display: inline-block;
}
.patch-item h3 {
    font-size: 16px;
    margin-bottom: 4px;
}
.patch-item p {
    font-size: 14px;
    color: var(--text-muted);
}