/* ============================================
   Universal Modal System
   Property Reports New Zealand
   ============================================ */

/* Modal Container */
.universal-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.universal-modal.active {
    display: block;
}

/* Modal Overlay */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    cursor: pointer;
}

/* Modal Content Box */
.modal-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 20px;
    padding: 2.5rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
    text-align: center;
    z-index: 10001;
}

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

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Close Button */
.modal-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #718096;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: #f7fafc;
    color: #2d3748;
    transform: rotate(90deg);
}

/* Modal Icon */
.modal-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}

.modal-icon.success {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
}

.modal-icon.error {
    background: linear-gradient(135deg, #f56565, #e53e3e);
    color: white;
}

.modal-icon.warning {
    background: linear-gradient(135deg, #ed8936, #dd6b20);
    color: white;
}

.modal-icon.info {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.modal-icon.question {
    background: linear-gradient(135deg, #4299e1, #3182ce);
    color: white;
}

/* Modal Body */
.modal-body {
    margin-bottom: 2rem;
}

.modal-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 0.75rem;
}

.modal-message {
    font-size: 1.1rem;
    color: #4a5568;
    line-height: 1.6;
    margin: 0;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Modal Buttons */
.modal-btn {
    min-width: 120px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.modal-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modal-btn-primary:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8b 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.modal-btn-success {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
}

.modal-btn-success:hover {
    background: linear-gradient(135deg, #38a169, #2f855a);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
}

.modal-btn-danger {
    background: linear-gradient(135deg, #f56565, #e53e3e);
    color: white;
}

.modal-btn-danger:hover {
    background: linear-gradient(135deg, #e53e3e, #c53030);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 101, 101, 0.4);
}

.modal-btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.modal-btn-secondary:hover {
    background: #cbd5e1;
    color: #2d3748;
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-box {
        padding: 2rem 1.5rem;
        max-width: 95%;
    }
    
    .modal-title {
        font-size: 1.5rem;
    }
    
    .modal-message {
        font-size: 1rem;
    }
    
    .modal-icon {
        width: 60px;
        height: 60px;
        font-size: 2rem;
        margin-bottom: 1rem;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-btn {
        width: 100%;
    }
}

/* Loading State */
.modal-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.modal-btn.loading::after {
    content: "";
    width: 16px;
    height: 16px;
    margin-left: 8px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.6s linear infinite;
}

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

/* Custom Content Support */
.modal-custom-content {
    text-align: left;
}

.modal-custom-content h3 {
    margin-top: 0;
}

.modal-custom-content p {
    margin-bottom: 1rem;
}

/* ============================================
   Purchase Page - Sample Image Modal
   ============================================ */
/* Legacy modal for displaying sample report image */

.purchase-page .modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.9);
}

.purchase-page .modal-content {
    position: relative;
    margin: 60px auto 40px auto;
    width: 800px;
    max-width: 90%;
    background: white;
    padding: 1rem;
    border-radius: 8px;
}

.purchase-page .modal-content img {
    display: block;
    width: 100%;
    height: auto;
}

.purchase-page .close {
    position: fixed;
    top: 20px;
    right: 40px;
    color: #f1f1f1;
    font-size: 50px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
}

.purchase-page .close:hover {
    color: #ccc;
}

@media (max-width: 768px) {
    .purchase-page .modal-content {
        width: 100%;
        margin: 50px auto 20px auto;
        padding: 0.75rem;
    }

    .purchase-page .close {
        top: 10px;
        right: 20px;
    }
}

/* ============================================
   Report Page - Sample Image Modal
   ============================================ */
/* Modal for displaying sample report image */

.report-page .modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.9);
}

.report-page .modal-content {
    position: relative;
    margin: 60px auto 40px auto;
    width: 800px;
    max-width: 90%;
    background: white;
    padding: 1rem;
    border-radius: 8px;
}

.report-page .modal-content img {
    display: block;
    width: 100%;
    height: auto;
}

.report-page .close {
    position: fixed;
    top: 20px;
    right: 35px;
    color: white;
    font-size: 45px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
}

.report-page .close:hover {
    color: #ccc;
}

@media (max-width: 768px) {
    .report-page .modal-content {
        width: 100%;
        margin: 50px auto 20px auto;
        padding: 0.75rem;
    }

    .report-page .close {
        top: 10px;
        right: 20px;
    }
}

/* ============================================
   Sample Modal - Generic (for pages without specific class)
   ============================================ */
/* Used on index.html and other pages */

.sample-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.9);
}

.sample-modal-content {
    position: relative;
    margin: 60px auto 40px auto;
    width: 800px;
    max-width: 90%;
    background: white;
    padding: 1rem;
    border-radius: 8px;
}

.sample-modal-content img {
    display: block;
    width: 100%;
    height: auto;
}

.sample-modal-close {
    position: fixed;
    top: 20px;
    right: 40px;
    color: white;
    font-size: 50px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
}

.sample-modal-close:hover {
    color: #ccc;
}

@media (max-width: 768px) {
    .sample-modal-content {
        width: 100%;
        margin: 50px auto 20px auto;
        padding: 0.75rem;
    }

    .sample-modal-close {
        top: 10px;
        right: 20px;
    }
}
