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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #050505;
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 40px 20px;
    background-image: radial-gradient(circle at 50% 50%, #1e1b4b 0%, #050505 70%);
}

.app-container {
    width: 100%;
    max-width: 700px;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 40px;
    border-radius: 28px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.main-header {
    text-align: center;
}

.main-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.05em;
    background: linear-gradient(to right, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.main-header p {
    color: #94a3b8;
    margin-bottom: 30px;
    font-size: 0.95rem;
}

/* --- Controls & Form --- */
.generator-box {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.search-bar {
    display: flex;
    gap: 12px;
    background: rgba(0, 0, 0, 0.4);
    padding: 8px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.search-bar:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.search-bar input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    padding: 12px 16px;
    font-size: 16px;
    outline: none;
}

.search-bar input::placeholder {
    color: #475569;
}

.search-bar button {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.search-bar button:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.search-bar button:disabled {
    background: #1e293b;
    color: #64748b;
    cursor: not-allowed;
    transform: none;
}

/* --- Options Section --- */
.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: rgba(255, 255, 255, 0.02);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.control-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    flex-wrap: wrap;
}

.control-group label {
    font-size: 0.9rem;
    color: #cbd5e1;
    font-weight: 500;
}

.control-group select {
    background: #0f172a;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.tags-container {
    display: flex;
    gap: 8px;
}

.style-btn {
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.style-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.style-btn.selected {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* --- Output Display --- */
.output-box {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

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

.image-box img {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 16px;
    display: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    animation: renderEffect 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-download {
    display: none;
    margin-top: 20px;
    background: transparent;
    border: 1px solid #10b981;
    color: #10b981;
    width: 100%;
    padding: 12px 28px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-download:hover {
    background: #10b981;
    color: white;
}

/* --- Saved Art History --- */
.gallery-box {
    margin-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 30px;
    text-align: left;
}

.gallery-box h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: #cbd5e1;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.gallery-item:hover {
    transform: scale(1.03);
}

.gallery-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.empty-text {
    grid-column: span 3;
    color: #475569;
    font-size: 0.9rem;
    font-style: italic;
    text-align: center;
    padding: 20px 0;
}

/* --- Status Elements & Keyframes --- */
.loader {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-bottom-color: #3b82f6;
    border-radius: 50%;
    display: none;
    animation: spinEffect 0.8s linear infinite;
    margin: 30px 0;
}

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

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

/* --- Responsiveness --- */
@media (max-width: 600px) {
    .app-container { padding: 24px; }
    .gallery-grid { grid-template-columns: repeat(2, 1fr); }
    .empty-text { grid-column: span 2; }
    .tags-container { width: 100%; justify-content: space-between; }
    .style-btn { flex: 1; text-align: center; padding: 6px 4px; font-size: 0.75rem; }
}
