:root {
    --primary: #6C5CE7;
    --primary-hover: #5b4bc4;
    --secondary: #A29BFE;
    --accent: #FD79A8;
    --bg-base: #0D0A19;
    --bg-panel: #1A162D;
    --border: rgba(108, 92, 231, 0.2);
    --text-main: #FFFFFF;
    --text-muted: #9CA3AF;
    --radius: 12px;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.hidden { display: none !important; }

/* Header */
.app-header {
    height: 70px;
    background: rgba(13, 10, 25, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--secondary);
}

.header-actions { display: flex; gap: 16px; }

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary { background: rgba(255,255,255,0.05); color: var(--text-main); border: 1px solid rgba(255,255,255,0.1); }
.btn-secondary:hover { background: rgba(255,255,255,0.1); }

/* Layout */
.app-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 380px;
    background: var(--bg-panel);
    border-right: 1px solid rgba(255,255,255,0.05);
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.control-group h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--secondary);
    margin-bottom: 16px;
    font-weight: 700;
}

.input-wrap { margin-bottom: 16px; }
.input-wrap label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; font-weight: 500;}
.input-wrap input, .input-wrap select, .input-wrap textarea {
    width: 100%;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 12px;
    border-radius: 8px;
    font-family: inherit;
    transition: border-color 0.2s;
}
.input-wrap input:focus, .input-wrap select:focus, .input-wrap textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.toggle-group { display: flex; gap: 8px; background: rgba(0,0,0,0.2); padding: 4px; border-radius: 8px; }
.toggle-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.toggle-btn.active { background: rgba(255,255,255,0.1); color: white; }

.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.template-card {
    background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px; padding: 12px; cursor: pointer; text-align: center;
    font-size: 0.85rem; color: var(--text-muted); transition: all 0.2s;
}
.template-card.active { border-color: var(--primary); background: rgba(108, 92, 231, 0.1); color: white; }

.gradient-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.grad-option {
    width: 40px; height: 40px; border-radius: 50%; cursor: pointer; border: 2px solid transparent;
    transition: transform 0.2s;
}
.grad-option:hover { transform: scale(1.1); }
.grad-option.active { border-color: white; transform: scale(1.1); }

/* Gradients definition */
.grad-1 { background: linear-gradient(135deg, #FF6B6B 0%, #556270 100%); }
.grad-2 { background: linear-gradient(135deg, #00C9FF 0%, #92FE9D 100%); }
.grad-3 { background: linear-gradient(135deg, #6C5CE7 0%, #FD79A8 100%); }
.grad-4 { background: linear-gradient(135deg, #1A2980 0%, #26D0CE 100%); }
.grad-5 { background: linear-gradient(135deg, #FF416C 0%, #FF4B2B 100%); }
.grad-6 { background: #1A162D; } /* Solid Dark */

/* Canvas Area */
.canvas-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0, rgba(255,255,255,0.02) 2px, transparent 2px, transparent 10px);
    overflow: auto;
}

.canvas-wrapper {
    /* To scale down visually if window is small, but keep exact dimensions for html2canvas */
    width: 1200px;
    height: 630px;
    transform-origin: center center;
    /* We will use js to set scale so it fits on screen */
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    border-radius: 0; /* OG images don't have border radius in final render usually */
    position: relative;
    overflow: hidden;
    background: #111;
}

/* 1200x630 OG Image Canvas */
.og-canvas {
    width: 1200px;
    height: 630px;
    position: absolute;
    top: 0; left: 0;
    display: flex;
    flex-direction: column;
    color: white;
    padding: 80px;
}

/* Light Theme Override */
.og-canvas.theme-light {
    color: #1a1a1a;
}
.og-canvas.theme-light .og-subtitle { color: #4a4a4a; }
.og-canvas.theme-light .og-brand { color: #666; }

/* Sub elements */
.og-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.og-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: auto;
}

.og-icon { font-size: 48px; }
.og-brand { font-size: 32px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: rgba(255,255,255,0.8); }

.og-main { margin: auto 0; }

.og-title {
    font-size: 80px;
    line-height: 1.1;
    font-weight: 800;
    margin-bottom: 24px;
    max-width: 1000px;
}

.og-subtitle {
    font-size: 36px;
    line-height: 1.4;
    color: rgba(255,255,255,0.8);
    font-weight: 400;
    max-width: 900px;
}

.og-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
}

.og-custom-logo {
    max-height: 60px;
    max-width: 250px;
    object-fit: contain;
}

/* Template 1: Blog Post (Default) */
.og-canvas.template-blog .og-content {
    justify-content: space-between;
}

/* Template 2: Centered (Product Launch) */
.og-canvas.template-centered {
    align-items: center;
    text-align: center;
}
.og-canvas.template-centered .og-header { margin-bottom: 40px; margin-top: 0; }
.og-canvas.template-centered .og-main { margin: 0; }
.og-canvas.template-centered .og-footer { margin-top: 40px; }

/* Template 3: Split (Event) */
.og-canvas.template-split {
    padding: 0;
    flex-direction: row;
}
.og-canvas.template-split .og-content {
    flex: 1;
    padding: 80px;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(20px);
}
.og-canvas.theme-light.template-split .og-content {
    background: rgba(255,255,255,0.7);
}

.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #00b894;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    animation: slideUp 0.3s ease-out forwards;
    z-index: 100;
}
@keyframes slideUp { from { opacity:0; transform: translateY(20px); } to { opacity:1; transform: translateY(0); } }

/* Scale wrapper logic on resize */
@media (max-width: 1650px) { .canvas-wrapper { transform: scale(0.7); } }
@media (max-width: 1300px) { .canvas-wrapper { transform: scale(0.5); } }
@media (max-width: 900px) { .app-layout { flex-direction: column; overflow: auto; } .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); } .canvas-area { min-height: 500px; } }
@media (max-width: 600px) { .canvas-wrapper { transform: scale(0.3); } }
