/* ImagiChat - Professional AI Image Generator */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* Reset & Base */
.imagi-app * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.imagi-app {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-glow: rgba(99, 102, 241, 0.35);
    --bg-dark: #0f0f14;
    --bg-card: #16161d;
    --bg-input: #1c1c26;
    --bg-hover: #22222e;
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border: rgba(255, 255, 255, 0.06);
    --success: #10b981;
    --error: #ef4444;
    --radius: 20px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    min-height: 100vh;
    padding: 40px 20px;
    color: var(--text-primary);
}

/* Main Generator Container */
.imagi-generator {
    max-width: 700px;
    margin: 0 auto 60px;
    text-align: center;
}

/* Header */
.imagi-header {
    margin-bottom: 40px;
}

.imagi-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.imagi-icon {
    font-size: 2.5rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.imagi-logo h1 {
    font-size: 2.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, var(--primary-light) 50%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.imagi-tagline {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Input Area */
.imagi-input-wrapper {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 8px;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.imagi-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow), 0 4px 24px rgba(0, 0, 0, 0.3);
}

#imagi-prompt {
    width: 100%;
    background: transparent;
    border: none;
    padding: 20px;
    font-size: 1.1rem;
    color: var(--text-primary);
    resize: none;
    font-family: inherit;
    line-height: 1.6;
}

#imagi-prompt:focus {
    outline: none;
}

#imagi-prompt::placeholder {
    color: var(--text-muted);
}

/* Generate Button */
.imagi-btn-generate {
    width: 100%;
    padding: 18px 32px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.imagi-btn-generate::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: left 0.5s ease;
}

.imagi-btn-generate:hover::before {
    left: 100%;
}

.imagi-btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--primary-glow);
}

.imagi-btn-generate:active {
    transform: translateY(0);
}

.imagi-btn-generate .btn-loader {
    display: none;
}

.imagi-btn-generate.loading .btn-text {
    display: none;
}

.imagi-btn-generate.loading .btn-loader {
    display: flex;
    align-items: center;
    gap: 10px;
}

.imagi-btn-generate.loading {
    pointer-events: none;
}

.spinner {
    width: 24px;
    height: 24px;
    animation: rotate 1s linear infinite;
}

.spinner circle {
    stroke: white;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate {
    100% { transform: rotate(360deg); }
}

@keyframes dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

/* Suggestions */
.imagi-suggestions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.imagi-suggestions > span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.imagi-suggestion {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 99px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.imagi-suggestion:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* Result Area */
.imagi-result {
    margin-top: 40px;
    display: none;
}

.imagi-result.show {
    display: block;
    animation: fadeUp 0.5s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.imagi-result-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.imagi-result-image {
    position: relative;
    aspect-ratio: 1;
    background: var(--bg-input);
}

.imagi-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.imagi-result-actions {
    padding: 20px;
    display: flex;
    gap: 12px;
}

.imagi-btn {
    flex: 1;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.imagi-btn-primary {
    background: var(--primary);
    color: white;
    border: none;
}

.imagi-btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.imagi-btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.imagi-btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

/* Processing State */
.imagi-processing {
    padding: 60px 20px;
    text-align: center;
}

.imagi-processing-animation {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    position: relative;
}

.imagi-processing-animation::before,
.imagi-processing-animation::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
}

.imagi-processing-animation::after {
    inset: 8px;
    border-top-color: var(--primary-light);
    animation-duration: 1.5s;
    animation-direction: reverse;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.imagi-processing h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.imagi-processing p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Error */
.imagi-error {
    display: none;
    margin-top: 20px;
    padding: 16px 20px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 0.95rem;
    text-align: left;
}

.imagi-error.show {
    display: block;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

/* History Section */
.imagi-history {
    max-width: 1000px;
    margin: 0 auto;
}

.imagi-history-header {
    margin-bottom: 24px;
    text-align: center;
}

.imagi-history-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.imagi-history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.imagi-history-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.imagi-history-empty svg {
    margin-bottom: 16px;
    opacity: 0.4;
}

.imagi-history-item {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.3s ease;
}

.imagi-history-item:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    border-color: var(--primary);
}

.imagi-history-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.imagi-history-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 16px;
}

.imagi-history-item:hover .imagi-history-overlay {
    opacity: 1;
}

.imagi-history-prompt {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.8);
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.imagi-history-actions {
    display: flex;
    gap: 8px;
}

.imagi-history-btn {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-xs);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none;
    border: none;
}

.imagi-history-btn.download {
    background: white;
    color: #0f0f14;
}

.imagi-history-btn.reuse {
    background: var(--primary);
    color: white;
}

.imagi-history-btn.delete {
    background: var(--error);
    color: white;
    flex: 0;
    padding: 10px 12px;
}

.imagi-history-btn:hover {
    transform: scale(1.05);
}

/* Responsive */
@media (max-width: 600px) {
    .imagi-app {
        padding: 20px 16px;
    }
    
    .imagi-logo h1 {
        font-size: 2rem;
    }
    
    .imagi-tagline {
        font-size: 0.95rem;
    }
    
    #imagi-prompt {
        font-size: 1rem;
        padding: 16px;
    }
    
    .imagi-btn-generate {
        padding: 16px;
        font-size: 1rem;
    }
    
    .imagi-suggestions {
        gap: 8px;
    }
    
    .imagi-suggestion {
        padding: 8px 14px;
        font-size: 0.8rem;
    }
    
    .imagi-history-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .imagi-result-actions {
        flex-direction: column;
    }
}

/* Loading shimmer effect */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.imagi-loading-placeholder {
    background: linear-gradient(90deg, var(--bg-input) 25%, var(--bg-hover) 50%, var(--bg-input) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}
