@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;600;700;800;900&family=Playfair+Display:wght@400;700;900&family=Roboto:wght@300;400;500;700&family=Oswald:wght@400;500;600;700&family=Poppins:wght@300;400;500;600;700;800&family=Bebas+Neue:wght@400;700&family=Raleway:wght@300;400;600;700;800&display=swap');

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-card: #1e1e36;
    --accent: #6c63ff;
    --accent-hover: #5a52d5;
    --accent-glow: rgba(108, 99, 255, 0.3);
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b80;
    --border: #2a2a45;
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #f87171;
    --gradient-1: linear-gradient(135deg, #6c63ff, #e91e63);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.4);
    --shadow-md: 0 8px 30px rgba(0,0,0,0.3);
    --shadow-sm: 0 4px 15px rgba(0,0,0,0.2);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

.header {
    background: var(--bg-secondary); border-bottom: 1px solid var(--border);
    padding: 16px 40px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 100; backdrop-filter: blur(20px);
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
    width: 42px; height: 42px; background: var(--gradient-1);
    border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
    font-size: 20px; box-shadow: 0 4px 15px var(--accent-glow);
}
.logo-text {
    font-family: 'Bebas Neue', sans-serif; font-size: 28px; letter-spacing: 2px;
    background: var(--gradient-1); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.header-actions { display: flex; gap: 12px; }
.btn {
    padding: 10px 24px; border: none; border-radius: var(--radius-sm);
    font-family: 'Poppins', sans-serif; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.3s ease; display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary { background: var(--gradient-1); color: white; box-shadow: 0 4px 15px var(--accent-glow); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 25px var(--accent-glow); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); transform: translateY(-1px); }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); color: white; box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3); }
.btn-success:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; }
.btn-danger:hover { transform: translateY(-2px); }
.btn-sm { padding: 8px 16px; font-size: 12px; }

.main-container { display: grid; grid-template-columns: 420px 1fr; min-height: calc(100vh - 74px); }
.sidebar {
    background: var(--bg-secondary); border-right: 1px solid var(--border);
    overflow-y: auto; max-height: calc(100vh - 74px);
}
.sidebar-section { padding: 24px; border-bottom: 1px solid var(--border); }
.sidebar-section:last-child { border-bottom: none; }
.section-title {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 2px; color: var(--text-muted); margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
}
.section-title .icon { font-size: 16px; }
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 10px 14px; background: var(--bg-primary);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-primary); font-family: 'Poppins', sans-serif;
    font-size: 14px; transition: all 0.3s ease;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-select {
    cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0a0b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    padding-right: 36px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.color-picker-group { display: flex; align-items: center; gap: 10px; }
.color-picker-wrapper {
    position: relative; width: 40px; height: 40px; border-radius: var(--radius-sm);
    overflow: hidden; border: 2px solid var(--border); flex-shrink: 0; cursor: pointer;
}
.color-picker-wrapper input[type="color"] {
    position: absolute; top: -8px; left: -8px; width: 56px; height: 56px;
    border: none; cursor: pointer; padding: 0;
}
.color-hex { flex: 1; }
.color-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.color-preset {
    width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
    border: 2px solid transparent; transition: all 0.2s ease;
}
.color-preset:hover { transform: scale(1.15); border-color: white; }
.color-preset.active { border-color: white; box-shadow: 0 0 10px rgba(255,255,255,0.3); }
.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.template-card {
    background: var(--bg-primary); border: 2px solid var(--border);
    border-radius: var(--radius-sm); padding: 14px; cursor: pointer;
    transition: all 0.3s ease; text-align: center;
}
.template-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.template-card.active {
    border-color: var(--accent); background: rgba(108, 99, 255, 0.1);
    box-shadow: 0 0 20px var(--accent-glow);
}
.template-card .template-icon { font-size: 28px; margin-bottom: 6px; }
.template-card .template-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.template-card .template-desc { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.range-group { display: flex; align-items: center; gap: 12px; }
.range-group input[type="range"] {
    flex: 1; -webkit-appearance: none; height: 6px; border-radius: 3px;
    background: var(--border); outline: none;
}
.range-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
    background: var(--accent); cursor: pointer; box-shadow: 0 2px 8px var(--accent-glow);
}
.range-value { font-size: 13px; font-weight: 600; color: var(--accent); min-width: 40px; text-align: right; }
.toggle-group { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.toggle { position: relative; width: 44px; height: 24px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border); border-radius: 12px; transition: 0.3s;
}
.toggle-slider::before {
    content: ''; position: absolute; width: 18px; height: 18px;
    left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }
.preview-area {
    background: var(--bg-primary); display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 40px;
    position: relative; overflow: auto;
}
.preview-area::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at 20% 20%, rgba(108, 99, 255, 0.05) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(233, 30, 99, 0.05) 0%, transparent 50%);
    pointer-events: none;
}
.preview-toolbar {
    position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 8px; z-index: 10; background: var(--bg-secondary);
    padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}
.preview-size-btn {
    padding: 6px 14px; background: transparent; border: 1px solid transparent;
    border-radius: 6px; color: var(--text-secondary); font-family: 'Poppins', sans-serif;
    font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.preview-size-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.preview-size-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.preview-container {
    position: relative; z-index: 1; margin-top: 20px;
    display: flex; justify-content: center; align-items: center;
}
.poster-canvas {
    background: white; box-shadow: var(--shadow-lg); position: relative;
    overflow: hidden; transition: width 0.3s, height 0.3s;
}
.poster-content {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 40px; text-align: center;
}
.poster-style-gradient-bg { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
.poster-badge {
    position: absolute; padding: 6px 16px; border-radius: 20px;
    font-weight: 700; font-size: 14px; text-transform: uppercase;
    letter-spacing: 1px; z-index: 5;
}
.poster-logo-area {
    width: 80px; height: 80px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; margin-bottom: 20px;
    position: relative; z-index: 2; font-size: 32px; font-weight: 900;
    color: white; box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.poster-company-name { font-weight: 800; letter-spacing: 3px; text-transform: uppercase; margin-bottom: 8px; position: relative; z-index: 2; }
.poster-tagline { font-size: 14px; opacity: 0.8; margin-bottom: 30px; position: relative; z-index: 2; }
.poster-headline { font-weight: 900; text-transform: uppercase; line-height: 1.1; margin-bottom: 16px; position: relative; z-index: 2; }
.poster-subheadline { font-size: 16px; opacity: 0.85; margin-bottom: 24px; position: relative; z-index: 2; line-height: 1.6; }
.poster-body { font-size: 14px; opacity: 0.75; line-height: 1.7; margin-bottom: 24px; position: relative; z-index: 2; max-width: 80%; }
.poster-cta {
    padding: 14px 40px; border-radius: 50px; font-weight: 700;
    font-size: 16px; text-transform: uppercase; letter-spacing: 2px;
    position: relative; z-index: 2; box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.poster-price { font-weight: 900; position: relative; z-index: 2; }
.poster-price .original { text-decoration: line-through; opacity: 0.5; font-size: 0.6em; }
.poster-price .current { font-size: 1.5em; }
.poster-divider { width: 60px; height: 4px; border-radius: 2px; margin: 16px 0; position: relative; z-index: 2; }
.poster-footer {
    position: absolute; bottom: 20px; left: 0; right: 0; display: flex;
    justify-content: center; gap: 20px; font-size: 12px; opacity: 0.6; z-index: 2;
}
.poster-date-badge {
    padding: 10px 24px; border-radius: var(--radius-sm); position: relative;
    z-index: 2; margin: 10px 0;
}
.deco-circle { position: absolute; border-radius: 50%; border: 2px solid rgba(255,255,255,0.1); }
.deco-dots { position: absolute; display: grid; grid-template-columns: repeat(5, 8px); gap: 12px; }
.deco-dot { width: 4px; height: 4px; border-radius: 50%; background: rgba(255,255,255,0.15); }
.deco-lines { position: absolute; width: 100%; height: 100%; overflow: hidden; }
.deco-line { position: absolute; height: 1px; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent); }

/* New Decoration Styles */
.deco-icon { position: absolute; opacity: 0.1; z-index: 1; }
.deco-icon svg { width: 100%; height: 100%; fill: currentColor; }
.deco-coffee-ring {
    position: absolute; border-radius: 50%; border: 3px dashed rgba(255,255,255,0.1);
    z-index: 1;
}
.deco-steam {
    position: absolute; width: 40px; height: 40px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.1); border-top-color: transparent;
    transform: rotate(45deg); z-index: 1;
}
.deco-grid {
    position: absolute; width: 100%; height: 100%;
    background-image: radial-gradient(rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 20px 20px; z-index: 1;
}

.upload-area {
    border: 2px dashed var(--border); border-radius: var(--radius-sm);
    padding: 20px; text-align: center; cursor: pointer; transition: all 0.3s;
    background: var(--bg-primary);
}
.upload-area:hover { border-color: var(--accent); background: rgba(108, 99, 255, 0.05); }
.upload-area .upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-area .upload-text { font-size: 13px; color: var(--text-secondary); }
.upload-area .upload-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg-primary); border-radius: var(--radius-sm); margin-bottom: 16px; }
.tab {
    flex: 1; padding: 8px 12px; text-align: center; font-size: 12px;
    font-weight: 600; color: var(--text-muted); border-radius: 6px;
    cursor: pointer; transition: all 0.2s; border: none; background: none;
    font-family: 'Poppins', sans-serif;
}
.tab:hover { color: var(--text-secondary); }
.tab.active { background: var(--accent); color: white; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.toast {
    position: fixed; bottom: 30px; right: 30px; padding: 14px 24px;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg);
    z-index: 1000; display: flex; align-items: center; gap: 10px;
    transform: translateY(100px); opacity: 0; transition: all 0.4s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.gradient-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.gradient-preset {
    height: 36px; border-radius: 6px; cursor: pointer; border: 2px solid transparent;
    transition: all 0.2s; position: relative;
}
.gradient-preset:hover { transform: scale(1.05); border-color: white; }
.gradient-preset.active { border-color: white; box-shadow: 0 0 10px rgba(255,255,255,0.2); }
.gradient-preset .preset-label {
    position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%);
    font-size: 9px; color: var(--text-muted); white-space: nowrap; pointer-events: none;
}
.info-box {
    background: rgba(108, 99, 255, 0.1); border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: var(--radius-sm); padding: 12px 16px; font-size: 12px;
    color: var(--text-secondary); line-height: 1.6; margin-top: 12px;
}
.info-box strong { color: var(--accent); }
.mode-toggle { display: flex; gap: 4px; margin-bottom: 12px; background: var(--bg-primary); border-radius: var(--radius-sm); padding: 3px; }
.mode-btn {
    flex: 1; padding: 6px 12px; border: none; border-radius: 6px;
    font-family: 'Poppins', sans-serif; font-size: 11px; font-weight: 600;
    cursor: pointer; transition: all 0.2s; background: transparent;
    color: var(--text-muted);
}
.mode-btn.active { background: var(--accent); color: white; }
.mode-btn:hover:not(.active) { color: var(--text-primary); }
.size-option {
    padding: 12px; background: var(--bg-primary); border: 2px solid var(--border);
    border-radius: var(--radius-sm); cursor: pointer; text-align: center;
    transition: all 0.2s;
}
.size-option:hover { border-color: var(--accent); transform: translateY(-2px); }
.size-option.active { border-color: var(--accent); background: rgba(108, 99, 255, 0.1); box-shadow: 0 0 10px var(--accent-glow); }
.size-option .size-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.size-option .size-dims { font-size: 11px; color: var(--text-muted); }
.section-divider { width: 100%; height: 1px; background: var(--border); margin: 12px 0; }
.section-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 8px; margin-top: 8px; }
.loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 15, 26, 0.8); display: none; align-items: center;
    justify-content: center; z-index: 999; backdrop-filter: blur(4px);
}
.loading-overlay.show { display: flex; }
.spinner {
    width: 40px; height: 40px; border: 4px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1024px) {
    .main-container { grid-template-columns: 1fr; }
    .sidebar { max-height: none; border-right: none; border-bottom: 1px solid var(--border); }
    .preview-area { padding: 20px; min-height: 600px; }
}

/* Image Controls */
.image-control-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
}
.image-control-card .range-group {
    margin-bottom: 6px;
}
.image-control-card .range-group span:first-child {
    width: 60px;
    font-size: 11px;
    color: var(--text-muted);
}
.image-control-card .range-group input[type="range"] {
    flex: 1;
}
.image-control-card .range-group .range-value {
    font-size: 11px;
    min-width: 35px;
}

/* Image Wrapping & Canvas Placement */
.poster-image-wrapper {
    position: absolute;
    shape-outside: url('');
    shape-margin: 15px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    z-index: 10;
}
.poster-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none; /* Prevents interference with html2canvas */
}
/* Ensure text content flows around images */
.poster-content {
    position: relative;
    z-index: 1;
    /* shape-outside works on the image, text container needs standard flow */
}

