/* ============================================
   WCAG-Compliant Modal Pattern
   SP ZOZ Lubartów
   
   Requirements met:
   - 2.1.2 No Keyboard Trap (ESC closes)
   - 2.4.3 Focus Order (focus trap)
   - 4.1.2 Name, Role, Value (ARIA)
   ============================================ */

/* Modal overlay - covers entire screen */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Show modal */
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal container */
.modal-dialog {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-dialog {
    transform: scale(1);
}

/* Modal header */
.modal-header {
    padding: 24px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #212529;
}

/* Close button */
.modal-close {
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
    background: #f8f9fa;
    color: #212529;
}

.modal-close:focus {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

/* Modal body - scrollable */
.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Modal footer (optional) */
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-footer button {
    min-width: 100px;
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    background: #ffffff;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.modal-footer button:hover {
    background: #f8f9fa;
}

.modal-footer button:focus {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

.modal-footer button.primary {
    background: #0066cc;
    color: white;
    border-color: #0066cc;
}

.modal-footer button.primary:hover {
    background: #0052a3;
}

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

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

    .modal-overlay {
        padding: 0;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .modal-overlay,
    .modal-dialog {
        transition: none !important;
    }
}

/* Print - hide modals */
@media print {
    .modal-overlay {
        display: none !important;
    }
}