/* AI Review Modal - Modern Glassmorphism Style */

.ai-review-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: modalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
    to {
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
}

.ai-review-modal.closing {
    animation: modalFadeOut 0.2s cubic-bezier(0.4, 0, 1, 1) forwards;
}

.ai-review-shell {
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    background: linear-gradient(
        135deg,
        rgba(124, 58, 237, 0.08) 0%,
        rgba(99, 102, 241, 0.06) 50%,
        rgba(79, 70, 229, 0.08) 100%
    );
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: 24px;
    box-shadow: 
        0 20px 60px rgba(124, 58, 237, 0.3),
        0 8px 32px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: shellSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@keyframes shellSlideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes shellSlideDown {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(40px) scale(0.92);
    }
}

.ai-review-shell.closing {
    animation: shellSlideDown 0.25s cubic-bezier(0.4, 0, 1, 1) forwards;
}

/* Header */
.ai-review-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid rgba(124, 58, 237, 0.15);
    background: linear-gradient(180deg, rgba(124, 58, 237, 0.05) 0%, transparent 100%);
}

.ai-review-title-block {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-review-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(99, 102, 241, 0.2));
    border: 1px solid rgba(124, 58, 237, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(124, 58, 237, 0);
    }
}

.ai-review-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--tg-theme-text-color, #eaf2ff);
    margin: 0;
    line-height: 1.2;
    background: linear-gradient(135deg, #a78bfa, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ai-review-close-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid rgba(124, 58, 237, 0.2);
    background: rgba(124, 58, 237, 0.1);
    color: var(--tg-theme-text-color, #eaf2ff);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 16px;
}

.ai-review-close-btn:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: rgba(124, 58, 237, 0.4);
    transform: rotate(90deg) scale(1.1);
}

.ai-review-close-btn:active {
    transform: rotate(90deg) scale(0.95);
}

/* Content */
.ai-review-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Review Text */
.ai-review-text {
    padding: 20px;
    background: var(--tg-theme-bg-color, rgba(18, 23, 29, 0.5));
    border: 1px solid rgba(124, 58, 237, 0.15);
    border-radius: 16px;
    color: var(--tg-theme-text-color, #eaf2ff);
    line-height: 1.7;
    font-size: 15px;
    margin-bottom: 20px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    animation: textFadeIn 0.5s ease-out 0.2s both;
}

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

/* Optimized Banner */
.ai-review-optimized {
    padding: 20px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(22, 163, 74, 0.1));
    border: 2px solid rgba(34, 197, 94, 0.3);
    border-radius: 16px;
    margin-bottom: 20px;
    animation: optimizedBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes optimizedBounce {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.ai-review-optimized-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: rgba(34, 197, 94, 1);
    margin: 0 0 8px 0;
}

.ai-review-optimized-text {
    font-size: 15px;
    color: var(--tg-theme-text-color, #eaf2ff);
    line-height: 1.6;
    margin: 0;
}

/* Recommendations Section */
.ai-review-recommendations {
    margin-bottom: 20px;
    animation: textFadeIn 0.5s ease-out 0.3s both;
}

.ai-review-recommendations-title {
    font-size: 16px;
    font-weight: 600;
    color: rgba(124, 58, 237, 1);
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-review-recommendations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-review-recommendation-item {
    padding: 12px 16px;
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.15);
    border-radius: 12px;
    font-size: 14px;
    color: var(--tg-theme-text-color, #eaf2ff);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    transition: all 0.2s ease;
}

.ai-review-recommendation-item:hover {
    background: rgba(124, 58, 237, 0.12);
    border-color: rgba(124, 58, 237, 0.25);
    transform: translateX(4px);
}

.ai-review-recommendation-badge {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
}

.ai-review-recommendation-badge.add {
    background: rgba(34, 197, 94, 0.2);
    color: rgba(34, 197, 94, 1);
}

.ai-review-recommendation-badge.remove {
    background: rgba(239, 68, 68, 0.2);
    color: rgba(239, 68, 68, 1);
}

/* Loading State */
.ai-review-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 20px;
}

.ai-review-spinner {
    width: 56px;
    height: 56px;
    border: 4px solid rgba(124, 58, 237, 0.2);
    border-top-color: rgba(124, 58, 237, 1);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.ai-review-loading-text {
    font-size: 16px;
    color: var(--tg-theme-hint-color, #98a2b3);
    font-weight: 500;
}

/* Footer */
.ai-review-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(124, 58, 237, 0.15);
    background: linear-gradient(0deg, rgba(124, 58, 237, 0.05) 0%, transparent 100%);
}

.ai-review-apply-btn {
    width: 100%;
    height: 52px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 
        0 4px 16px rgba(124, 58, 237, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.ai-review-apply-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.ai-review-apply-btn:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 24px rgba(124, 58, 237, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.ai-review-apply-btn:hover::before {
    left: 100%;
}

.ai-review-apply-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 
        0 2px 8px rgba(124, 58, 237, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

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

.ai-review-apply-btn-count {
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 640px) {
    .ai-review-modal {
        padding: 0;
        align-items: flex-end;
    }
    
    .ai-review-shell {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 24px 24px 0 0;
    }
    
    .ai-review-header {
        padding: 20px;
    }
    
    .ai-review-icon {
        width: 44px;
        height: 44px;
        font-size: 22px;
    }
    
    .ai-review-title {
        font-size: 20px;
    }
    
    .ai-review-content {
        padding: 20px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .ai-review-modal,
    .ai-review-shell,
    .ai-review-icon,
    .ai-review-close-btn,
    .ai-review-apply-btn,
    .ai-review-text,
    .ai-review-optimized,
    .ai-review-recommendation-item,
    .ai-review-spinner {
        animation: none !important;
        transition: none !important;
    }
}
