/* =========================================
   Base & Resets
   ========================================= */
:root {
    --bg-color: #0d1117;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --accent-primary: #58a6ff;
    --accent-hover: #3182ce;
    --accent-gradient: linear-gradient(135deg, #FF6B6B 0%, #4ECDC4 100%);
    --glass-bg: rgba(22, 27, 34, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-inset: rgba(13, 17, 23, 0.6);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: 2rem;
    position: relative;
}

/* =========================================
   Animated Background Blobs
   ========================================= */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
    filter: blur(80px);
}

.blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.6;
    animation: float 20s infinite alternate ease-in-out;
}

.blob-1 {
    width: 40vw;
    height: 40vw;
    background: radial-gradient(circle, #58a6ff, rgba(88, 166, 255, 0));
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.blob-2 {
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, #8a2be2, rgba(138, 43, 226, 0));
    bottom: -20%;
    right: -10%;
    animation-duration: 25s;
    animation-delay: -5s;
}

.blob-3 {
    width: 30vw;
    height: 30vw;
    background: radial-gradient(circle, #ff6b6b, rgba(255, 107, 107, 0));
    top: 40%;
    left: 40%;
    animation-duration: 30s;
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(5%, 5%) scale(1.1);
    }

    66% {
        transform: translate(-5%, 10%) scale(0.9);
    }

    100% {
        transform: translate(0, 0) scale(1);
    }
}

/* =========================================
   Typography & Utils
   ========================================= */
h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.5;
}

.gradient-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hidden {
    display: none !important;
}

/* =========================================
   Glassmorphism Components
   ========================================= */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
}

.glass-inset {
    background: var(--glass-inset);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* =========================================
   Layout Structure
   ========================================= */
.app-container {
    width: 100%;
    max-width: 1000px;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 10;
}

header {
    text-align: center;
}

.dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   Drop Zone Area
   ========================================= */
.drop-zone {
    height: 100%;
    min-height: 350px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    transition: all 0.3s ease;
    cursor: auto;
    position: relative;
    overflow: hidden;
}

.drop-zone.dragover {
    border-color: var(--accent-primary);
    background: rgba(88, 166, 255, 0.1);
    transform: scale(1.02);
}

.drop-content {
    text-align: center;
    pointer-events: none;
    transition: opacity 0.3s;
}

.drop-content svg {
    margin-bottom: 1rem;
    color: var(--accent-primary);
}

.drop-content span {
    font-size: 0.85rem;
    opacity: 0.7;
}

#sourcePreview {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    object-fit: contain;
    z-index: 2;
}

/* Checkerboard background for transparent preview */
.checkerboard {
    background-image:
        linear-gradient(45deg, #222 25%, transparent 25%),
        linear-gradient(-45deg, #222 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #222 75%),
        linear-gradient(-45deg, transparent 75%, #222 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* =========================================
   Controls & Inputs
   ========================================= */
.controls-wrapper {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group.row-col {
    flex-direction: row;
    gap: 1rem;
}

.control-group.row-col label {
    flex: 1;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

label span {
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
}

.hint {
    font-size: 0.75rem !important;
    color: var(--text-secondary) !important;
    margin-top: -0.25rem;
}

input[type="number"] {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s;
    width: 100%;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

/* Range Sliders */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    margin-top: 0.5rem;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Color Picker */
.color-picker-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

input[type="color"] {
    -webkit-appearance: none;
    width: 100%;
    height: 48px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
}

/* Checkbox styling */
.checkbox-group {
    margin-top: 0.5rem;
}

.custom-checkbox {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    height: 20px;
    width: 20px;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    position: relative;
    transition: all 0.2s;
}

.custom-checkbox:hover input~.checkmark {
    border-color: var(--accent-primary);
}

.custom-checkbox input:checked~.checkmark {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.custom-checkbox input:checked~.checkmark:after {
    display: block;
}

.sub-control {
    margin-left: 2rem;
    margin-top: 0.5rem;
    transition: opacity 0.3s, height 0.3s;
}

/* Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.primary-btn {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.primary-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.primary-btn.pulse:not(:disabled) {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(78, 205, 196, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(78, 205, 196, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(78, 205, 196, 0);
    }
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* =========================================
   Results Grid
   ========================================= */
.results-panel {
    padding: 2rem;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.5rem;
}

.result-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.result-canvas-wrapper {
    width: 100%;
    aspect-ratio: 1;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><rect width="10" height="10" fill="rgba(255,255,255,0.1)"/><rect x="10" y="10" width="10" height="10" fill="rgba(255,255,255,0.1)"/></svg>');
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 0.5rem;
}

.result-canvas-wrapper canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.result-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* =========================================
   Modal
   ========================================= */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    color: var(--text-primary);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
}

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    margin: 0;
    color: var(--text-primary);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    flex: none;
    width: auto;
    transition: color 0.2s;
    outline: none;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modal-body h3 {
    margin-bottom: 0.5rem;
    color: var(--accent-primary);
    font-size: 1.3rem;
    border-left: 3px solid var(--accent-primary);
    padding-left: 0.75rem;
}

.modal-body p,
.modal-body li {
    font-size: 0.95rem;
    line-height: 1.6;
}

.modal-body ul,
.modal-body ol {
    padding-left: 1.8rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.modal-body li strong {
    color: var(--text-primary);
}

.note-box {
    background: rgba(88, 166, 255, 0.1);
    border-left: 4px solid var(--accent-primary);
    padding: 1.2rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    line-height: 1.6;
}