/* Modal Overlay */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
    visibility: visible;
    align-items: center;
    justify-content: center;
}

/* Modal Container */
.modal-container {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.7) translateY(-50px);
    transition: all 0.3s ease;
    position: relative;
}

.modal-overlay.active .modal-container {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.modal-header {
    padding: 20px 25px 15px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.modal-title {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
    color: #333;
}

.modal-close {
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    background: none;
    border: none;
    transition: color 0.2s ease;
}

.modal-close:hover,
.modal-close:focus {
    color: #333;
    text-decoration: none;
}

/* Modal Body */
.modal-body {
    padding: 25px;
    line-height: 1.6;
}

.modal-body p {
    margin-bottom: 15px;
}

.modal-body h1, .modal-body h2, .modal-body h3,
.modal-body h4, .modal-body h5, .modal-body h6 {
    margin-top: 0;
    margin-bottom: 15px;
}

/* Modal Footer */
.modal-footer {
    padding: 15px 25px 20px;
    border-top: 1px solid #e9ecef;
    text-align: right;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    margin-left: 10px;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.modal-btn-close {
    background: #6c757d;
    color: white;
}

.modal-btn-close:hover {
    background: #5a6268;
}

.modal-btn-primary {
    background: #007cba;
    color: white;
}

.modal-btn-primary:hover {
    background: #005a87;
}

/* Loading State */
.modal-loading .modal-body {
    text-align: center;
    padding: 50px 25px;
}

.modal-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .modal-container {
        width: 95%;
        margin: 20px;
        max-height: 90vh;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 20px;
        padding-right: 20px;
    }
    
    .modal-title {
        font-size: 1.3em;
    }
    
    .modal-footer {
        text-align: center;
    }
    
    .modal-btn {
        margin: 5px;
        width: auto;
        min-width: 100px;
    }
}

/* Animation for multiple modals */
.modal-overlay.stacked {
    z-index: 10000;
}

.modal-overlay.stacked .modal-container {
    transform: scale(0.95) translateY(-20px);
}

/* Special content types */
.modal-image {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.modal-video {
    width: 100%;
    height: 315px;
    border: none;
    border-radius: 4px;
}

/* Form styling within modal */
.modal-form .form-group {
    margin-bottom: 20px;
}

.modal-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.modal-form input[type="text"],
.modal-form input[type="email"],
.modal-form input[type="password"],
.modal-form textarea,
.modal-form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.modal-form input:focus,
.modal-form textarea:focus,
.modal-form select:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}