/* App Page Specific Styles - All scoped under .application-page */

/* Application page layout */
.application-page .application-section {
    padding: 20px 0;
    min-height: calc(100vh - 100px);
}

/* Ensure container centering for app page */
.application-page main .container {
    max-width: 1200px;
    /* Same as other pages */
    margin: 0 auto;
    padding: 0 20px;
}

.application-page .app-layout {
    display: grid;
    grid-template-columns: 0.54fr 1fr;
    /* ~35/65 ratio with gap properly handled */
    gap: 30px;
    align-items: stretch;
}

@media (max-width: 992px) {
    .application-page .app-layout {
        grid-template-columns: 1fr;
    }

    .application-page main .container {
        max-width: 100%;
        padding: 0 15px;
        /* Slightly less padding on mobile */
    }

    .application-page .result-display {
        max-height: none;
        overflow: visible;
    }

    .application-page .image-gallery {
        grid-template-columns: 1fr;
    }
}

/* Left panel - Upload area */
.application-page .app-left-panel {
    background-color: var(--card-bg);
    border-radius: 12px;
    /* Standardized */
    padding: 30px;
    border: 1px solid #e0e0e0;
    /* Visible border */
    display: flex;
    flex-direction: column;
}

.application-page .upload-panel {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Custom scrollbar styling */
.application-page .upload-panel::-webkit-scrollbar {
    width: 8px;
}

.application-page .upload-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.application-page .upload-panel::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 4px;
}

.application-page .upload-panel::-webkit-scrollbar-thumb:hover {
    background: #888;
}

.application-page .upload-header h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-color);
}

.application-page .upload-header p {
    font-size: 14px;
    color: #aaa;
    margin-top: 0;
    margin-bottom: 15px;
}

.application-page .upload-header {
    margin-bottom: 10px;
}

.application-page .upload-area {
    background-color: rgba(255, 255, 255, 0.05);
    background-image: url("../images/decorviz-upload-bg.jpeg");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    border: 2px dashed #e0e0e0;
    border-radius: 12px;
    /* Standardized from 8px */
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.application-page .upload-area.has-image {
    padding: 0;
    border: none;
    background-color: transparent;
    background-image: none;
}

.application-page .upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(255, 120, 70, 0.05);
}

.application-page .prompt-area textarea {
    width: 100%;
    min-height: 80px;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    /* Standardized from 8px */
    color: var(--text-color);
    font-family: 'Poppins', sans-serif;
    font-size: 16px;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.application-page .prompt-area textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: rgba(255, 120, 70, 0.05);
}

.application-page .prompt-area textarea::placeholder {
    color: #aaa;
    font-size: 14px;
}

.application-page .image-preview {
    width: 100%;
    position: relative;
}

.application-page .image-preview p {
    color: #555;
    font-size: 16px;
    font-weight: 500;
}

.application-page .optional-tag {
    font-size: 13px;
    font-weight: 500;
    color: #888;
}

.application-page .image-preview .image-container {
    position: relative;
    width: 100%;
    padding-bottom: 50%;
    /* Reduced from 75% to make it shorter */
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    overflow: hidden;
}

.application-page .image-preview img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
}

.application-page .remove-image-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 32px;
    height: 32px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
    z-index: 10;
}

.application-page .remove-image-btn:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.application-page .file-input {
    display: none;
}

.application-page .upload-spacer {
    height: 20px;
}

.application-page .generate-button-container {
    margin-top: 20px;
}

.application-page .generate-btn {
    width: 100%;
    padding: 15px 30px;
    background: linear-gradient(90deg, var(--primary-color), #ff9a46, #ff5e62, var(--primary-color));
    background-size: 300% auto;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
    animation: gradient 4s linear infinite;
}

.application-page .generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 120, 70, 0.4);
    animation: gradient 1s linear infinite;
}

.application-page .generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    animation: none;
}

.application-page .disclaimer-text {
    margin-top: 15px;
    text-align: center;
}

.application-page .disclaimer-text p {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* Right panel - Result area */
.application-page .app-right-panel {
    background-color: var(--card-bg);
    border-radius: 12px;
    /* Standardized */
    padding: 30px;
    border: 1px solid #e0e0e0;
    /* Visible border */
    display: flex;
    flex-direction: column;
}

.application-page .result-header h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 15px;
    /* Increased from 5px for better spacing */
    color: var(--text-color);
}

.application-page .result-display {
    background-color: rgba(255, 255, 255, 0.05);
    border: none;
    /* No border */
    border-radius: 12px;
    /* Standardized from 8px */
    padding: 0;
    /* No padding */
    text-align: center;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow-y: auto;
    /* Scroll functionality */
    max-height: calc(100vh - 200px);
    /* Dynamic height based on viewport */
}

.application-page .result-display.has-image {
    padding: 10px;
    /* Reduced padding when has images */
    padding-right: 15px;
    /* Extra padding for scrollbar */
    border: none;
    background-color: transparent;
}

/* Custom scrollbar styling for result display */
.application-page .result-display::-webkit-scrollbar {
    width: 8px;
}

.application-page .result-display::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.application-page .result-display::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 4px;
}

.application-page .result-display::-webkit-scrollbar-thumb:hover {
    background: #888;
}

.application-page .image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.application-page .gallery-item {
    position: relative;
    width: 100%;
    padding-bottom: 75%;
    /* 4:3 aspect ratio */
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    overflow: hidden;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.application-page .gallery-item:hover {
    opacity: 0.9;
}

.application-page .gallery-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
    /* Browser-level optimization for thumbnails */
    image-rendering: auto;
    /* Decode images off main thread for smooth scrolling */
    decoding: async;
    /* Add smooth fade-in when loaded */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.application-page .gallery-item img.loaded {
    opacity: 1;
}

/* Placeholder while image loads */
.application-page .gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    border-radius: 5px;
    z-index: -1;
}

.application-page .gallery-actions {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    justify-content: space-between;
    z-index: 10;
}

.application-page .download-result-btn,
.application-page .delete-result-btn {
    width: 36px;
    height: 36px;
    background-color: rgba(0, 0, 0, 0.55);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 999px;
    font-size: 0;
    line-height: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.application-page .gallery-actions button svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

.application-page .download-result-btn:hover {
    background-color: #4CAF50;
    border-color: #4CAF50;
    transform: scale(1.1);
}

.application-page .delete-result-btn:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(1.1);
}

/* Processing indicator */
.application-page .processing-indicator {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
}

.application-page .processing-indicator p {
    color: var(--text-color);
    font-size: 18px;
    margin-bottom: 20px;
}

/* Generating placeholder in gallery */
.application-page .gallery-item.generating {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 120, 70, 0.3);
    min-height: 200px;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    cursor: default;
    /* Not clickable */
    pointer-events: none;
    /* Disable all click events */
    padding-bottom: 0 !important;
    /* Override base gallery-item padding */
}

.application-page .gallery-item.failed {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: rgba(255, 70, 70, 0.05);
    border: 2px solid rgba(255, 70, 70, 0.3);
    min-height: 200px;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    cursor: default;
    /* Not clickable */
    pointer-events: none;
    /* Disable all click events */
    padding-bottom: 0 !important;
    /* Override base gallery-item padding */
}

.application-page .generating-placeholder {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 15px;
    width: 100%;
    height: 100%;
}

.application-page .generating-placeholder p {
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 500;
    margin: 0;
}

.application-page .gallery-item.failed .generating-placeholder p {
    color: #ff6b6b;
    text-align: center;
    padding: 0 15px;
}

.application-page .spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Result overlay buttons */
.application-page .result-overlay {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.application-page .download-btn,
.application-page .share-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
}

.application-page .download-btn {
    background-color: var(--primary-color);
    color: white;
}

.application-page .download-btn:hover {
    background-color: #ff9a46;
    transform: translateY(-2px);
}

.application-page .share-btn {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.application-page .share-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Header adjustment for app page */
.application-page header {
    border-bottom: 1px solid var(--border-color);
}

.application-page .header-divider {
    flex-grow: 1;
}

/* Fullscreen image modal */
.application-page .image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.application-page .image-modal.active {
    display: flex;
}

.application-page .image-modal img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: 5px;
}

.application-page .modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    color: white;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.application-page .modal-close:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.application-page .app-header-info {
    display: flex;
    align-items: center;
    gap: 30px;
}

.application-page .credits-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: rgba(255, 120, 70, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(255, 120, 70, 0.3);
}

.application-page .credits-label {
    font-size: 14px;
    color: #aaa;
    font-weight: 500;
}

.application-page .credits-count {
    font-size: 16px;
    color: var(--primary-color);
    font-weight: 700;
}

.application-page .profile-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 25px;
    transition: background-color 0.3s ease;
}

.application-page .profile-info:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.application-page .profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #ff9a46);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: white;
}

.application-page .profile-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
}

@media (max-width: 768px) {
    .application-page .app-header-info {
        gap: 15px;
    }

    .application-page .profile-name {
        display: none;
    }

    .application-page .credits-info {
        padding: 6px 12px;
    }

    .application-page .credits-label,
    .application-page .credits-count {
        font-size: 12px;
    }

    .application-page .download-result-btn,
    .application-page .delete-result-btn {
        width: 44px;
        height: 44px;
    }

    .application-page .gallery-actions button svg {
        width: 20px;
        height: 20px;
    }

    .application-page .result-display {
        max-height: none;
        overflow: visible;
        height: auto;
    }

    .application-page .image-gallery {
        grid-template-columns: 1fr;
    }
}

/* Error message styling */
.application-page .error-message {
    background-color: rgba(255, 82, 82, 0.1);
    border: 2px solid rgba(255, 82, 82, 0.3);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    animation: slideIn 0.3s ease-out;
}

.application-page .error-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.application-page .error-icon {
    font-size: 24px;
    color: #ff5252;
    flex-shrink: 0;
}

.application-page .error-text {
    flex: 1;
    color: #ffb3b3;
    font-size: 14px;
    line-height: 1.5;
}

.application-page .error-close {
    background: none;
    border: none;
    color: #ffb3b3;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
    flex-shrink: 0;
}

.application-page .error-close:hover {
    color: #ff5252;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}
