/* ============================================
   BASE MODAL - Global Styles
   ============================================ */

/* Overlay/Backdrop */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* Modal Container */
.modal-container {
    position: fixed;
    inset: 0;
    z-index: 101;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-container.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Modal Content Box */
.modal-content {
    background: #101622;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    height: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.modal-container.is-open .modal-content {
    transform: scale(1) translateY(0);
}

/* Size Variants */
.modal-content.modal-sm {
    max-width: 32rem;
}

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

.modal-content.modal-lg {
    max-width: 64rem;
}

/* ============================================
   MODAL HEADER (Fixed)
   ============================================ */
.modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #101622;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.modal-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.modal-header-content {
    flex: 1;
    min-width: 0;
}

/* Tags/Chips */
.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(19, 91, 236, 0.8);
    margin-bottom: 0.5rem;
}

.modal-tags span:not(:last-child)::after {
    content: ' • ';
    margin: 0 0.25rem;
}

/* Title */
.modal-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: #fff;
    line-height: 1.2;
    margin: 0;
}

/* Subtitle */
.modal-subtitle {
    font-size: 0.875rem;
    color: #8b5cf6;
    margin-top: 0.25rem;
    font-weight: 500;
}

/* Close Button */
.modal-close {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-close .material-symbols-outlined {
    color: #fff;
    font-size: 1.25rem;
}

/* ============================================
   MODAL MEDIA (Inside Body - Scrollable)
   ============================================ */
.modal-media {
    flex-shrink: 0;
    margin: -1.5rem -1.5rem 1.5rem -1.5rem;
    padding: 0;
}

.modal-media-inner {
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    margin: 0;
    line-height: 0;
}

.modal-media img,
.modal-media video {
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: cover;
    display: block;
    margin: 0;
    padding: 0;
}

.modal-media video {
    background: #000;
}

/* Aspect ratios */
.modal-media.aspect-16-9 .modal-media-inner {
    aspect-ratio: 16/9;
}

.modal-media.aspect-4-3 .modal-media-inner {
    aspect-ratio: 4/3;
}

.modal-media.aspect-1-1 .modal-media-inner {
    aspect-ratio: 1/1;
}

.modal-media.aspect-16-9 img,
.modal-media.aspect-16-9 video,
.modal-media.aspect-4-3 img,
.modal-media.aspect-4-3 video,
.modal-media.aspect-1-1 img,
.modal-media.aspect-1-1 video {
    height: 100%;
    max-height: none;
}

/* ============================================
   MODAL BODY (Scrollable)
   ============================================ */
.modal-body-wrapper {
    position: relative;
    flex: 1 1 auto;
    min-height: 150px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 150px;
    max-height: 100%;
}

/* Elegant Scrollbar */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    transition: background 0.2s ease;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Firefox */
.modal-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* Fade Cues (scroll indicators) */
.modal-body-wrapper::before,
.modal-body-wrapper::after {
    content: '';
    position: absolute;
    left: 0;
    right: 6px;
    height: 40px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
}

.modal-body-wrapper::before {
    top: 0;
    background: linear-gradient(to bottom, #101622 0%, transparent 100%);
}

.modal-body-wrapper::after {
    bottom: 0;
    background: linear-gradient(to top, #101622 0%, transparent 100%);
}

.modal-body-wrapper.has-scroll-top::before {
    opacity: 1;
}

.modal-body-wrapper.has-scroll-bottom::after {
    opacity: 1;
}

/* ============================================
   MODAL FOOTER (Fixed)
   ============================================ */
.modal-footer {
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.modal-footer a,
.modal-footer button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: #135bec;
    color: #fff;
    font-weight: 700;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease;
}

.modal-footer a:hover,
.modal-footer button:hover {
    background: rgba(19, 91, 236, 0.9);
}

/* ============================================
   CASE DETAIL SECTIONS (Content styling)
   ============================================ */
.case-detail-section {
    border-left: 3px solid #135bec;
    padding-left: 1rem;
    margin-bottom: 1.5rem;
}

.case-detail-section:last-child {
    margin-bottom: 0;
}

.case-detail-section h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #135bec;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.case-detail-section p {
    color: #cbd5e1;
    line-height: 1.7;
    margin: 0;
}

.case-detail-section p+p {
    margin-top: 0.75rem;
    color: #94a3b8;
}

.case-detail-section .result-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.case-detail-section .result-item:last-child {
    margin-bottom: 0;
}

.case-detail-section .result-item .material-symbols-outlined {
    color: #22c55e;
    margin-top: 0.125rem;
    flex-shrink: 0;
}

.case-detail-section .result-item p {
    margin: 0;
}

.case-detail-section .result-item strong {
    color: #fff;
}

/* ============================================
   BODY SCROLL LOCK
   ============================================ */
body.modal-open {
    overflow: hidden;
    padding-right: var(--scrollbar-width, 0);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 640px) {
    .modal-container {
        padding: 1rem;
        align-items: flex-end;
    }

    .modal-content {
        max-height: 85vh;
        border-radius: 1rem 1rem 0 0;
    }

    .modal-header {
        padding: 1.25rem;
    }

    .modal-title {
        font-size: 1.25rem;
    }

    .modal-body {
        padding: 1.25rem;
    }

    .modal-media {
        padding: 0 1.25rem;
    }

    .modal-media img,
    .modal-media video {
        max-height: 180px;
    }

    .modal-footer {
        padding: 1rem 1.25rem 1.25rem;
    }
}