/**
 * Modal Styles
 *
 * Styles for template selection modal and other modals
 * Loaded on: Pages that use modals (subscription popup editor, etc.)
 */

/**
 * Template Selection Modal Styles
 */
#subscription-template-modal {
    position: fixed !important;
    top: 10% !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 800px !important;
    height: auto !important;
    background: none !important;
    z-index: 999999 !important;
    display: none !important;
    transition: all 0.3s ease !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    /* Override blocker styles from main modal.css */
    right: auto !important;
    bottom: auto !important;
    padding: 0 !important;
    box-sizing: content-box !important;
    overflow: visible !important;
    text-align: left !important;
}

/* Ensure no blocker overlay is applied */
#subscription-template-modal:before {
    display: none !important;
    content: none !important;
}

/* Override any modal library blocker styles */
.blocker #subscription-template-modal,
#subscription-template-modal.blocker {
    position: fixed !important;
    top: 10% !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 800px !important;
    height: auto !important;
    background: none !important;
    background-color: transparent !important;
    right: auto !important;
    bottom: auto !important;
    padding: 0 !important;
    box-sizing: content-box !important;
    overflow: visible !important;
    text-align: left !important;
}

/* Prevent blocker pseudo-element */
.blocker #subscription-template-modal:before,
#subscription-template-modal.blocker:before {
    display: none !important;
    content: none !important;
}

#subscription-template-modal.show {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    background: none !important;
    background-color: transparent !important;
}

.template-selection-modal .modal-content {
    background: #ffffff;
    border-radius: 8px;
    max-width: 800px;
    max-height: 85vh;
    width: 800px;
    position: relative;
    overflow: hidden;
    box-shadow: none;
    border: 1px solid #ddd;
    transition: transform 0.3s ease;
}

#subscription-template-modal.show .modal-content {
    transform: none;
}

.template-selection-modal .modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
}

.template-selection-modal .modal-header h3 {
    margin: 0;
    font-size: 20px;
    color: #333;
    font-weight: 600;
}

.template-selection-modal .close-modal {
    font-size: 24px;
    cursor: pointer;
    color: #999;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
    transition: color 0.3s ease;
}

.template-selection-modal .close-modal:hover {
    color: #333;
}

.template-selection-modal .modal-body {
    padding: 0;
    max-height: calc(85vh - 80px);
    overflow-y: auto;
    background: #fff;
}

/* Template Selection Content */
.template-selection-modal .template_selection_wrapper {
    margin: 0;
    padding: 25px;
    max-width: none;
}

.template-selection-modal .ipb_new_heading {
    margin-bottom: 20px;
    text-align: center;
}

.template-selection-modal .ipb_new_heading h3 {
    display: none; /* Hide since we have it in modal header */
}

.template-selection-modal .ipb_new_heading p {
    font-size: 14px;
    color: #666;
    margin: 0;
}

.template-selection-modal .ipb_template_search {
    margin-bottom: 25px;
    display: flex;
    justify-content: center;
}

.template-selection-modal .ipb_ext_search {
    max-width: 300px;
    width: 100%;
}

.template-selection-modal .ipb_ext_search input {
    padding: 10px 15px;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid #ddd;
    width: 100%;
    box-sizing: border-box;
}

/* Force exactly 3 columns */
.template-selection-modal .subscription_templates_grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Exactly 3 columns */
    gap: 20px;
    margin-bottom: 25px;
}

.template-selection-modal .template_card {
    background: #fff;
    border-radius: 8px;
    box-shadow: none;
    transition: transform 0.3s ease;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid #e5e5e5;
}

.template-selection-modal .template_card:hover {
    transform: translateY(-2px);
    box-shadow: none;
    border-color: #007cba;
}

.template-selection-modal .template_preview {
    height: 160px;
    overflow: hidden;
    position: relative;
    background: #f8f9fa;
}

.template-selection-modal .template-preview-img {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.template-selection-modal .preview-content {
    text-align: center;
    width: 80%;
    transform: scale(0.75);
}

.template-selection-modal .preview-title {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.template-selection-modal .preview-form {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
}

.template-selection-modal .preview-input {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.1);
}

.template-selection-modal .preview-button {
    width: 60%;
    height: 12px;
    border-radius: 6px;
    background: #007cba;
    margin-top: 4px;
}

.template-selection-modal .template_overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.template-selection-modal .template_card:hover .template_overlay {
    opacity: 1;
}

.template-selection-modal .preview_btn,
.template-selection-modal .select_btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: all 0.3s ease;
    text-decoration: none;
}

.template-selection-modal .preview_btn {
    background: #fff;
    color: #333;
}

.template-selection-modal .select_btn {
    background: #007cba;
    color: #fff;
}

.template-selection-modal .template_info {
    padding: 15px;
    background: #fff;
}

.template-selection-modal .template_info h4 {
    margin: 0 0 6px 0;
    font-size: 15px;
    color: #333;
    font-weight: 600;
}

.template-selection-modal .template_info p {
    margin: 0 0 10px 0;
    color: #666;
    line-height: 1.4;
    font-size: 12px;
}

.template-selection-modal .template_features {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.template-selection-modal .feature_tag {
    background: #f0f8ff;
    color: #007cba;
    padding: 3px 7px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 500;
}

.template-selection-modal .blank_template_section {
    border-top: 1px solid #eee;
    padding-top: 20px;
    margin-top: 10px;
    display: flex;
    justify-content: center;
}

.template-selection-modal .blank_template .template_preview {
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-selection-modal .blank_icon {
    font-size: 32px;
    color: #ccc;
}

.template-selection-modal .blank_template:hover .blank_icon {
    color: #007cba;
}

/* Make sure modal appears above everything */
body.modal-open {
    /* overflow: hidden; */ /* Removed to allow background interaction */
}

.template-selection-modal .template_preview_modal {
    z-index: 1000000;
}

/* Animation classes */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#subscription-template-modal .modal-content {
    /* animation: slideIn 0.3s ease-out; */ /* Removed animation */
}
