/* ===== CSS VARIABLES ===== */
:root {
    /* Colors - Neo-Portfolio palette */
    --color-bg: #FDFBF7;
    --color-surface: #FFFFFF;
    --color-text: #1A1A1A;
    --color-text-light: #6B6B6B;
    --color-border: #E8E4DF;
    --color-accent: #FF6B35;
    --color-accent-secondary: #1A1A1A;

    /* Typography */
    --font-display: 'Playfair Display', Georgia, serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
    --font-body: 'DM Sans', system-ui, sans-serif;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.06);
    --shadow-lg: 0 16px 48px rgba(0,0,0,0.08);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0D0D0D;
        --color-surface: #1A1A1A;
        --color-text: #F5F5F5;
        --color-text-light: #9B9B9B;
        --color-border: #2A2A2A;
        --color-accent-secondary: #FFFFFF;
    }
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== LAYOUT ===== */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== HEADER ===== */
.header {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-bg);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(var(--color-bg), 0.9);
}

.logo {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 0.1em;
    letter-spacing: -0.02em;
}

.logo-bracket {
    color: var(--color-accent);
    font-size: 1.4em;
}

.logo-text {
    background: linear-gradient(135deg, var(--color-text) 0%, var(--color-text-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3xl);
    padding: var(--space-3xl) var(--space-xl);
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* ===== EDITOR PANEL ===== */
.editor-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xl);
}

.section {
    animation: fadeSlideUp 0.5s ease backwards;
}

.section:nth-child(1) { animation-delay: 0.05s; }
.section:nth-child(2) { animation-delay: 0.1s; }
.section:nth-child(3) { animation-delay: 0.15s; }
.section:nth-child(4) { animation-delay: 0.2s; }
.section:nth-child(5) { animation-delay: 0.25s; }

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-title {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-lg);
    letter-spacing: -0.02em;
}

.title-number {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--color-accent);
    font-weight: 700;
}

/* ===== UPLOAD SECTION ===== */
.upload-area {
    position: relative;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-3xl);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--color-surface);
    overflow: hidden;
}

.upload-area:hover {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.1);
}

.upload-area.dragover {
    border-color: var(--color-accent);
    background: rgba(255, 107, 53, 0.05);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--color-text-light);
    transition: color var(--transition-base);
}

.upload-area:hover .upload-icon {
    color: var(--color-accent);
}

.upload-text {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text);
}

.upload-subtext {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-text-light);
}

.upload-preview {
    position: relative;
    display: inline-block;
}

.upload-preview img {
    max-width: 200px;
    max-height: 200px;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-accent);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: all var(--transition-base);
}

.upload-preview:hover .remove-btn {
    opacity: 1;
    transform: scale(1);
}

.remove-btn svg {
    width: 16px;
    height: 16px;
}

/* ===== BACKGROUND REMOVAL ===== */
.bg-removal-options {
    margin-top: var(--space-md);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--color-text);
    user-select: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    position: relative;
    transition: all var(--transition-base);
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ===== INPUT GROUPS ===== */
.input-group {
    margin-bottom: var(--space-lg);
}

.input-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-light);
    margin-bottom: var(--space-sm);
}

.label-icon {
    color: var(--color-accent);
}

.text-input {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--color-text);
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.text-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.1);
}

.text-input::placeholder {
    color: var(--color-text-light);
    opacity: 0.7;
}

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

/* ===== TEMPLATE GRID ===== */
.template-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-sm);
}

.template-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--color-text-light);
}

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

.template-btn.active {
    border-color: var(--color-accent);
    background: rgba(255, 107, 53, 0.05);
    color: var(--color-accent);
}

.template-preview {
    width: 100%;
    aspect-ratio: 9/16;
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
}

.template-preview.bold {
    background: linear-gradient(135deg, #1A1A1A 0%, #333 100%);
}

.template-preview.bold::after {
    content: '';
    position: absolute;
    inset: 30%;
    background: var(--color-accent);
    border-radius: 50%;
}

.template-preview.minimal {
    background: #FFFFFF;
    border: 1px solid var(--color-border);
}

.template-preview.minimal::after {
    content: '';
    position: absolute;
    inset: 35%;
    background: var(--color-text);
    border-radius: 50%;
}

.template-preview.editorial {
    background: linear-gradient(45deg, #F5F5F5 50%, #E8E4DF 50%);
}

.template-preview.editorial::after {
    content: '';
    position: absolute;
    top: 25%;
    left: 25%;
    right: 25%;
    height: 30%;
    background: var(--color-accent);
}

.template-preview.vibrant {
    background: linear-gradient(135deg, #FF6B35 0%, #FF3864 100%);
}

.template-preview.vibrant::after {
    content: '';
    position: absolute;
    inset: 30%;
    background: white;
    border-radius: 50%;
}

.template-preview.mono {
    background: #0D0D0D;
}

.template-preview.mono::after {
    content: '';
    position: absolute;
    inset: 25%;
    border: 2px solid white;
    border-radius: 50%;
}

/* ===== COLOR PALETTE ===== */
.color-palette {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.color-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
}

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

.color-btn.active {
    border-color: var(--color-text);
    box-shadow: 0 0 0 4px rgba(26, 26, 26, 0.1);
}

.color-input {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    padding: 0;
    cursor: pointer;
    background: none;
}

.color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input::-webkit-color-swatch {
    border-radius: 50%;
    border: 2px solid var(--color-border);
}

/* ===== PREVIEW PANEL ===== */
.preview-panel {
    position: sticky;
    top: calc(var(--space-3xl) + 80px);
    height: fit-content;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.preview-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.live-indicator {
    width: 8px;
    height: 8px;
    background: #22C55E;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.preview-size {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-text-light);
}

.preview-container {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    box-shadow: var(--shadow-lg);
    aspect-ratio: 9/16;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#cardCanvas {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.preview-actions {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    border: none;
}

.action-btn svg {
    width: 20px;
    height: 20px;
}

.action-btn.secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 2px solid var(--color-border);
}

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

.action-btn.primary {
    background: var(--color-accent);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
}

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

/* ===== FOOTER ===== */
.footer {
    padding: var(--space-lg);
    text-align: center;
    border-top: 1px solid var(--color-border);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-text-light);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .header {
        padding: var(--space-md);
    }

    .logo {
        font-size: 1.25rem;
    }

    .tagline {
        display: none;
    }

    .main-content {
        padding: var(--space-lg) var(--space-md);
        gap: var(--space-xl);
    }

    .section-title {
        font-size: 1.25rem;
    }

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

    .preview-panel {
        position: static;
    }

    .upload-area {
        padding: var(--space-xl);
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-light);
}
