/*
 * SPDX-FileCopyrightText: Hadad <hadad@linuxmail.org>
 * SPDX-License-Identifier: Apache-2.0
 */

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    -webkit-font-smoothing: antialiased; 
    -moz-osx-font-smoothing: grayscale; 
}

:root {
    --bg-primary: #0d0d0d;
    --bg-secondary: #151515;
    --bg-tertiary: #1c1c1c;
    --bg-card: #181818;
    --border: rgba(255, 255, 255, 0.05);
    --border-hover: rgba(255, 255, 255, 0.1);
    --text-primary: #fafafa;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --danger: #ef4444;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    word-wrap: break-word;
    word-break: break-word;
}

.gradient-bg {
    background: 
        radial-gradient(
            ellipse at top left, 
            rgba(124, 58, 237, 0.03) 0%, 
            transparent 50%
        ),
        radial-gradient(
            ellipse at bottom right, 
            rgba(236, 72, 153, 0.03) 0%, 
            transparent 50%
        );
    position: fixed;
    inset: 0;
    z-index: -1;
}

.gradient-mesh {
    background-image: 
        radial-gradient(
            at 20% 40%, 
            hsla(280, 70%, 40%, 0.05) 0px, 
            transparent 50%
        ),
        radial-gradient(
            at 80% 20%, 
            hsla(320, 70%, 40%, 0.04) 0px, 
            transparent 50%
        ),
        radial-gradient(
            at 40% 80%, 
            hsla(200, 70%, 40%, 0.03) 0px, 
            transparent 50%
        );
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: 0.8;
    animation: meshFloat 100s ease-in-out infinite;
}

@keyframes meshFloat {
    0%, 100% { 
        transform: translate(0, 0) scale(1) rotate(0deg); 
    }
    33% { 
        transform: translate(-30px, -40px) scale(1.02) rotate(1deg); 
    }
    66% { 
        transform: translate(30px, -30px) scale(0.98) rotate(-1deg); 
    }
}

.card {
    background: rgba(24, 24, 24, 0.4);
    backdrop-filter: blur(60px);
    border: 1px solid var(--border);
    border-radius: clamp(16px, 2vw, 24px);
    transition: all 0.8s cubic-bezier(0.23, 1, 0.320, 1);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        800px circle at var(--mouse-x) var(--mouse-y), 
        rgba(124, 58, 237, 0.02), 
        transparent 40%
    );
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.card:hover::before { 
    opacity: 1; 
}

.card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.btn {
    border-radius: clamp(12px, 1.5vw, 16px);
    font-weight: 600;
    transition: all 0.5s cubic-bezier(0.23, 1, 0.320, 1);
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 1vw, 12px);
    border: none;
    cursor: pointer;
    z-index: 1;
    font-size: clamp(14px, 1.5vw, 16px);
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        45deg, 
        transparent 30%, 
        rgba(255, 255, 255, 0.05) 50%, 
        transparent 70%
    );
    transform: translateX(-100%) skewX(-20deg);
    transition: transform 1.5s;
}

.btn:hover::after { 
    transform: translateX(200%) skewX(-20deg); 
}

.btn-primary {
    background: linear-gradient(
        135deg, 
        var(--accent), 
        var(--accent-hover)
    );
    color: white;
    padding: clamp(14px, 2vw, 20px) clamp(28px, 4vw, 48px);
    box-shadow: 0 8px 32px rgba(124, 58, 237, 0.2);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 16px 40px rgba(124, 58, 237, 0.3);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
    padding: clamp(14px, 2vw, 20px) clamp(28px, 4vw, 48px);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.96);
    backdrop-filter: blur(40px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.4s ease;
    padding: clamp(16px, 2vw, 24px);
}

.modal-content {
    background: linear-gradient(
        135deg, 
        rgba(28, 28, 28, 0.98), 
        rgba(24, 24, 24, 0.98)
    );
    border-radius: clamp(20px, 2.5vw, 32px);
    padding: clamp(24px, 4vw, 48px);
    max-width: min(90%, 720px);
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
    animation: slideUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    word-wrap: break-word;
    word-break: break-word;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(
        from 0deg at 50% 50%, 
        rgba(124, 58, 237, 0.04), 
        rgba(236, 72, 153, 0.04), 
        rgba(59, 130, 246, 0.04), 
        rgba(124, 58, 237, 0.04)
    );
    animation: rotate 90s linear infinite;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0; 
        transform: translateY(60px) scale(0.9); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(124, 58, 237, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 20px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #ec4899);
    transition: width 0.3s ease;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

.image-output-section {
    min-height: clamp(120px, 15vh, 200px);
    border: 2px dashed var(--border);
    border-radius: clamp(20px, 2.5vw, 32px);
    padding: clamp(32px, 4vw, 60px);
    margin-bottom: clamp(32px, 4vw, 56px);
    text-align: center;
    transition: all 0.5s ease;
    background: rgba(24, 24, 24, 0.2);
    position: relative;
    overflow: hidden;
}

.image-output-section.has-images {
    border: none;
    padding: 0;
    background: transparent;
}

.image-grid {
    display: grid;
    gap: clamp(20px, 2.5vw, 36px);
    grid-template-columns: repeat(
        auto-fit, 
        minmax(
            min(100%, clamp(280px, 35vw, 400px)), 
            1fr
        )
    );
    justify-content: center;
    justify-items: center;
    align-items: start;
}

.image-card {
    position: relative;
    border-radius: clamp(16px, 2vw, 24px);
    overflow: hidden;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    transition: all 0.8s cubic-bezier(0.23, 1, 0.320, 1);
    animation: scaleIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    width: 100%;
    max-width: fit-content;
}

.image-card img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.image-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    border-color: rgba(124, 58, 237, 0.2);
}

@keyframes scaleIn {
    from { 
        opacity: 0; 
        transform: scale(0.7) translateY(60px); 
    }
    to { 
        opacity: 1; 
        transform: scale(1) translateY(0); 
    }
}

.image-actions {
    position: absolute;
    top: clamp(16px, 2vw, 24px);
    right: clamp(16px, 2vw, 24px);
    display: flex;
    gap: clamp(10px, 1.5vw, 14px);
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.image-card:hover .image-actions {
    opacity: 1;
    transform: translateY(0);
}

.action-btn {
    width: clamp(40px, 5vw, 52px);
    height: clamp(40px, 5vw, 52px);
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(40px);
    border-radius: clamp(12px, 1.5vw, 18px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: white;
}

.action-btn:hover {
    background: rgba(124, 58, 237, 0.2);
    transform: scale(1.15) rotate(10deg);
    border-color: rgba(124, 58, 237, 0.3);
}

.input-field {
    background: rgba(28, 28, 28, 0.5);
    border: 1px solid var(--border);
    border-radius: clamp(12px, 1.5vw, 18px);
    padding: clamp(16px, 2vw, 22px) clamp(20px, 2.5vw, 28px);
    color: var(--text-primary);
    width: 100%;
    font-size: clamp(14px, 1.5vw, 16px);
    transition: all 0.3s ease;
    outline: none;
}

.input-field:focus {
    border-color: rgba(124, 58, 237, 0.3);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.06);
    background: rgba(28, 28, 28, 0.7);
    transform: translateY(-1px);
}

.select-field {
    appearance: none;
    background-image: url(
        "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%236b7280' d='M8 11L3 6h10z'/%3E%3C/svg%3E"
    );
    background-repeat: no-repeat;
    background-position: right clamp(20px, 2.5vw, 28px) center;
    padding-right: clamp(48px, 6vw, 64px);
    cursor: pointer;
}

.textarea-field {
    resize: vertical;
    min-height: clamp(140px, 20vh, 200px);
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.7;
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.example-card {
    background: rgba(28, 28, 28, 0.3);
    border: 1px solid var(--border);
    border-radius: clamp(14px, 1.8vw, 20px);
    padding: clamp(20px, 2.5vw, 32px);
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.23, 1, 0.320, 1);
    position: relative;
    overflow: hidden;
    word-wrap: break-word;
    word-break: break-word;
}

.example-card p {
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.example-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg, 
        rgba(124, 58, 237, 0.05), 
        rgba(236, 72, 153, 0.05)
    );
    opacity: 0;
    transition: opacity 0.5s;
}

.example-card:hover::before { 
    opacity: 1; 
}

.example-card:hover {
    transform: translateX(12px) scale(1.02);
    border-color: rgba(124, 58, 237, 0.25);
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.3);
}

.loading-spinner {
    width: clamp(24px, 3vw, 32px);
    height: clamp(24px, 3vw, 32px);
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.header-gradient {
    background: linear-gradient(135deg, #7c3aed, #ec4899, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 900;
    background-size: 200% 200%;
    animation: gradientShift 12s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { 
        background-position: 0% 50%; 
    }
    50% { 
        background-position: 100% 50%; 
    }
}

@media (max-width: 144px) {
    body { 
        font-size: 10px; 
    }
    .modal-content { 
        padding: 12px; 
    }
}

@media (min-width: 3840px) {
    body { 
        font-size: 22px; 
    }
}

@media (min-width: 7680px) {
    body { 
        font-size: 36px; 
    }
}