/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Light Theme (Default) */
    --bg-body: #f3f5f9;
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-input: rgba(255, 255, 255, 0.9);
    --border-color: rgba(0, 0, 0, 0.08);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --primary: #0ca5b0;
    --primary-hover: #0d8a93;
    --accent: #8b5cf6;
    --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05);
    --focus-ring: 0 0 0 3px rgba(12, 165, 176, 0.2);
    --radius: 16px;
    --radius-sm: 8px;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #0ca5b0, #38bdf8);
}

[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-input: rgba(15, 23, 42, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #22d3ee;
    --primary-hover: #67e8f9;
    --accent: #a78bfa;
    --card-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
    --focus-ring: 0 0 0 3px rgba(34, 211, 238, 0.2);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    transition: background-color 0.4s ease, color 0.4s ease;
    display: flex;
    justify-content: center;
    /* Center horizontally */
    align-items: center;
    /* Center vertically if wanted, or at least start nicely */
    padding: 2rem;
    line-height: 1.5;
}

/* Layout */
.app-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 900px) {
    .app-container {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
}

/* Header */
.app-header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.title-group h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.25rem;
}

.title-group p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Components */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
}

/* Form Elements */
label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    margin-top: 1rem;
}

label:first-child {
    margin-top: 0;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Custom Range Slider */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: var(--border-color);
    border-radius: 99px;
}

/* Color Picker override */
input[type="color"] {
    padding: 0;
    height: 40px;
    cursor: pointer;
    overflow: hidden;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    /* Always white on primary */
    border: none;
    box-shadow: 0 4px 12px rgba(12, 165, 176, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(12, 165, 176, 0.4);
}

/* Grids */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

/* Theme Toggle */
.theme-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    cursor: pointer;
}

/* Preview Area */
.preview-wrapper {
    position: sticky;
    top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.canvas-container {
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    background: #fff;
    /* Canvas base is white usually */
    margin-bottom: 1rem;
    max-width: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: auto;
}

/* Quick Background Presets */
.bg-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.color-option {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}


/* Action Bar */
.actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.actions .btn {
    flex: 1;
    min-width: 100px;
}

/* Utility to hide/show */
.hidden {
    display: none !important;
}

/* --- AI & Modal Styles --- */

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.modal-content {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    padding: 2rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
}

.close-btn:hover {
    color: var(--text-main);
}

/* AI Inputs */
.magic-group {
    position: relative;
    margin-bottom: 1rem;
}

.magic-input {
    padding-right: 100px;
    /* Space for button */
}

.magic-btn {
    position: absolute;
    right: 4px;
    top: 4px;
    bottom: 4px;
    border: none;
    background: var(--gradient-primary);
    color: white;
    border-radius: 6px;
    padding: 0 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.magic-btn:hover {
    filter: brightness(1.1);
}

.magic-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* Loaders */
.loader-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.shimmer {
    position: relative;
    overflow: hidden;
}

.shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0,
            rgba(255, 255, 255, 0.2) 20%,
            rgba(255, 255, 255, 0.5) 60%,
            rgba(255, 255, 255, 0));
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

/* Smart Animations for Video */
/* These won't affect the canvas directly but can be used for CSS checks or UI feedback */