/* ========================================
   AI Design Generator - Modern Styling
   ======================================== */

/* Root Variables */
:root {
    --primary-color: #000;
    --secondary-color: #333;
    --accent-color: #f0f0f0;
    --border-color: #e0e0e0;
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --success-color: #4caf50;
    --error-color: #f44336;
    --transition-speed: 0.3s;
    --border-radius: 12px;
}

/* Reset & Base Styles */
.ai-design-app {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--text-primary);
    background: #fff;
}

.ai-design-app * {
    box-sizing: border-box;
}

/* Form Container */
.ai-form {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.ai-form-container {
    position: relative;
}

/* Step Animations */
.ai-step {
    display: none;
    animation: fadeIn 0.4s ease;
    opacity: 0;
}

.ai-step.active {
    display: block;
    opacity: 1;
}

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

/* Step Content */
.ai-step-content {
    padding: 20px 0;
}

.ai-step-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.ai-step-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0 0 30px 0;
}

/* Image Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.grid-item {
    position: relative;
    cursor: pointer;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--accent-color);
    transition: all var(--transition-speed) ease;
}

.grid-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.ai-image-btn {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    border: 3px solid transparent;
    border-radius: var(--border-radius);
    transition: all var(--transition-speed) ease;
    cursor: pointer;
}

.ai-image-btn:hover {
    border-color: var(--primary-color);
    transform: scale(1.02);
}

.ai-image-btn.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.grid-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    color: #fff;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

/* Form Groups */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

/* File Input */
.file-input {
    display: none;
}

.file-input-label {
    display: block;
    cursor: pointer;
}

.file-input-box {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 40px 20px;
    text-align: center;
    transition: all var(--transition-speed) ease;
    background: #fafafa;
}

.file-input-box:hover {
    border-color: var(--primary-color);
    background: #f5f5f5;
}

.file-input-label:has(.file-input:focus-visible) .file-input-box {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.upload-text {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.upload-hint {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Textarea */
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    transition: all var(--transition-speed) ease;
    color: var(--text-primary);
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.form-textarea::placeholder {
    color: var(--text-secondary);
}

/* Submit Button - Full Width */
.submit-btn {
    width: 100%;
    padding: 16px 24px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    margin-top: 10px;
}

.submit-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.submit-btn:active {
    transform: translateY(0);
}

/* Spinner */
.ai-spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.loader {
    width: 60px;
    height: 60px;
    border: 4px solid var(--accent-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: rotation 1s linear infinite;
    margin-bottom: 24px;
}

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

.spinner-message {
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 600;
    margin: 0 0 8px 0;
    transition: opacity 0.5s ease;
    min-height: 1.5em;
}

.spinner-hint {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* Result Container */
.result-container {
    margin-top: 30px;
}

.result-image {
    margin-bottom: 30px;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.result-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--border-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* Result Actions */
.result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    border: 2px solid var(--border-color);
    background: #fff;
    color: var(--text-primary);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.action-btn:hover {
    border-color: var(--primary-color);
    background: var(--accent-color);
    transform: translateY(-2px);
}

.download-btn {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.download-btn:hover {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
}

.btn-icon {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

/* Navigation Controls - Sticky on Mobile */
.ai-navigation {
    display: flex;
    gap: 12px;
    margin-top: 30px;
    position: relative;
}

.nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    background: var(--accent-color);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.nav-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

/* Honeypot */
.website-field-wrapper {
    display: none !important;
    position: absolute;
    left: -9999px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ai-form {
        padding: 16px;
    }

    .ai-step-title {
        font-size: 24px;
    }

    .ai-step-subtitle {
        font-size: 14px;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 16px;
        margin-bottom: 24px;
    }

    .grid-label {
        font-size: 12px;
        padding: 8px 12px;
    }

    .file-input-box {
        padding: 30px 16px;
    }

    .upload-icon {
        width: 40px;
        height: 40px;
    }

    .upload-text {
        font-size: 14px;
    }

    .upload-hint {
        font-size: 12px;
    }

    .submit-btn {
        padding: 14px 20px;
        font-size: 15px;
    }

    .result-actions {
        grid-template-columns: 1fr;
    }

    /* Sticky Navigation on Mobile */
    .ai-navigation {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        gap: 0;
        background: #fff;
        border-top: 1px solid var(--border-color);
        padding: 12px;
        z-index: 100;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
    }

    .nav-btn {
        padding: 12px 16px;
        font-size: 13px;
        margin: 0;
        border-radius: 8px;
    }

    .ai-form {
        padding-bottom: 80px;
    }

    .spinner-container {
        padding: 30px 16px;
    }

    .loader {
        width: 50px;
        height: 50px;
        border-width: 3px;
    }

    .spinner-message {
        font-size: 16px;
    }

    .spinner-hint {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .ai-form {
        padding: 12px;
        padding-bottom: 80px;
    }

    .ai-step-title {
        font-size: 20px;
    }

    .ai-step-subtitle {
        font-size: 13px;
        margin-bottom: 20px;
    }

    .image-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 20px;
    }

    .grid-label {
        font-size: 11px;
        padding: 6px 10px;
    }

    .form-group {
        margin-bottom: 16px;
    }

    .file-input-box {
        padding: 24px 12px;
    }

    .upload-icon {
        width: 36px;
        height: 36px;
        margin-bottom: 8px;
    }

    .upload-text {
        font-size: 13px;
        margin-bottom: 2px;
    }

    .upload-hint {
        font-size: 11px;
    }

    .form-textarea {
        font-size: 13px;
        padding: 10px 12px;
    }

    .submit-btn {
        padding: 12px 16px;
        font-size: 14px;
        margin-top: 8px;
    }

    .nav-btn {
        padding: 10px 12px;
        font-size: 12px;
        gap: 4px;
    }

    .nav-btn svg {
        width: 16px;
        height: 16px;
    }

    .action-btn {
        padding: 12px 16px;
        font-size: 13px;
        gap: 6px;
    }

    .btn-icon {
        width: 16px;
        height: 16px;
    }

    .ai-navigation {
        padding: 8px;
    }

    .ai-form {
        padding-bottom: 70px;
    }
}

/* Accessibility */
.ai-image-btn:focus-visible,
.submit-btn:focus-visible,
.nav-btn:focus-visible,
.action-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .ai-navigation,
    .submit-btn,
    .action-btn {
        display: none;
    }
}
