/* Modal Components */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-2xl);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: all var(--transition-normal);
    position: relative;
}

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

/* Modal Sizes */
.modal-sm .modal-content {
    width: 400px;
}

.modal-md .modal-content {
    width: 600px;
}

.modal-lg .modal-content {
    width: 800px;
}

.modal-xl .modal-content {
    width: 1000px;
}

.modal-full .modal-content {
    width: 95vw;
    height: 95vh;
    max-width: none;
    max-height: none;
}

/* Modal Header */
.modal-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--gray-50);
}

.modal-header h2 {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--gray-800);
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--font-size-2xl);
    color: var(--gray-400);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-600);
}

/* Modal Body */
.modal-body {
    padding: var(--space-6);
    overflow-y: auto;
    max-height: 60vh;
}

.modal-body p {
    margin-bottom: var(--space-4);
    color: var(--gray-600);
    line-height: var(--line-height-relaxed);
}

/* Modal Footer */
.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    background: var(--gray-50);
}

.modal-footer .btn {
    min-width: 100px;
}

/* Modal Types */
.modal-confirm .modal-content {
    width: 400px;
}

.modal-confirm .modal-header {
    background: var(--warning-orange);
    color: var(--white);
    border-bottom: none;
}

.modal-confirm .modal-header h2 {
    color: var(--white);
}

.modal-confirm .modal-close {
    color: var(--white);
}

.modal-confirm .modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
}

.modal-error .modal-header {
    background: var(--error-red);
    color: var(--white);
    border-bottom: none;
}

.modal-error .modal-header h2 {
    color: var(--white);
}

.modal-error .modal-close {
    color: var(--white);
}

.modal-error .modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
}

.modal-success .modal-header {
    background: var(--success-green);
    color: var(--white);
    border-bottom: none;
}

.modal-success .modal-header h2 {
    color: var(--white);
}

.modal-success .modal-close {
    color: var(--white);
}

.modal-success .modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
}

/* Modal Loading */
.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
    text-align: center;
}

.modal-loading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top: 4px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: var(--space-4);
}

.modal-loading p {
    color: var(--gray-600);
    margin: 0;
}

/* Modal Form */
.modal-form .modal-body {
    padding: var(--space-6);
}

.modal-form .form-group {
    margin-bottom: var(--space-4);
}

.modal-form .form-actions {
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--gray-200);
}

/* Modal Image */
.modal-image .modal-content {
    background: transparent;
    box-shadow: none;
    max-width: 90vw;
    max-height: 90vh;
}

.modal-image .modal-body {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-image img {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

/* Modal Video */
.modal-video .modal-content {
    background: var(--black);
    max-width: 90vw;
    max-height: 90vh;
}

.modal-video .modal-body {
    padding: 0;
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.modal-video iframe,
.modal-video video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Modal Backdrop */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal-backdrop);
}

/* Modal Animation Classes */
.modal-fade-in {
    animation: modalFadeIn var(--transition-normal) ease-out;
}

.modal-fade-out {
    animation: modalFadeOut var(--transition-normal) ease-in;
}

.modal-slide-in {
    animation: modalSlideIn var(--transition-normal) ease-out;
}

.modal-slide-out {
    animation: modalSlideOut var(--transition-normal) ease-in;
}

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

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

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes modalSlideOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-50px);
        opacity: 0;
    }
}

/* Responsive Modals */
@media (max-width: 768px) {
    .modal-content {
        margin: var(--space-4);
        max-width: calc(100vw - var(--space-8));
        max-height: calc(100vh - var(--space-8));
    }
    
    .modal-sm .modal-content,
    .modal-md .modal-content,
    .modal-lg .modal-content,
    .modal-xl .modal-content {
        width: auto;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--space-4);
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .modal-content {
        margin: var(--space-2);
        max-width: calc(100vw - var(--space-4));
        max-height: calc(100vh - var(--space-4));
        border-radius: var(--radius-lg);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--space-3);
    }
}
