/* Modal System — ПравоАгент */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
    padding: var(--space-md);
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition-base);
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.modal-header-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text);
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    background: none;
    font-size: 1.25rem;
}

.modal-close:hover {
    color: var(--color-text);
    background: var(--color-bg-hover);
}

.modal-body {
    padding: var(--space-lg);
    overflow: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--color-border);
    gap: var(--space-sm);
    flex-shrink: 0;
    background: var(--color-bg);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Modal sizes */
.modal-sm {
    max-width: 400px;
}

.modal-lg {
    max-width: 700px;
}

.modal-xl {
    max-width: 900px;
    max-height: 90vh;
}

.modal-fullscreen {
    max-width: 95vw;
    max-height: 95vh;
}

/* Modal with no padding in body */
.modal-body-no-padding {
    padding: 0;
}

/* Confirm dialog */
.modal-confirm-icon {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: var(--space-md);
}

.modal-confirm-title {
    text-align: center;
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.modal-confirm-message {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-lg);
}

/* Modal with sidebar layout */
.modal-split {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.modal-split-sidebar {
    width: 200px;
    background: var(--color-bg);
    border-right: 1px solid var(--color-border);
    padding: var(--space-md);
    flex-shrink: 0;
}

.modal-split-main {
    flex: 1;
    padding: var(--space-md);
    overflow: auto;
}

/* Scroll lock on body when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Animations */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
}

/* Responsive */
@media (max-width: 640px) {
    .modal {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal-sm,
    .modal-lg,
    .modal-xl {
        max-width: 100%;
    }
}
