/* Purple Theme and Animation CSS for Text-to-Image Generator */

/* Import Google Fonts for better typography */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@700;800;900&display=swap');

/* CSS Variables for consistent theming */
:root {
    --primary-purple: #8a2be2;
    --secondary-purple: #9370db;
    --light-purple: #e6e0fa;
    --dark-purple: #4b0082;
    --accent-color: #ff6b6b;
    --accent-purple: #b19cd9;
    --text-color: #333;
    --light-text: #fff;
    --background: #f9f4ff;
    --card-bg: #ffffff;
    --shadow: 0 4px 20px rgba(138, 43, 226, 0.15);
    --gradient-purple: linear-gradient(135deg, var(--primary-purple), var(--dark-purple));
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--background);
    color: var(--text-color);
    line-height: 1.6;
    padding: 0;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--light-purple) 0%, var(--background) 100%);
    animation: gradientShift 15s ease infinite alternate;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

main {
    flex: 1;
    padding: 2rem;
    z-index: 1;
    margin-top: 20px;
}

/* Background Animation */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Particles Animation */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.particles::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(138, 43, 226, 0.05) 0%, transparent 8%),
        radial-gradient(circle at 30% 70%, rgba(138, 43, 226, 0.05) 0%, transparent 8%),
        radial-gradient(circle at 50% 40%, rgba(138, 43, 226, 0.05) 0%, transparent 8%),
        radial-gradient(circle at 70% 90%, rgba(138, 43, 226, 0.05) 0%, transparent 8%),
        radial-gradient(circle at 90% 10%, rgba(138, 43, 226, 0.05) 0%, transparent 8%);
    animation: particleMove 20s linear infinite;
}

@keyframes particleMove {
    0% {
        background-position: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%;
    }
    100% {
        background-position: 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
    }
}

/* Header Styles */
header {
    background: var(--gradient-purple);
    color: var(--light-text);
    padding: 2rem;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
    animation: headerGlow 3s infinite alternate;
    margin-top: 0;
}

@keyframes headerGlow {
    0% {
        box-shadow: 0 4px 20px rgba(138, 43, 226, 0.2);
    }
    100% {
        box-shadow: 0 4px 30px rgba(138, 43, 226, 0.5);
    }
}

.subtitle {
    font-size: 1.2rem;
    margin-top: 0.5rem;
    opacity: 0;
    animation: fadeIn 1s ease-out 0.5s forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Header Animation */
h1 {
    font-family: 'Montserrat', sans-serif;
    text-align: center;
    margin-bottom: 1rem;
    font-size: 2.5rem;
    font-weight: 800;
    position: relative;
    padding-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    animation: fadeInDown 1s ease-out, glowPulse 3s infinite alternate;
    letter-spacing: 1px;
}

h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--light-text), transparent);
    border-radius: 2px;
    animation: expandWidth 2s ease-in-out infinite;
}

.magic-icon {
    display: inline-block;
    margin-right: 10px;
    animation: spinMagic 3s ease-in-out infinite;
}

@keyframes spinMagic {
    0% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(30deg);
    }
    75% {
        transform: rotate(-30deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

h3 {
    color: var(--dark-purple);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    animation: fadeInLeft 0.8s ease-out;
}

/* Container Styling */
.input, .output {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 15px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    transform: translateY(20px);
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
    position: relative;
    overflow: hidden;
}

.input {
    animation-delay: 0.3s;
    border-left: 5px solid var(--primary-purple);
}

.input::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(138, 43, 226, 0.1) 0%, transparent 70%);
    animation: pulseRadial 10s infinite linear;
    z-index: 0;
}

@keyframes pulseRadial {
    0% {
        transform: scale(0.8);
        opacity: 0.3;
    }
    50% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(0.8);
        opacity: 0.3;
    }
}

.output {
    animation-delay: 0.6s;
    border-left: 5px solid var(--secondary-purple);
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.output-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.loader {
    display: none;
}

.loader.active {
    display: block;
}

.loader-circle {
    width: 30px;
    height: 30px;
    border: 3px solid var(--light-purple);
    border-top: 3px solid var(--primary-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.image-info {
    margin-top: 1.5rem;
    width: 100%;
    padding-top: 1rem;
    border-top: 1px solid var(--light-purple);
    font-size: 0.9rem;
    color: var(--dark-purple);
    opacity: 0;
    animation: fadeIn 0.5s ease-out forwards;
    animation-delay: 1s;
}

.image-info p {
    margin-bottom: 0.5rem;
}

/* Label Styling */
label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 500;
    color: var(--dark-purple);
    animation: fadeInLeft 0.8s ease-out;
    position: relative;
    z-index: 1;
}

label i {
    margin-right: 8px;
    color: var(--primary-purple);
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* Input Field Styling */
.input-group {
    position: relative;
    z-index: 1;
    margin-bottom: 1.5rem;
}

input[type="input"] {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--light-purple);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--light-purple);
    color: var(--text-color);
    transition: all 0.3s ease;
    animation: pulseGlow 2s infinite alternate;
}

input[type="input"]:focus {
    outline: none;
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.25);
    transform: translateY(-2px);
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.suggestion-tag {
    background: var(--light-purple);
    color: var(--dark-purple);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: fadeInUp 0.5s ease-out forwards;
    opacity: 0;
    transform: translateY(10px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.suggestion-tag:nth-child(1) {
    animation-delay: 0.1s;
}

.suggestion-tag:nth-child(2) {
    animation-delay: 0.2s;
}

.suggestion-tag:nth-child(3) {
    animation-delay: 0.3s;
}

.suggestion-tag:nth-child(4) {
    animation-delay: 0.4s;
}

.suggestion-tag:hover {
    background: var(--primary-purple);
    color: var(--light-text);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 5px 15px rgba(138, 43, 226, 0.3);
}

/* Button Styling */
.button-container {
    display: flex;
    gap: 1rem;
    position: relative;
    z-index: 1;
}

button {
    background: var(--primary-purple);
    color: var(--light-text);
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.3);
    position: relative;
    overflow: hidden;
    animation: bounceIn 1s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

button i {
    margin-right: 8px;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: all 0.5s ease;
}

button:hover {
    background: var(--dark-purple);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(138, 43, 226, 0.4);
}

button:hover::before {
    left: 100%;
    animation: shimmer 1.5s infinite;
}

button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(138, 43, 226, 0.3);
}

.secondary-btn {
    background: var(--light-purple);
    color: var(--dark-purple);
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.15);
}

.secondary-btn:hover {
    background: var(--secondary-purple);
    color: var(--light-text);
}

/* Image Styling */
#image {
    max-width: 100%;
    max-height: 500px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    transition: all 0.5s ease;
    animation: zoomIn 1s ease-out, floatAnimation 3s ease-in-out infinite alternate;
}

#image:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 30px rgba(138, 43, 226, 0.3);
}

/* Loading Animation for Image */
#image[alt="Generating image..."] {
    animation: pulse 1.5s infinite;
}

/* Footer Styling */
footer {
    background: var(--dark-purple);
    color: var(--light-text);
    text-align: center;
    padding: 1.5rem;
    margin-top: auto;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.8s ease-out;
}

footer p {
    font-size: 0.9rem;
}

.highlight {
    color: var(--accent-color);
    font-weight: 600;
    position: relative;
    display: inline-block;
}

.highlight::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-color);
    animation: widthPulse 2s infinite;
}

@keyframes widthPulse {
    0%, 100% {
        width: 0;
    }
    50% {
        width: 100%;
    }
}

/* Animation Keyframes */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.6;
    }
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

@keyframes expandWidth {
    0% {
        width: 50px;
    }
    50% {
        width: 150px;
    }
    100% {
        width: 50px;
    }
}

@keyframes glowPulse {
    0% {
        text-shadow: 0 0 5px rgba(138, 43, 226, 0.3);
    }
    100% {
        text-shadow: 0 0 15px rgba(138, 43, 226, 0.7), 0 0 30px rgba(138, 43, 226, 0.4);
    }
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 5px rgba(138, 43, 226, 0.2);
    }
    100% {
        box-shadow: 0 0 15px rgba(138, 43, 226, 0.4);
    }
}

@keyframes floatAnimation {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-10px);
    }
}

@keyframes rotateAnimation {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    main {
        padding: 1rem;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .input, .output {
        padding: 1.5rem;
    }
    
    .button-container {
        flex-direction: column;
    }
    
    button {
        width: 100%;
    }
}

/* Additional Floating Particles Animation */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(138, 43, 226, 0.05) 0%, transparent 8%),
        radial-gradient(circle at 30% 70%, rgba(138, 43, 226, 0.05) 0%, transparent 8%),
        radial-gradient(circle at 50% 40%, rgba(138, 43, 226, 0.05) 0%, transparent 8%),
        radial-gradient(circle at 70% 90%, rgba(138, 43, 226, 0.05) 0%, transparent 8%),
        radial-gradient(circle at 90% 10%, rgba(138, 43, 226, 0.05) 0%, transparent 8%);
    animation: particleMove 20s linear infinite;
}

.logout-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 20px;
    background: #ff4757;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 5px;
}

.logout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.3);
    background: #ff6b81;
}

.logout-btn i {
    margin-right: 5px;
}

/* Update the header-controls styles */
.header-controls {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 10px 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
    gap: 15px;
    height: 60px;
}

/* Add styles for the username display */
.user-name {
    margin-right: auto;
    color: var(--dark-purple);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    background: var(--light-purple);
    border-radius: 20px;
    font-size: 0.9rem;
}

.user-name i {
    color: var(--primary-purple);
}

/* Make buttons consistent in size */
.theme-btn, .new-btn, .saved-btn, .logout-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    min-width: 100px;
    justify-content: center;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    .header-controls {
        flex-wrap: wrap;
        justify-content: center;
        padding: 10px;
    }

    .user-name {
    width: 100%;
        justify-content: center;
        margin-bottom: 10px;
    }

    .theme-btn, .new-btn, .saved-btn, .logout-btn {
        min-width: auto;
        padding: 8px 12px;
    }
}

/* Update saved-images-sidebar top position */
.saved-images-sidebar {
    top: 60px;
    height: calc(100vh - 60px);
}