/* ===== CSS VARIABLES ===== */
:root {
    --primary-red: #ff0040;
    --secondary-red: #cc0033;
    --dark-red: #990026;
    --bg-dark: #0a0a0a;
    --bg-darker: #050505;
    --bg-panel: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    --border-color: #333333;
    --success-color: #00ff88;
    --warning-color: #ffaa00;
    --error-color: #ff4444;
    --shadow-glow: 0 0 20px rgba(255, 0, 64, 0.3);
    --shadow-dark: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Rajdhani', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== BACKGROUND ANIMATION ===== */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(255, 0, 64, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 0, 64, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: gridMove 20s linear infinite;
}

.particles {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(2px 2px at 20px 30px, var(--primary-red), transparent),
                radial-gradient(2px 2px at 40px 70px, var(--success-color), transparent),
                radial-gradient(1px 1px at 90px 40px, var(--warning-color), transparent);
    background-repeat: repeat;
    background-size: 200px 200px;
    animation: particleFloat 15s ease-in-out infinite;
}

@keyframes gridMove {
    0% { transform: translate(0, 0); }
    100% { transform: translate(50px, 50px); }
}

@keyframes particleFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(180deg); }
}

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, var(--bg-darker), var(--bg-panel));
    border-bottom: 2px solid var(--primary-red);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.api-docs-link {
    color: var(--text-primary);
    text-decoration: none;
    font-family: 'Orbitron', monospace;
    font-size: 0.9rem;
    font-weight: 700;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--bg-darker), var(--bg-panel));
    border: 2px solid var(--primary-red);
    border-radius: 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 15px rgba(255, 0, 64, 0.2);
}

.api-docs-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 0, 64, 0.2), transparent);
    transition: left 0.5s ease;
}

.api-docs-link:hover::before {
    left: 100%;
}

.api-docs-link:hover {
    color: white;
    border-color: var(--primary-red);
    box-shadow: 0 0 25px rgba(255, 0, 64, 0.5), 0 0 50px rgba(255, 0, 64, 0.2);
    transform: translateY(-3px) scale(1.05);
    background: linear-gradient(135deg, var(--primary-red), var(--dark-red));
}

.api-docs-link i {
    font-size: 1rem;
    animation: codeIconPulse 2s ease-in-out infinite;
}

@keyframes codeIconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.logo {
    font-family: 'Orbitron', monospace;
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary-red);
    text-shadow: 0 0 10px var(--primary-red);
    animation: logoGlow 2s ease-in-out infinite alternate;
}

.logo i {
    margin-right: 10px;
    animation: brainPulse 1.5s ease-in-out infinite;
}

@keyframes logoGlow {
    0% { text-shadow: 0 0 10px var(--primary-red); }
    100% { text-shadow: 0 0 20px var(--primary-red), 0 0 30px var(--primary-red); }
}

@keyframes brainPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
}

.status-dot {
    width: 12px;
    height: 12px;
    background: var(--success-color);
    border-radius: 50%;
    animation: statusBlink 2s ease-in-out infinite;
    box-shadow: 0 0 10px var(--success-color);
}

@keyframes statusBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ===== MAIN CONTENT ===== */
.main {
    padding: 40px 0;
    min-height: calc(100vh - 100px);
}

/* ===== CONTROL PANEL ===== */
.control-panel {
    background: linear-gradient(135deg, var(--bg-panel), var(--bg-darker));
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 40px;
    box-shadow: var(--shadow-dark);
    position: relative;
    overflow: hidden;
}

.control-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-red), transparent);
    animation: scanLine 3s linear infinite;
}

@keyframes scanLine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.panel-header h2 {
    font-family: 'Orbitron', monospace;
    font-size: 1.5rem;
    color: var(--primary-red);
    margin-bottom: 10px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.usage-stats {
    text-align: center;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(255, 0, 64, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(255, 0, 64, 0.2);
}

.usage-stats small {
    color: var(--text-secondary);
    font-family: 'Orbitron', monospace;
    font-size: 0.8rem;
}

.usage-stats i {
    color: var(--primary-red);
    margin-right: 5px;
}

.panel-header i {
    margin-right: 10px;
}

/* ===== FORM STYLES ===== */
.generation-form {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-family: 'Orbitron', monospace;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-group label i {
    margin-right: 8px;
    color: var(--primary-red);
}

.char-counter {
    float: right;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: normal;
}

.char-counter.warning {
    color: var(--warning-color);
}

.char-counter.error {
    color: var(--error-color);
}

.input-help {
    margin-top: 5px;
}

.input-help small {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
}

.params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* Input Styles */
input, select, textarea {
    background: var(--bg-darker);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 15px;
    color: var(--text-primary);
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    transition: all 0.3s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 15px rgba(255, 0, 64, 0.3);
    transform: translateY(-2px);
}

textarea {
    resize: vertical;
    min-height: 100px;
    font-family: 'Rajdhani', sans-serif;
}

/* Checkbox Styles */
.checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 15px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    background: var(--bg-darker);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    position: relative;
    transition: all 0.3s ease;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: var(--primary-red);
    border-color: var(--primary-red);
    box-shadow: 0 0 10px rgba(255, 0, 64, 0.5);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 12px;
}

/* ===== GENERATE BUTTON ===== */
.generate-btn {
    background: linear-gradient(135deg, var(--primary-red), var(--dark-red));
    border: none;
    border-radius: 12px;
    padding: 18px 40px;
    color: white;
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-glow);
    margin-top: 20px;
}

.generate-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 30px rgba(255, 0, 64, 0.6);
}

.generate-btn:active {
    transform: translateY(-1px);
}

.generate-btn.loading {
    pointer-events: none;
}

.btn-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: opacity 0.3s ease;
}

.btn-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.generate-btn.loading .btn-text {
    opacity: 0;
}

.generate-btn.loading .btn-loader {
    opacity: 1;
}

.loader-ring {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ===== RESULTS SECTION ===== */
.results-section {
    background: linear-gradient(135deg, var(--bg-panel), var(--bg-darker));
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 30px;
    box-shadow: var(--shadow-dark);
    position: relative;
    overflow: hidden;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.results-header h2 {
    font-family: 'Orbitron', monospace;
    font-size: 1.5rem;
    color: var(--primary-red);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.results-actions {
    display: flex;
    gap: 15px;
}

.action-btn {
    background: linear-gradient(135deg, var(--bg-darker), var(--border-color));
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 20px;
    color: var(--text-primary);
    font-family: 'Orbitron', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: linear-gradient(135deg, var(--primary-red), var(--dark-red));
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(255, 0, 64, 0.3);
}

/* ===== PROGRESS BAR ===== */
.progress-container {
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-darker);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-red), var(--warning-color), var(--success-color));
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: progressShine 2s ease-in-out infinite;
}

@keyframes progressShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    text-align: center;
    margin-top: 10px;
    font-family: 'Orbitron', monospace;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== IMAGE GALLERY ===== */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    min-height: 200px;
}

.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
    animation: emptyFloat 3s ease-in-out infinite;
}

@keyframes emptyFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.empty-subtitle {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* ===== IMAGE CARD ===== */
.image-card {
    background: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
    opacity: 1; /* Ensure cards are visible by default */
}

@keyframes cardSlideIn {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.image-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(255, 0, 64, 0.2);
    border-color: var(--primary-red);
}

.image-card img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    transition: transform 0.3s ease;
    background: var(--bg-darker);
    border-radius: 8px 8px 0 0;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.image-card img[src=""], .image-card img:not([src]) {
    opacity: 0 !important;
}

.image-card img.loading {
    background: linear-gradient(90deg, var(--bg-darker) 25%, var(--border-color) 50%, var(--bg-darker) 75%);
    background-size: 200% 100%;
    animation: imageLoading 1.5s infinite;
}

@keyframes imageLoading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.image-card:hover img {
    transform: scale(1.05);
}

.image-info {
    padding: 15px;
}

.image-prompt {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.image-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'Orbitron', monospace;
}

.download-btn {
    background: var(--primary-red);
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-weight: 600;
}

.download-btn:hover {
    background: var(--dark-red);
    transform: scale(1.05);
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.modal-content {
    position: relative;
    margin: 5% auto;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    0% {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: var(--text-primary);
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--primary-red);
}

.modal-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 0 50px rgba(255, 0, 64, 0.3);
}

.modal-actions {
    margin-top: 20px;
}

.modal-btn {
    background: linear-gradient(135deg, var(--primary-red), var(--dark-red));
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    color: white;
    font-family: 'Orbitron', monospace;
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(255, 0, 64, 0.3);
}

.modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(255, 0, 64, 0.5);
}

/* ===== FOOTER NOTICE ===== */
.footer-notice {
    padding: 20px 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

.footer-notice .beta-notice {
    color: var(--text-muted);
    opacity: 0.7;
    font-size: 0.8rem;
    font-family: 'Orbitron', monospace;
}

.footer-notice .beta-notice small {
    color: inherit;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    .logo {
        font-size: 1.5rem;
    }

    .params-grid {
        grid-template-columns: 1fr;
    }

    .results-header {
        flex-direction: column;
        align-items: stretch;
    }

    .results-actions {
        justify-content: center;
    }

    .image-gallery {
        grid-template-columns: 1fr;
    }

    .modal-content {
        margin: 10% auto;
        max-width: 95%;
    }
}

@media (max-width: 480px) {
    .control-panel,
    .results-section {
        padding: 20px;
    }

    .generate-btn {
        padding: 15px 30px;
        font-size: 1rem;
    }
}
