:root {
    --bg-color: #0f111a;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --secondary: #ec4899;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Dynamic Animated Background */
.background-animation {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.15) 0%, rgba(15, 17, 26, 0) 50%),
                radial-gradient(circle at 80% 20%, rgba(236, 72, 153, 0.15) 0%, rgba(15, 17, 26, 0) 40%);
    animation: rotateBg 30s linear infinite;
    z-index: -1;
}

@keyframes rotateBg {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.app-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    max-width: 1200px;
    width: 95%;
    height: 90vh;
    margin: 2rem auto;
}

header {
    grid-column: 1 / -1;
    text-align: center;
    margin-bottom: 1rem;
}

header h1 {
    font-family: 'Srisakdi', cursive;
    font-size: 3.5rem;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Glassmorphism Panel */
main, .glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--shadow);
    overflow-y: auto;
}

.step-section {
    display: none;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.4s ease-out forwards;
}

.step-section.active {
    display: flex;
}

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

h2 {
    margin-bottom: 1.5rem;
    font-weight: 400;
    font-size: 1.5rem;
}

/* Upload Area */
.upload-area {
    width: 100%;
    max-width: 400px;
    height: 250px;
    border: 2px dashed var(--glass-border);
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
}

.preview-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
}

/* Inputs & Buttons */
.input-group {
    width: 100%;
    max-width: 400px;
    margin-bottom: 2rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(0,0,0,0.2);
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.input-group input:focus {
    border-color: var(--primary);
}

.btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.btn.primary:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

.btn.secondary {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid var(--glass-border);
}

.btn.secondary:hover {
    background: rgba(255,255,255,0.2);
}

.btn.outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn.outline:hover {
    background: rgba(139, 92, 246, 0.1);
}

.btn.text-btn {
    background: transparent;
    color: var(--text-muted);
    padding: 8px;
    font-size: 0.9rem;
}
.btn.text-btn:hover {
    color: white;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Loader */
.loader {
    width: 60px;
    height: 60px;
    border: 4px solid var(--glass-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

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

/* Showcase */
.image-showcase {
    width: 100%;
    max-width: 400px;
    height: 600px; /* 9:16 approx for preview */
    background: rgba(0,0,0,0.3);
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    margin-bottom: 1rem;
}

.image-showcase img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* History Sidebar */
aside h3 {
    margin-bottom: 1.5rem;
    font-weight: 400;
}

.history-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 1.5rem;
}

.history-item {
    position: relative;
    width: 100%;
    aspect-ratio: 9/16;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}

.history-item:hover {
    transform: scale(1.05);
}

.history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-delete-history {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(236, 72, 153, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s;
    z-index: 10;
}
.btn-delete-history:hover {
    background: rgba(236, 72, 153, 1);
}

@media (max-width: 800px) {
    .app-container {
        grid-template-columns: 1fr;
        height: auto;
    }
}
