/* Modal Preview */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.modal {
    background: var(--color-bg-darker);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 800px;
    height: auto;
    max-height: calc(100vh - 2rem);
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    touch-action: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem var(--spacing-md);
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.modal-title {
    color: var(--color-text-link);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-base);
}

.modal-close {
    background: transparent;
    border: 0;
    color: var(--color-primary-light);
    font-size: 1.2rem;
    cursor: pointer;
    padding: var(--spacing-sm);
    line-height: 1;
    transition: color var(--transition-fast);
    -webkit-tap-highlight-color: rgba(96, 165, 250, 0.3);
    touch-action: manipulation;
    min-width: 44px;
    min-height: 44px;
}

.modal-close:hover {
    color: var(--color-primary);
}

.modal-body {
    position: relative;
    flex: 1;
    background: var(--color-bg-input);
    height: 500px;
    min-height: 400px;
}

.modal-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--color-bg-input);
    touch-action: auto;
    pointer-events: auto;
}

.modal-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--color-primary-light);
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .modal-overlay {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }
    
    .modal {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100dvh;
        min-height: 100dvh;
        border-radius: 0;
        margin: 0;
        border: none;
    }
    
    .modal-header {
        padding: 0.5rem 1rem;
        position: sticky;
        top: 0;
        z-index: 10;
        flex-shrink: 0;
    }
    
    .modal-body {
        flex: 1;
        height: auto;
        min-height: 0;
        overflow: hidden;
    }
    
    .modal-body .embed-responsive {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
    }
    
    .modal-frame {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        min-height: 0;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .modal-title {
        font-size: 0.9rem;
    }
    
    .modal-close {
        padding: 0.75rem;
    }
}
