/* App Frame Modal Styles - Apple iOS Card Aesthetic */

.app-frame-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 10000;
    display: none;
    opacity: 0;
    transition: opacity 0.28s ease;
    align-items: center;
    justify-content: center;
}

.app-frame-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.app-frame-modal {
    position: relative;
    background: #ffffff;
    width: 90vw;
    max-width: 1120px;
    height: 86vh;
    max-height: 880px;
    border-radius: 36px;
    box-shadow: 0 25px 65px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    transform: scale(0.92);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
}

.app-frame-modal-overlay.active .app-frame-modal {
    transform: scale(1);
}

/* Floating Controls above the Card (matching Calculator modal) */
.app-frame-close-btn {
    position: absolute;
    top: -42px;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    color: #333;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    transition: background 0.2s, transform 0.2s;
    z-index: 10;
}

.app-frame-close-btn:hover {
    background: #ffffff;
    transform: scale(1.08);
}

.app-frame-external-btn {
    position: absolute;
    top: -42px;
    left: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    transition: background 0.2s, transform 0.2s, color 0.2s;
    z-index: 10;
    text-decoration: none;
}

.app-frame-external-btn:hover {
    background: #ffffff;
    transform: scale(1.08);
    color: #007aff;
}

.app-frame-title-pill {
    position: absolute;
    top: -42px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 18px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    font-weight: 600;
    color: #1d1d1f;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.app-frame-title-pill img {
    width: 18px;
    height: 18px;
    border-radius: 4px;
}

/* Modal Internal Body */
.app-frame-body {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 36px;
    overflow: hidden;
    background: #fbfbfd;
}

.app-frame-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    border-radius: 36px;
}

/* Loading State */
.app-frame-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 5;
    border-radius: 36px;
    transition: opacity 0.25s ease;
}

.app-ios-spinner {
    width: 38px;
    height: 38px;
    border: 3.5px solid rgba(0, 122, 255, 0.18);
    border-top-color: #007aff;
    border-radius: 50%;
    animation: appSpinnerRotate 0.8s linear infinite;
}

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

.app-frame-loader span {
    font-size: 14px;
    color: #86868b;
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-frame-modal {
        width: 95vw;
        height: 88vh;
        border-radius: 24px;
    }
    .app-frame-body,
    .app-frame-body iframe,
    .app-frame-loader {
        border-radius: 24px;
    }
    .app-frame-title-pill {
        display: none;
    }
}

/* Dark Mode Support */
body[data-theme='dark'] .app-frame-modal {
    background: #1c1c1e;
    box-shadow: 0 25px 65px rgba(0, 0, 0, 0.7);
}

body[data-theme='dark'] .app-frame-close-btn,
body[data-theme='dark'] .app-frame-external-btn,
body[data-theme='dark'] .app-frame-title-pill {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

body[data-theme='dark'] .app-frame-close-btn:hover,
body[data-theme='dark'] .app-frame-external-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

body[data-theme='dark'] .app-frame-body {
    background: #121214;
}

body[data-theme='dark'] .app-frame-loader {
    background: rgba(28, 28, 30, 0.95);
}

body[data-theme='dark'] .app-frame-loader span {
    color: #a1a1a6;
}
