/**
 * Frontend route modals – minimal, modern, responsive
 */

/* Container: clean card, subtle shadow, responsive width */
.route-modal .modal-dialog {
    margin: 1rem;
    max-width: 480px;
}
@media (min-width: 576px) {
    .route-modal .modal-dialog {
        margin: 1.75rem auto;
    }
}
@media (min-width: 768px) {
    .route-modal .modal-dialog {
        max-width: 520px;
    }
}

/* Content-sized when short; max-height caps when tall so body scrolls.
   svh = small viewport height (reliable on mobile when URL bar visible); vh fallback for older browsers. */
.route-modal .modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    background: #fff;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 2rem);
    max-height: calc(100svh - 2rem);
    min-height: 0;
}

/* Header: organized, minimal color by type; no shrink so body can scroll */
.route-modal .route-modal__header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
}
.route-modal .route-modal__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.35;
    color: #1a1a1a;
    flex: 1;
    min-width: 0;
}
.route-modal .route-modal__close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #6b7280;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.route-modal .route-modal__close:hover,
.route-modal .route-modal__close:focus {
    background: rgba(0, 0, 0, 0.06);
    color: #1a1a1a;
    outline: none;
}
.route-modal .route-modal__close:focus-visible {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2);
}

/* Type accent: minimal left border or top bar (no full header color) */
.route-modal.route-modal--info .route-modal__header { border-left: 4px solid #0ea5e9; }
.route-modal.route-modal--warning .route-modal__header { border-left: 4px solid #f59e0b; }
.route-modal.route-modal--cta .route-modal__header { border-left: 4px solid #6366f1; }

/* Body: scrolls when tall; no horizontal overflow; long text/media/tables contained.
   Explicit max-height fallback for devices where flex + min-height: 0 doesn't compute. */
.route-modal .route-modal__body {
    padding: 1.5rem 1.5rem;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: #374151;
    background: #fff;
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(100vh - 10rem);
    max-height: calc(100svh - 10rem);
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.route-modal .route-modal__body p:last-child {
    margin-bottom: 0;
}
.route-modal .route-modal__body a {
    color: #4f46e5;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.route-modal .route-modal__body a:hover {
    color: #4338ca;
}
/* Contain media and tables inside body so they don't cause page overflow */
.route-modal .route-modal__body img,
.route-modal .route-modal__body video,
.route-modal .route-modal__body iframe {
    max-width: 100%;
    height: auto;
}
.route-modal .route-modal__body video {
    max-height: 40vh;
}
.route-modal .route-modal__body table {
    max-width: 100%;
    table-layout: fixed;
}
.route-modal .route-modal__body table td,
.route-modal .route-modal__body table th {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Footer: single clear action; no shrink */
.route-modal .route-modal__footer {
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: #fafafa;
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}
.route-modal .route-modal__btn-close {
    min-width: 100px;
    padding: 0.5rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.route-modal .route-modal__btn-close:hover,
.route-modal .route-modal__btn-close:focus {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #1f2937;
    outline: none;
}
.route-modal .route-modal__btn-close:focus-visible {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15);
}

/* Animation: smooth fade + slight scale */
.route-modal.modal.fade .modal-dialog {
    transition: transform 0.25s ease-out, opacity 0.25s ease-out;
}
.route-modal.modal.fade:not(.show) .modal-dialog {
    transform: scale(0.96);
    opacity: 0;
}
.route-modal.modal.fade.show .modal-dialog {
    transform: scale(1);
    opacity: 1;
}

/* Mobile: content-sized when short; fits viewport when tall (body scrolls).
   Use svh so modal never exceeds visible area when mobile browser UI is shown. */
@media (max-width: 575.98px) {
    .route-modal .modal-dialog {
        margin: 0.75rem;
        max-width: calc(100vw - 1.5rem);
        max-width: calc(100svw - 1.5rem);
        max-height: calc(100vh - 1.5rem);
        max-height: calc(100svh - 1.5rem);
        display: flex;
        align-items: center;
    }
    .route-modal .modal-content {
        max-height: calc(100vh - 1.5rem);
        max-height: calc(100svh - 1.5rem);
        width: 100%;
    }
    .route-modal .route-modal__body {
        max-height: calc(100vh - 9rem);
        max-height: calc(100svh - 9rem);
    }
    .route-modal .route-modal__header,
    .route-modal .route-modal__body,
    .route-modal .route-modal__footer {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .route-modal.modal.fade .modal-dialog {
        transition: none;
    }
}
