:root {
    /* App Generator UI Variables - Independent of Portfolio Theme */
    --app-bg: #f8fafc;
    --app-surface: #ffffff;
    --app-border: #e2e8f0;
    --app-text: #0f172a;
    --app-text-muted: #64748b;
    --app-primary: #3b82f6;
    --app-primary-hover: #2563eb;
    
    --transition: 0.3s ease;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    
    --font-ui: 'Inter', sans-serif;
}

[data-theme="dark"] {
    --app-bg: #09090b;
    --app-surface: #18181b;
    --app-border: #27272a;
    --app-text: #f8fafc;
    --app-text-muted: #a1a1aa;
    --app-primary: #3b82f6;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.6);
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--app-bg);
    color: var(--app-text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar Config Panel */
.config-panel {
    width: 320px;
    background: var(--app-surface);
    border-right: 1px solid var(--app-border);
    display: flex;
    flex-direction: column;
    z-index: 10;
    flex-shrink: 0;
    overflow-y: auto;
}

.panel-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--app-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--app-text);
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--app-border);
    color: var(--app-text-muted);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.icon-btn:hover {
    background: var(--app-border);
    color: var(--app-text);
}
.icon-btn.active {
    background: var(--app-primary);
    color: white;
    border-color: var(--app-primary);
}

.config-section {
    padding: 1.5rem;
    border-bottom: 1px solid var(--app-border);
}

.config-section h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--app-text-muted);
    margin-bottom: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--app-text);
}

input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--app-border);
    background: var(--app-bg);
    color: var(--app-text);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    border-color: var(--app-primary);
}

.input-with-button {
    display: flex;
    gap: 0.5rem;
}
.input-with-button input { flex: 1; }

.btn {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.btn.primary {
    background: var(--app-primary);
    color: white;
}
.btn.primary:hover {
    background: var(--app-primary-hover);
}
.btn.outline {
    background: transparent;
    border: 1px solid var(--app-border);
    color: var(--app-text);
}
.btn.outline:hover {
    background: var(--app-border);
}
.w-full { width: 100%; }
.mt-3 { margin-top: 1rem; }

#fetch-status {
    font-size: 0.8rem;
    margin-top: 0.5rem;
    color: var(--app-text-muted);
}
#fetch-status.error { color: #ef4444; }
#fetch-status.success { color: #10b981; }

/* Theme Selector */
.theme-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.theme-option {
    cursor: pointer;
}
.theme-option input { display: none; }

.theme-card {
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 2px solid var(--app-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
}

.theme-option input:checked + .theme-card {
    border-color: var(--app-primary);
    background: rgba(59, 130, 246, 0.05);
}

.theme-colors {
    display: flex;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--app-border);
}
.theme-colors span {
    width: 16px;
    height: 16px;
    display: block;
}

.theme-card span {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--app-text);
}

.accent-options {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--swatch-color);
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s;
    padding: 0;
}
.color-swatch.active {
    border-color: var(--app-text);
    transform: scale(1.1);
}

.config-actions {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: auto;
}

/* Preview Area */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--app-bg);
    position: relative;
}

.preview-header {
    height: 60px;
    border-bottom: 1px solid var(--app-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    background: var(--app-surface);
}

.preview-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--app-text-muted);
}

.preview-controls {
    display: flex;
    gap: 0.5rem;
}

.preview-container {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    transition: padding 0.3s;
}

.preview-container.mobile {
    padding: 2rem 0;
}

.portfolio-wrapper {
    width: 100%;
    max-width: 1200px;
    min-height: 800px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    position: relative;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Set default portfolio CSS variables that get overriden */
    --accent-color: #3b82f6; 
}

.preview-container.mobile .portfolio-wrapper {
    width: 375px; /* Mobile width */
}

/* 
==================================================
   PORTFOLIO PREVIEW STYLES (Injected Sandbox Look)
================================================== 
*/

/* 
 * The following styles are scoped inside `.portfolio-wrapper`.
 * This acts like a mini "reset" and applies the selected theme's variables.
 */

.portfolio-wrapper {
    font-family: 'Space Grotesk', sans-serif;
    line-height: 1.6;
}

/* Themes Definition */
.portfolio-wrapper.theme-light {
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --border-color: #e5e7eb;
}

.portfolio-wrapper.theme-dark {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
}

.portfolio-wrapper.theme-hacker {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --text-primary: #a3a3a3;
    --text-secondary: #737373;
    --border-color: #262626;
    font-family: 'Courier New', Courier, monospace;
}

/* Inner App Structure */
.p-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Empty State */
.portfolio-content.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 800px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.empty-state h2 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

/* Navigation */
.p-nav {
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    background: rgba(var(--bg-primary-rgb), 0.9);
    backdrop-filter: blur(8px);
    z-index: 50;
    border-bottom: 1px solid var(--border-color);
}

.nav-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.p-logo {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--accent-color);
    letter-spacing: -0.5px;
}

.p-nav-links {
    list-style: none;
    display: flex;
    gap: 2rem;
}

.p-nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
    font-weight: 500;
}

.p-nav-links a:hover {
    color: var(--accent-color);
}

/* Buttons */
.p-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.p-btn.primary {
    background: var(--accent-color);
    color: #fff;
    border: 1px solid var(--accent-color);
}
.p-btn.primary:hover {
    filter: brightness(1.1);
}

.p-btn.outline {
    background: transparent;
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
}
.p-btn.outline:hover {
    background: rgba(147, 197, 253, 0.1); /* fallback light bg */
}

/* Hero Section */
.p-hero {
    min-height: calc(100vh - 80px); /* Fill screen minus nav */
    display: flex;
    align-items: center;
    padding: 4rem 0;
}

.hero-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4rem;
}

.hero-content {
    flex: 1;
}

.greeting {
    color: var(--accent-color);
    font-weight: 500;
    margin-bottom: 1rem;
}

.hero-name {
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

.hero-role {
    font-size: clamp(2rem, 4vw, 3.5rem);
    font-weight: 700;
    color: var(--text-secondary);
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.hero-bio {
    color: var(--text-secondary);
    max-width: 540px;
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
}

.hero-actions {
    display: flex;
    gap: 1rem;
}

.hero-image {
    position: relative;
    width: 300px;
    height: 300px;
    border-radius: var(--radius-lg);
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-lg);
    position: relative;
    z-index: 2;
    background: var(--bg-secondary);
}

.hero-backdrop {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 100%;
    height: 100%;
    border: 2px solid var(--accent-color);
    border-radius: var(--radius-lg);
    z-index: 1;
    transition: top 0.2s, left 0.2s;
}

.hero-image:hover .hero-backdrop {
    top: 15px;
    left: 15px;
}

/* Sections */
.p-section {
    padding: 6rem 0;
}

.section-title {
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 3rem;
    white-space: nowrap;
}

.section-title span {
    color: var(--accent-color);
    font-family: monospace;
    font-size: 1.25rem;
    margin-right: 0.5rem;
    font-weight: 400;
}

.section-title.center {
    justify-content: center;
}

.section-title::after {
    content: "";
    display: block;
    width: 100%;
    height: 1px;
    background: var(--border-color);
    margin-left: 1.5rem;
}
.section-title.center::after { display: none; }

/* Skills Grid */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.skill-tag {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
    transition: transform 0.2s;
}
.skill-tag:hover {
    transform: translateY(-2px);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

/* Projects */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s;
}
.project-card:hover { transform: translateY(-4px); }

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

.project-folder i {
    font-size: 2.5rem;
    color: var(--accent-color);
}

.project-links a {
    color: var(--text-secondary);
    font-size: 1.25rem;
    margin-left: 1rem;
    transition: color 0.2s;
}
.project-links a:hover { color: var(--accent-color); }

.project-title {
    color: var(--text-primary);
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.project-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.project-tech {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Contact */
.text-center { text-align: center; }
.contact-heading {
    font-size: clamp(2rem, 4vw, 3rem);
    color: var(--text-primary);
    margin-bottom: 1rem;
}
.contact-desc {
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 2rem;
    font-size: 1.1rem;
}

/* Footer */
.p-footer {
    padding: 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.p-footer p {
    color: var(--text-secondary);
    font-family: monospace;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}
.social-links a {
    color: var(--text-secondary);
    font-size: 1.2rem;
    transition: color 0.2s;
}
.social-links a:hover {
    color: var(--accent-color);
}

/* Media Queries for Preview */
@media (max-width: 768px) {
    .hero-inner {
        flex-direction: column-reverse;
        text-align: center;
        gap: 2rem;
    }
    .hero-bio {
        margin: 0.5rem auto 2rem;
    }
    .hero-actions {
        justify-content: center;
    }
    .p-nav-links {
        display: none; /* simple mobile nav */
    }
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
    transform: translateY(20px);
    transition: transform var(--transition);
}

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

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-body p { margin-bottom: 1rem; color: var(--app-text); font-size: 0.95rem; }

.modal-actions {
    padding: 1.5rem;
    border-top: 1px solid var(--app-border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Code Modal Specific */
.code-tabs {
    display: flex;
    border-bottom: 1px solid var(--app-border);
    margin-bottom: 1rem;
}
.tab-btn {
    background: none;
    border: none;
    color: var(--app-text-muted);
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
    border-bottom: 2px solid transparent;
}
.tab-btn.active {
    color: var(--app-primary);
    border-bottom-color: var(--app-primary);
}

.code-area {
    width: 100%;
    height: 300px;
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: monospace;
    font-size: 0.85rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    border: none;
    resize: none;
    outline: none;
    display: none;
}
.code-area.active {
    display: block;
}

/* Deployment Guide Specific */
.deployment-guide h3 {
    margin: 1.5rem 0 0.5rem;
    color: var(--app-primary);
    font-size: 1.1rem;
}
.deployment-guide h3:first-child { margin-top: 0; }
.deployment-guide ol {
    margin-left: 1.5rem;
    color: var(--app-text);
    font-size: 0.95rem;
}
.deployment-guide li { margin-bottom: 0.5rem; }
.deployment-guide code {
    background: var(--app-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 2000;
    pointer-events: none;
}
.toast {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    color: var(--app-text);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.show { transform: translateX(0); }
.toast.error i { color: #ef4444; }
.toast.success i { color: #10b981; }

@media (max-width: 900px) {
    .app-container { flex-direction: column; }
    .config-panel { width: 100%; height: 50vh; border-right: none; border-bottom: 2px solid var(--app-border); }
}
