/* In-App Modal Styles - For Desktop and iPad */

.in-app-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.in-app-modal.active {
    opacity: 1;
    visibility: visible;
}

.in-app-modal-content {
    width: 90%;
    height: 90%;
    max-width: 1200px;
    max-height: 85vh;
    background: linear-gradient(135deg, rgba(10, 15, 35, 0.98), rgba(20, 25, 45, 0.98));
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 
        0 40px 100px rgba(0, 0, 0, 0.6),
        0 0 80px rgba(0, 247, 255, 0.4),
        0 0 120px rgba(255, 0, 247, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(0, 247, 255, 0.5);
    display: flex;
    flex-direction: column;
    transform: scale(0.85) translateY(30px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.in-app-modal.active .in-app-modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Modal Header */
.in-app-modal-header {
    background: linear-gradient(135deg, rgba(0, 247, 255, 0.18), rgba(255, 0, 247, 0.18));
    padding: 1.3rem 1.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid rgba(0, 247, 255, 0.35);
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
}

.in-app-modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: headerShine 3s ease-in-out infinite;
}

@keyframes headerShine {
    0% { left: -100%; }
    50%, 100% { left: 200%; }
}

.in-app-modal-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.in-app-modal-title .app-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 0 10px rgba(0, 247, 255, 0.6));
}

.in-app-modal-title h2 {
    font-size: 1.6rem;
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
    background: linear-gradient(45deg, #00f7ff, #ff00f7, #8a2be2);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    animation: titleGradient 3s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(0, 247, 255, 0.6));
}

@keyframes titleGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.in-app-modal-controls {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.modal-control-btn {
    background: rgba(0, 247, 255, 0.12);
    border: 2px solid rgba(0, 247, 255, 0.35);
    border-radius: 12px;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #00f7ff;
    padding: 0;
    position: relative;
    overflow: hidden;
}

.modal-control-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(0, 247, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.modal-control-btn:hover {
    background: rgba(0, 247, 255, 0.25);
    border-color: #00f7ff;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 247, 255, 0.5);
}

.modal-control-btn:hover::before {
    width: 100%;
    height: 100%;
}

.modal-control-btn:active {
    transform: translateY(0);
}

.modal-control-btn svg {
    width: 20px;
    height: 20px;
}

.close-app-modal {
    background: rgba(255, 0, 100, 0.12);
    border-color: rgba(255, 0, 100, 0.35);
    color: #ff0064;
}

.close-app-modal::before {
    background: rgba(255, 0, 100, 0.3);
}

.close-app-modal:hover {
    background: rgba(255, 0, 100, 0.25);
    border-color: #ff0064;
    box-shadow: 0 8px 25px rgba(255, 0, 100, 0.5);
    transform: translateY(-3px) scale(1.05) rotate(90deg);
}

/* Modal Body */
.in-app-modal-body {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #000;
    pointer-events: auto;
}

.in-app-modal-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    pointer-events: auto;
    user-select: auto;
    -webkit-user-select: auto;
    -moz-user-select: auto;
    -ms-user-select: auto;
}

/* Loading State */
.in-app-modal-body::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    margin: -30px 0 0 -30px;
    border: 4px solid rgba(0, 247, 255, 0.2);
    border-top-color: #00f7ff;
    border-radius: 50%;
    animation: modalSpinner 1s linear infinite;
    z-index: 1;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.in-app-modal-body::after {
    content: 'Loading App...';
    position: absolute;
    top: calc(50% + 50px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2rem;
    color: #00f7ff;
    font-family: 'Orbitron', sans-serif;
    animation: loadingPulse 1.5s ease-in-out infinite;
    z-index: 1;
    pointer-events: none;
    text-shadow: 0 0 20px rgba(0, 247, 255, 0.6);
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Hide loading indicator when iframe is loaded */
.in-app-modal-body.loaded::before,
.in-app-modal-body.loaded::after {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

@keyframes modalSpinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes loadingPulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* Day Theme Styles */
[data-theme="day"] .in-app-modal {
    background: rgba(255, 255, 255, 0.9);
}

[data-theme="day"] .in-app-modal-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(245, 245, 250, 0.98));
    border-color: rgba(255, 107, 53, 0.4);
    box-shadow: 
        0 30px 80px rgba(0, 0, 0, 0.3),
        0 0 60px rgba(255, 107, 53, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

[data-theme="day"] .in-app-modal-header {
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.15), rgba(255, 23, 68, 0.15));
    border-bottom-color: rgba(255, 107, 53, 0.3);
}

[data-theme="day"] .in-app-modal-title h2 {
    background: linear-gradient(45deg, #ff6b35, #ff1744);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(255, 107, 53, 0.5);
}

[data-theme="day"] .modal-control-btn {
    background: rgba(255, 107, 53, 0.1);
    border-color: rgba(255, 107, 53, 0.3);
    color: #ff6b35;
}

[data-theme="day"] .modal-control-btn:hover {
    background: rgba(255, 107, 53, 0.2);
    border-color: #ff6b35;
    box-shadow: 0 5px 20px rgba(255, 107, 53, 0.4);
}

[data-theme="day"] .close-app-modal {
    background: rgba(255, 0, 100, 0.1);
    border-color: rgba(255, 0, 100, 0.3);
    color: #ff0064;
}

[data-theme="day"] .close-app-modal:hover {
    background: rgba(255, 0, 100, 0.2);
    border-color: #ff0064;
    box-shadow: 0 5px 20px rgba(255, 0, 100, 0.4);
}

[data-theme="day"] .in-app-modal-body::before {
    color: #ff6b35;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .in-app-modal-content {
        width: 98%;
        height: 98%;
    }
    
    .in-app-modal-header {
        padding: 1rem;
    }
    
    .in-app-modal-title h2 {
        font-size: 1.2rem;
    }
    
    .modal-control-btn {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 768px) {
    .in-app-modal-title h2 {
        font-size: 1rem;
    }
    
    .in-app-modal-title .app-icon {
        font-size: 1.5rem;
    }
    
    .modal-control-btn {
        width: 36px;
        height: 36px;
        gap: 0.5rem;
    }
    
    .modal-control-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* Performance Optimizations */
.in-app-modal-content {
    will-change: transform;
}

.in-app-modal-body iframe {
    will-change: contents;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .in-app-modal,
    .in-app-modal-content,
    .modal-control-btn {
        transition: none !important;
        animation: none !important;
    }
}
