/* ══════════════════════════════════════════════════════════════
   Open Graph Image Maker — Premium Dark Editor Styles
   ══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Playfair+Display:wght@400;600;700;900&family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    --primary: #8B5CF6;
    --primary-light: #A78BFA;
    --primary-dim: rgba(139, 92, 246, 0.15);
    --accent: #F43F5E;
    --accent-light: #FB7185;
    --accent-dim: rgba(244, 63, 94, 0.15);
    --cyan: #06B6D4;
    --green: #10B981;
    --orange: #F59E0B;
    --bg: #0C0A1A;
    --bg-card: rgba(30, 25, 50, 0.7);
    --bg-input: rgba(15, 12, 30, 0.9);
    --border: rgba(139, 92, 246, 0.12);
    --border-focus: rgba(139, 92, 246, 0.5);
    --text: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-dim: #64748B;
    --glass: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 20% 10%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 90%, rgba(244, 63, 94, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.app {
    position: relative;
    z-index: 1;
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px;
}

/* ── Header ── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.header__brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header__icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
}

.header__title {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header__subtitle {
    font-size: 13px;
    color: var(--text-dim);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn--primary {
    background: linear-gradient(135deg, var(--primary), #7C3AED);
    color: #fff;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn--secondary {
    background: var(--glass);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn--secondary:hover {
    border-color: var(--primary);
    background: var(--bg-card);
}

.btn--accent {
    background: linear-gradient(135deg, var(--accent), #E11D48);
    color: #fff;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}

.btn--accent:hover {
    transform: translateY(-1px);
}

.btn--small {
    padding: 6px 14px;
    font-size: 12px;
}

/* ── Editor Layout ── */
.editor {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
    min-height: calc(100vh - 140px);
}

/* ── Controls Panel ── */
.controls {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 140px);
    backdrop-filter: blur(16px);
}

.controls::-webkit-scrollbar {
    width: 4px;
}

.controls::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.panel {
    margin-bottom: 20px;
}

.panel__title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.form-group input[type="color"] {
    height: 36px;
    padding: 4px;
    cursor: pointer;
}

.form-group input[type="range"] {
    padding: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* ── Template Gallery ── */
.templates {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.template-thumb {
    aspect-ratio: 1200/630;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.template-thumb:hover {
    border-color: var(--primary);
    transform: scale(1.03);
}

.template-thumb--active {
    border-color: var(--primary-light);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}

.template-thumb__label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    font-size: 9px;
    font-weight: 600;
    padding: 3px;
    text-align: center;
    color: #fff;
}

/* ── Logo Upload ── */
.logo-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-dim);
    font-size: 13px;
}

.logo-upload:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}

.logo-upload--has-image {
    padding: 8px;
}

.logo-upload img {
    max-height: 48px;
    max-width: 100%;
    object-fit: contain;
}

/* ── Preview Panel ── */
.preview-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    min-height: 400px;
    backdrop-filter: blur(16px);
}

.preview-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ── OG Canvas ── */
.og-canvas-wrapper {
    width: 100%;
    max-width: 720px;
    aspect-ratio: 1200 / 630;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.og-canvas-wrapper canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ── Font Selector Custom ── */
.font-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.font-pill {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.font-pill:hover {
    border-color: var(--primary);
    color: var(--text);
}

.font-pill--active {
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--primary-light);
    font-weight: 600;
}

/* ── Gradient Presets ── */
.gradient-presets {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.gradient-swatch {
    aspect-ratio: 1;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
}

.gradient-swatch:hover {
    transform: scale(1.1);
    border-color: var(--text-secondary);
}

.gradient-swatch--active {
    border-color: var(--primary-light);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.4);
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    box-shadow: var(--shadow);
}

.toast--success {
    background: rgba(16, 185, 129, 0.9);
}

.toast--info {
    background: rgba(139, 92, 246, 0.9);
}

@keyframes toastIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes toastOut {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .editor {
        grid-template-columns: 1fr;
    }

    .controls {
        max-height: none;
    }
}

@media (max-width: 480px) {
    .app {
        padding: 12px;
    }

    .templates {
        grid-template-columns: repeat(2, 1fr);
    }

    .gradient-presets {
        grid-template-columns: repeat(4, 1fr);
    }
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}