/**
 * Donation Form Overlay Styles
 * =============================
 * Professional overlay system with loading, success, and error states
 */

/* Overlay Container - Hidden by default */
.donation-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999; /* High z-index but reasonable */
    /* Create new stacking context to escape parent z-index constraints */
    isolation: isolate;
}

/* Overlay visible state */
.donation-overlay.active {
    display: block;
}

/* Semi-transparent backdrop */
.overlay-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(2px);
    animation: fadeIn 0.3s ease-out;
}

/* Content container */
.overlay-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1000000;
    animation: slideInScale 0.4s ease-out;
}

/* State containers - hidden by default */
.loading-state-container,
.success-state-container,
.error-state-container {
    display: none;
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    min-width: 320px;
    max-width: 480px;
    position: relative;
}

/* Active states */
.donation-overlay.loading .loading-state-container,
.donation-overlay.success .success-state-container,
.donation-overlay.error .error-state-container {
    display: block;
}

/* Spinner Animation */
.spinner-container {
    margin: 0 auto 24px;
    width: 60px;
    height: 60px;
}

.donation-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Processing State Styles */
.processing-title {
    font-size: 24px;
    color: #333;
    margin: 0 0 12px;
    font-weight: 600;
}

.processing-message {
    font-size: 16px;
    color: #666;
    margin: 0;
    line-height: 1.5;
}

/* Success State Styles */
.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
}

.checkmark {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: block;
    stroke-width: 2;
    stroke: #4bb543;
    stroke-miterlimit: 10;
    animation: checkmarkScale 0.3s ease-in-out 0.3s both;
}

.checkmark-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 2;
    stroke-miterlimit: 10;
    stroke: #4bb543;
    fill: none;
    animation: checkmarkStroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: checkmarkStroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}

@keyframes checkmarkStroke {
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes checkmarkScale {
    0%, 100% {
        transform: none;
    }
    50% {
        transform: scale3d(1.1, 1.1, 1);
    }
}

.success-title {
    font-size: 28px;
    color: #4bb543;
    margin: 0 0 12px;
    font-weight: 600;
}

.success-message {
    font-size: 16px;
    color: #666;
    margin: 0 0 24px;
    line-height: 1.5;
}

/* Donation Summary */
.donation-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin: 24px 0;
    text-align: left;
}

.donation-summary > div {
    margin: 8px 0;
    font-size: 14px;
    color: #333;
}

.donation-summary > div:before {
    content: '• ';
    color: #4bb543;
    font-weight: bold;
    margin-right: 8px;
}

/* Error State Styles */
.error-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    animation: errorShake 0.5s ease-in-out;
}

.error-icon svg {
    width: 100%;
    height: 100%;
    color: #dc3545;
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.error-title {
    font-size: 24px;
    color: #dc3545;
    margin: 0 0 12px;
    font-weight: 600;
}

.error-message {
    font-size: 16px;
    color: #666;
    margin: 0 0 24px;
    line-height: 1.5;
}

/* Close Button */
.overlay-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s ease;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-close-btn:hover {
    background-color: #f0f0f0;
}

.overlay-close-btn:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Action Buttons */
.success-actions,
.error-actions {
    margin-top: 24px;
}

.btn-make-another,
.btn-try-again {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 32px;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
    font-weight: 500;
}

.btn-make-another:hover,
.btn-try-again:hover {
    background: #2980b9;
}

.btn-make-another:focus,
.btn-try-again:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

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

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

/* Exit Animation */
.donation-overlay.hiding {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .overlay-content {
        width: 90%;
        max-width: none;
    }

    .loading-state-container,
    .success-state-container,
    .error-state-container {
        padding: 30px 20px;
        min-width: auto;
    }

    .processing-title,
    .success-title,
    .error-title {
        font-size: 20px;
    }

    .processing-message,
    .success-message,
    .error-message {
        font-size: 14px;
    }
}
