/* =============================================
   QUOTE IMAGE GENERATOR STUDIO
============================================= */
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@500;700&family=Merriweather:ital,wght@0,400;0,700;1,400&family=Playfair+Display:ital,wght@0,500;0,700;1,500&family=Oswald:wght@400;500;700&family=Cinzel:wght@400;600;700&family=Dancing+Script:wght@500;700&family=Outfit:wght@400;500;700&family=Montserrat:ital,wght@0,400;0,500;0,700;1,400&display=swap');

.generator-page body {
    overflow-x: hidden;
}

.generator-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 70px);
    background-color: var(--bg-primary);
}

/* --- Preview Section --- */
.preview-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: var(--space-md) var(--space-xl);
    background-color: var(--bg-primary);
    width: 100%;
    margin: 0 auto;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 640px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* The actual canvas element to be captured */
.quote-canvas {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3em 4em;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    color: #fff;
    text-align: center;
    overflow: hidden;
    width: 100%;
    height: auto;
    font-size: 16px; /* Base size, updated by JS */
}

/* Aspect Ratios */
.aspect-square { max-width: 500px; aspect-ratio: 1 / 1; }
.aspect-portrait { max-width: 480px; aspect-ratio: 4 / 5; }
.aspect-pin { max-width: 420px; aspect-ratio: 2 / 3; }
.aspect-story { max-width: 360px; aspect-ratio: 9 / 16; }
.aspect-landscape { max-width: 640px; aspect-ratio: 16 / 9; }

/* Remove old hardcoded CSS */

/* --- Responsive Magic --- */
@media (max-width: 900px) {
    .preview-section {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: var(--space-md);
    }
}

@media (max-width: 768px) {
    .canvas-wrapper {
        align-items: center;
        padding-top: var(--space-sm);
    }
    
    .options-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .image-bg-options {
        grid-template-columns: repeat(4, 1fr);
    }

    .button-group .control-btn {
        flex: 1 1 calc(50% - var(--space-sm));
    }
}

@media (max-width: 480px) {
    .canvas-wrapper {
        padding-top: var(--space-sm);
    }
    
    .image-bg-options {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Image Backgrounds & CSS Mattes */
.bg-pure-matte { background: radial-gradient(circle at center, #1a1a1a 0%, #000000 100%); color: #fff; }
.bg-black-leather { background-image: url('../images/backgrounds/black_leather.png'); background-size: cover; background-position: center; color: #fff; }
.bg-carbon-fiber { background-image: url('../images/backgrounds/carbon_fiber.png'); background-size: cover; background-position: center; color: #fff; }
.bg-midnight-geometry { background-image: url('../images/backgrounds/midnight_geometry.png'); background-size: cover; background-position: center; color: #fff; }
.bg-cosmic-dust { background-image: url('../images/backgrounds/cosmic_dust.png'); background-size: cover; background-position: center; color: #fff; }
.bg-dark-marble { background-image: url('../images/backgrounds/dark_marble.png'); background-size: cover; background-position: center; color: #fff; }
.bg-smoky-quartz { background-image: url('../images/backgrounds/smoky_quartz.png'); background-size: cover; background-position: center; color: #fff; }
.bg-ethereal-light { background-image: url('../images/backgrounds/ethereal_light.png'); background-size: cover; background-position: center; color: #111827; }
.bg-obsidian-glass { background-image: url('../images/backgrounds/obsidian_glass.png'); background-size: cover; background-position: center; color: #fff; }
.bg-deep-ocean { background-image: url('../images/backgrounds/deep_ocean.png'); background-size: cover; background-position: center; color: #fff; }
.bg-crimson-velvet { background-image: url('../images/backgrounds/crimson_velvet.png'); background-size: cover; background-position: center; color: #fff; }
.bg-dark-slate { background-image: url('../images/backgrounds/dark_slate.png'); background-size: cover; background-position: center; color: #fff; }

/* Text Alignment Options */
.align-left .canvas-content { align-items: flex-start; text-align: left; }
.align-center .canvas-content { align-items: center; text-align: center; }
.align-right .canvas-content { align-items: flex-end; text-align: right; }

/* Fonts */
.font-playfair { font-family: 'Playfair Display', serif; }
.font-inter { font-family: 'Inter', sans-serif; }
.font-merriweather { font-family: 'Merriweather', serif; }
.font-caveat { font-family: 'Caveat', cursive; }
.font-oswald { font-family: 'Oswald', sans-serif; text-transform: uppercase; }
.font-cinzel { font-family: 'Cinzel', serif; }
.font-dancing { font-family: 'Dancing Script', cursive; }
.font-outfit { font-family: 'Outfit', sans-serif; }
.font-montserrat { font-family: 'Montserrat', sans-serif; }

/* Canvas Content Layout */
.canvas-dimmer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    opacity: 0; /* Default no dimmer */
    z-index: 1;
    pointer-events: none;
}

.canvas-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    min-height: 0; /* Crucial to allow overflow calculation */
    z-index: 2;
}

.canvas-quotation-mark {
    font-size: 6em;
    font-family: 'Merriweather', serif;
    color: #6366f1;
    line-height: 0.5;
    margin-bottom: 0.5em;
    opacity: 0.8;
}

.canvas-quote-text {
    font-size: 1.8em;
    line-height: 1.5;
    margin-bottom: 1.5em;
    font-weight: 500;
}

/* Highlight Styles */
.quote-canvas.hl-brand .canvas-highlight { color: var(--accent); font-weight: bold; }

.quote-canvas.hl-gold .canvas-highlight { color: #fbbf24; font-weight: bold; }
.quote-canvas.hl-bold .canvas-highlight { color: inherit; font-weight: 800; }
.quote-canvas.hl-italic .canvas-highlight { color: inherit; font-style: italic; font-weight: inherit; }
.quote-canvas.hl-underline .canvas-highlight { color: inherit; font-weight: inherit; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }

.canvas-author-block {
    display: flex;
    flex-direction: column;
    align-items: inherit;
    margin-top: 1em;
}

.canvas-quote-author {
    font-size: 1.25em;
    font-weight: 700;
    opacity: 0.9;
}

.canvas-quote-author-title {
    font-size: 0.9em;
    font-weight: 400;
    opacity: 0.7;
    margin-top: 0.25em;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.canvas-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-top: 1.5em;
}

.canvas-tag {
    font-size: 0.95em;
    font-weight: 500;
    color: inherit;
    opacity: 0.6;
    letter-spacing: 0.5px;
}

.canvas-watermark {
    position: absolute;
    bottom: 20px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85em;
    opacity: 0.6;
    letter-spacing: 1px;
    z-index: 10;
}

/* --- Controls Section --- */
.controls-section {
    padding: var(--space-xl);
    background-color: var(--bg-primary);
    overflow-y: auto;
}

.controls-section h2 {
    margin-top: 0;
    margin-bottom: var(--space-lg);
    font-size: 1.5rem;
    color: var(--text-primary);
}

.control-group {
    margin-bottom: var(--space-lg);
}

.control-group label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.button-group .control-btn {
    flex: 1 1 calc(33.33% - var(--space-sm));
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.control-btn {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.canvas-size-toolbar .control-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    flex: 1;
    justify-content: center;
}

.control-btn:hover {
    border-color: var(--accent);
}

.control-btn.active {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
}

.theme-options {
    grid-template-columns: repeat(3, 1fr);
}

.theme-btn {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s;
    margin: 0 auto;
}

.theme-btn:hover {
    transform: scale(1.1);
}

.theme-btn.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--text-primary);
}

.image-bg-options {
    grid-template-columns: repeat(5, 1fr);
}

.horizontal-scroll {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE and Edge */
    -webkit-overflow-scrolling: touch;
}

.horizontal-scroll::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

.horizontal-scroll .image-bg-btn {
    width: 65px;
    height: 65px;
    flex: 0 0 65px;
}

.image-bg-btn {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    transition: transform 0.2s;
}

.image-bg-btn:hover {
    transform: scale(1.1);
}

.image-bg-btn.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--text-primary);
}

.control-select {
    width: 100%;
    padding: var(--space-sm);
    border: 1px solid var(--border);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}

.control-select:focus {
    border-color: var(--accent);
}

.control-select option {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.control-select option:checked,
.control-select option:hover {
    background-color: var(--accent) !important;
    color: white !important;
    box-shadow: 0 0 10px 100px var(--accent) inset !important;
}

.toggle-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    width: 100%;
}

/* Custom sleek toggle switches */
.toggle-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 44px;
    height: 24px;
    background: #374151;
    border-radius: 24px;
    position: relative;
    outline: none;
    cursor: pointer;
    transition: background 0.3s ease;
    margin: 0;
}

.toggle-label input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-label input[type="checkbox"]:checked {
    background: #2dd4bf; /* Teal accent */
}

.toggle-label input[type="checkbox"]:checked::after {
    transform: translateX(20px);
}

.action-section {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border);
}

.btn-full {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: var(--space-md);
    font-size: 1.1rem;
}
