:root {
    --bg-color: #0f172a;
    --text-color: #e2e8f0;
    --primary-color: #38bdf8;
    --secondary-color: #818cf8;
    --accent-color: #c084fc;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    /* overflow: hidden; Removed to allow scrolling */
    position: relative;
    padding: 2rem 0;
    /* Add some vertical padding */
}

/* Background Animations */
.background-blobs {
    position: fixed;
    /* Changed to fixed so it covers screen while scrolling */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
    /* Ensure clicks pass through */
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 10s infinite ease-in-out;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--primary-color);
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: var(--accent-color);
    bottom: -50px;
    right: -50px;
    animation-delay: 2s;
}

.blob-3 {
    width: 200px;
    height: 200px;
    background: var(--secondary-color);
    top: 40%;
    left: 60%;
    animation-delay: 4s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(20px, -20px);
    }
}

/* Glassmorphism Card */
.container {
    width: 100%;
    max-width: 1200px;
    padding: 20px;
}

.card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

h1 {
    font-weight: 700;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    text-align: left;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.mobile-title {
    display: none;
}

.subtitle {
    text-align: left;
    color: #94a3b8;
    margin-bottom: 2rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 400;
    color: #cbd5e1;
}

input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.5);
    color: #fff;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

/* Force numeric arrows (spinners) - hiding native now that we have custom ones */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
    /* Firefox */
}

/* Custom Number Control */
.number-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.5);
    overflow: hidden;
    transition: box-shadow 0.3s, border-color 0.3s;
}

.number-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.number-wrapper input {
    border: none;
    border-radius: 0;
    background: transparent;
    text-align: center;
    padding: 12px 5px;
    /* Reduce padding to fit */
    box-shadow: none !important;
    /* Remove focus shadow from input itself */
}

.spin-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--primary-color);
    font-size: 1.25rem;
    cursor: pointer;
    width: 40px;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s;
    user-select: none;
}

.spin-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.spin-btn:active {
    background: rgba(56, 189, 248, 0.2);
}


/* Preview Area */
.preview-container {
    margin-top: 0;
    margin-bottom: 1rem;
}

.preview-header {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.image-wrapper {
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    border: 1px solid var(--glass-border);
    padding: 64px;
}

.image-wrapper img {
    max-width: 100%;
    height: auto;
    display: block;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.loading-overlay.active {
    opacity: 1;
}

/* Actions */
.actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    margin-bottom: 2rem;
    justify-content: center;
}

.btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.2s, filter 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #0f172a;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid var(--glass-border);
}

/* Responsive Divider */
.vertical-divider {
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 1rem;
    display: none;
}

@media (min-width: 900px) {
    .vertical-divider {
        display: block;
    }
}

@media (max-width: 899px) {
    .preview-section {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: rgba(15, 23, 42, 0.95);
        /* High opacity background */
        backdrop-filter: blur(12px);
        padding: 1rem;
        border-bottom: 1px solid var(--glass-border);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        /* Ensure it sits nicely */
    }

    /* Reduce padding/margins inside key header to save space */
    .preview-container {
        margin-top: 0;
        margin-bottom: 0.5rem;
    }

    /* Make image smaller on mobile to save vertical space? */
    .image-wrapper {
        padding: 2rem;
        /* Reduce padding from 64px */
        min-height: 150px;
    }

    .actions {
        margin-top: 1rem;
        margin-bottom: 0.5rem;
    }

    /* Push down the rest of the content */
    .top-section {
        padding-top: 250px;
        /* Approximate height of header */
    }

    /* Adjust container padding since header is fixed */
    .container {
        padding-top: 1rem;
    }

    /* Fix for position: fixed context */
    .card {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        transform: none;
    }

    .mobile-header-row {
        display: flex !important;
    }

    .mobile-title {
        display: block;
        text-align: left;
        margin-bottom: 0;
        font-size: 1.5rem;
    }

    /* Responsive Table to Cards */
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    /* Hide table headers (but not display: none;, for accessibility) */
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        border: 1px solid var(--glass-border);
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 1rem;
        background: rgba(15, 23, 42, 0.3);
    }

    td {
        /* Behave  like a "row" */
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        position: relative;
        padding-left: 50% !important;
        text-align: right !important;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        min-height: 40px;
    }

    td:last-child {
        border-bottom: 0;
    }

    td:before {
        /* Now like a table header */
        position: absolute;
        /* Top/left values mimic padding */
        top: 50%;
        left: 10px;
        transform: translateY(-50%);
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
        color: #94a3b8;
        content: attr(data-label);
    }

    /* Special case for image/preview to center it or give more space */
    td[data-label="Preview"] {
        padding-left: 0 !important;
        display: flex;
        justify-content: center;
        width: 100% !important;
        padding: 1rem !important;
        background: rgba(0, 0, 0, 0.2);
        border-radius: 12px;
        margin-bottom: 10px;
    }

    td[data-label="Preview"]:before {
        display: none;
    }
}