/**
 * Tailwind Modal System - Standardized CSS with Sleek Animations
 * 
 * Usage:
 * - Add class 'modal-spark-backdrop' to backdrop div
 * - Add class 'modal-spark' to modal content div
 * - Use data-modal-open="modalId" to open
 * - Use data-modal-close="modalId" to close
 */

/* Modal Animation Keyframes */
@keyframes modal-backdrop-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modal-backdrop-fade-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes modal-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes modal-slide-down {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
}

/* Modal Backdrop - Hidden by default */
/* CRITICAL: display:none by default, only show with .modal-open class */
.modal-spark-backdrop {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none !important;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    backdrop-filter: blur(0px);
    transition: backdrop-filter 0.3s ease;
}

/* Modal Backdrop - Opening state */
.modal-spark-backdrop.modal-open {
    display: flex !important;
    animation: modal-backdrop-fade-in 0.25s ease-out forwards;
    backdrop-filter: blur(4px);
}

/* Modal Backdrop - Closing state */
.modal-spark-backdrop.modal-closing {
    animation: modal-backdrop-fade-out 0.2s ease-in forwards;
    backdrop-filter: blur(0px);
}

/* Modal Content Container */
.modal-spark {
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: none;
}

/* Modal Content - Opening state */
.modal-spark-backdrop.modal-open .modal-spark {
    animation: modal-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Modal Content - Closing state */
.modal-spark-backdrop.modal-closing .modal-spark {
    animation: modal-slide-down 0.2s ease-in forwards;
}

/* Modal Header */
.modal-spark-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
}

.modal-spark-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-spark-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: #64748b;
    font-size: 1.25rem;
    line-height: 1;
    transition: color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-spark-close:hover {
    color: #1e293b;
}

/* Modal Body */
.modal-spark-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* Modal Footer */
.modal-spark-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    background: #f8fafc;
}

/* Modal Buttons */
.btn-spark-primary,
.btn-spark-secondary,
.btn-spark-danger,
.btn-spark-warning {
    height: 32px;
    padding: 0 1rem;
    border-radius: 2px;
    border: none;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-spark-primary {
    background: #0078d4;
    color: white;
}

.btn-spark-primary:hover {
    background: #106ebe;
}

.btn-spark-secondary {
    background: #605e5c;
    color: #ffffff;
}

.btn-spark-secondary:hover {
    background: #484644;
}

.btn-spark-danger {
    background: #d13438;
    color: white;
}

.btn-spark-danger:hover {
    background: #b52b2f;
}

.btn-spark-warning {
    background: #f59e0b;
    color: white;
}

.btn-spark-warning:hover {
    background: #d97706;
    color: white;
    text-decoration: none;
}

.btn-spark-info {
    background: #0ea5e9;
    color: white;
}

.btn-spark-info:hover {
    background: #0284c7;
    color: white;
    text-decoration: none;
}

.btn-spark-success {
    background: #10b981;
    color: white;
}

.btn-spark-success:hover {
    background: #059669;
    color: white;
    text-decoration: none;
}

.btn-spark-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

/* Pulse animation for static modals */
@keyframes modal-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.modal-spark-pulse {
    animation: modal-pulse 0.3s ease-in-out;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .modal-spark {
        width: 95%;
        max-width: none;
    }
    
    .modal-spark-header,
    .modal-spark-body,
    .modal-spark-footer {
        padding: 1rem;
    }
    
    .modal-spark-footer {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-spark-footer button {
        width: 100%;
        justify-content: center;
    }
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}
