:root {
    --primary: #c5a059; /* Gold */
    --primary-dark: #a68545;
    --secondary: #2c3e50;
    --accent: #e74c3c;
    --bg-dark: #0f0f12;
    --card-bg: rgba(255, 255, 255, 0.05);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f0f0f0;
    --text-dim: #a0a0a0;
    --font-sans: 'Inter', sans-serif;
    --font-serif: 'Playfair Display', serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.app-header {
    background: rgba(15, 15, 18, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo h1 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
}

.logo h1 span {
    color: var(--primary);
    font-weight: 300;
    font-style: italic;
}

.api-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.api-key-group {
    display: flex;
    gap: 0.5rem;
}

input[type="password"],
input[type="text"],
select,
textarea {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 10px rgba(197, 160, 89, 0.2);
}

/* App Container */
.app-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    flex-grow: 1;
    overflow: hidden;
}

/* Sidebar Navigation */
.sidebar {
    background: rgba(255, 255, 255, 0.02);
    border-right: 1px solid var(--glass-border);
    padding: 2rem 1rem;
}

.category-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    text-align: left;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    transform: translateX(5px);
}

.nav-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: black;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(197, 160, 89, 0.3);
}

/* Content Area */
.content-area {
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    overflow-y: auto;
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

h2 {
    font-family: var(--font-serif);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtext {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

/* Form Styles */
.dynamic-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    color: var(--primary);
    font-weight: 600;
}

.action-row {
    margin-top: 2rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: black;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(197, 160, 89, 0.4);
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Preview Styles */
.preview-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.preview-container {
    aspect-ratio: 9 / 16;
    max-height: 700px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 1rem;
    overflow: hidden;
}

.img-box {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    animation: fadeIn 0.5s ease-out;
}

.placeholder-content {
    color: var(--text-dim);
    text-align: center;
    font-style: italic;
    font-weight: 300;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 15, 18, 0.8);
    backdrop-filter: blur(5px);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    border-radius: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(197, 160, 89, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.btn-download {
    background: #27ae60;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.btn-download:hover {
    background: #2ecc71;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.3);
}

/* Footer */
.app-footer {
    padding: 1.5rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--glass-border);
    font-size: 0.85rem;
    color: var(--text-dim);
}

.app-footer strong {
    color: var(--primary);
}

/* Utilities */
.hidden { display: none !important; }

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

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Responsive */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 200px 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        padding: 1rem;
    }
    .category-nav {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }
    .nav-btn {
        white-space: nowrap;
    }
    .content-area {
        grid-template-columns: 1fr;
    }
}
