/**
 * EIASM Course Module Table — Modal stylesheet.
 *
 * v1.7.0 — initial implementation
 * v1.7.1 — tightened spacing, absolute-positioned close button to
 *          escape Elementor flex-wrap, hardened against theme button
 *          style bleed (transparent !important on close, no border),
 *          slightly denser body type.
 *
 * Selector strategy: `.eiasm-cmt-modal.eiasm-cmt-modal` (class doubled)
 * to win cascade over Elementor's global stylesheet on every
 * declaration that can reasonably be overridden by theme buttons.
 *
 * @since 1.7.0
 */

/* ─── Clickable card affordance ────────────────────────────────── */

.eiasm-cmt-wrap [data-clickable="true"],
.eiasm-cmt-wrap [data-clickable="true"] * {
    cursor: pointer;
}

.eiasm-cmt-wrap [data-clickable="true"] {
    transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}

.eiasm-cmt-wrap [data-clickable="true"]:hover,
.eiasm-cmt-wrap [data-clickable="true"]:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 31, 51, 0.10);
    outline: none;
}

.eiasm-cmt-wrap [data-clickable="true"]:focus-visible {
    box-shadow: 0 0 0 2px #ff5c2e, 0 6px 16px rgba(0, 31, 51, 0.10);
}

/* ─── Modal shell ──────────────────────────────────────────────── */

.eiasm-cmt-modal.eiasm-cmt-modal {
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: #ffffff;
    color: #001f33;
    max-width: 520px;
    width: 92vw;
    box-shadow: 0 24px 64px rgba(0, 31, 51, 0.22);
    font-family: inherit;
    line-height: 1.5;
    overflow: hidden;
}

.eiasm-cmt-modal.eiasm-cmt-modal::backdrop {
    background: rgba(0, 31, 51, 0.55);
    backdrop-filter: blur(2px);
}

.eiasm-cmt-modal-fallback-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 31, 51, 0.55);
    z-index: 99998;
}

.eiasm-cmt-modal-fallback-shell {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 99999;
    max-width: 520px;
    width: 92vw;
    background: #ffffff;
    color: #001f33;
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0, 31, 51, 0.22);
    overflow: hidden;
    font-family: inherit;
    line-height: 1.5;
}

/* ─── Modal head ───────────────────────────────────────────────── */
/* v1.7.1: tighter padding, reserve right side for the close button. */

.eiasm-cmt-modal .eiasm-cmt-modal__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 16px 48px 12px 20px; /* right reserved for absolute close btn */
    border-bottom: 1px solid #eef2f5;
    position: relative;
}

.eiasm-cmt-modal .eiasm-cmt-modal__chip {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 10px;
    border-radius: 11px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: #001f33;
    color: #ffffff;
    flex: 0 0 auto;
}

.eiasm-cmt-modal .eiasm-cmt-modal__chip--core,
.eiasm-cmt-modal .eiasm-cmt-modal__chip--research_methodology {
    background: #001f33;
}

.eiasm-cmt-modal .eiasm-cmt-modal__chip--specialisation {
    background: #ff5c2e;
}

.eiasm-cmt-modal .eiasm-cmt-modal__chip--elective,
.eiasm-cmt-modal .eiasm-cmt-modal__chip--bonus,
.eiasm-cmt-modal .eiasm-cmt-modal__chip--simulation {
    background: #4f7a8c;
}

.eiasm-cmt-modal .eiasm-cmt-modal__title {
    margin: 0;
    flex: 1 1 100%;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.25;
    color: #001f33;
    padding: 0;
    letter-spacing: -0.01em;
}

.eiasm-cmt-modal .eiasm-cmt-modal__credits {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 600;
    color: #4f7a8c;
    white-space: nowrap;
    margin-top: -2px;
}

/* v1.7.1 — absolute corner placement to dodge flex-wrap quirks AND
   strong reset to neutralise theme/Elementor button styles that were
   bleeding in on production. */
.eiasm-cmt-modal .eiasm-cmt-modal__close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    padding: 0;
    margin: 0;
    border: 0 !important;
    background: transparent !important;
    background-image: none !important;
    background-color: transparent !important;
    color: #4f7a8c !important;
    cursor: pointer;
    border-radius: 6px;
    font-size: 22px;
    line-height: 1;
    box-shadow: none !important;
    text-shadow: none;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    appearance: none;
    -webkit-appearance: none;
}

.eiasm-cmt-modal .eiasm-cmt-modal__close:hover,
.eiasm-cmt-modal .eiasm-cmt-modal__close:focus-visible {
    background: #f1f5f8 !important;
    color: #001f33 !important;
    outline: none;
    transform: none;
}

/* ─── Modal body ───────────────────────────────────────────────── */
/* v1.7.1: tighter padding + denser line-height + tighter paragraph
   margins for that "compact" feel Petr asked for. */

.eiasm-cmt-modal .eiasm-cmt-modal__body {
    padding: 14px 20px 18px;
    max-height: 58vh;
    overflow-y: auto;
    font-size: 14.5px;
    line-height: 1.55;
    color: #1a2a35;
}

.eiasm-cmt-modal .eiasm-cmt-modal__body p {
    margin: 0 0 10px;
}

.eiasm-cmt-modal .eiasm-cmt-modal__body p:last-child {
    margin-bottom: 0;
}

.eiasm-cmt-modal .eiasm-cmt-modal__body h2,
.eiasm-cmt-modal .eiasm-cmt-modal__body h3,
.eiasm-cmt-modal .eiasm-cmt-modal__body h4 {
    margin: 14px 0 6px;
    color: #001f33;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.005em;
}

.eiasm-cmt-modal .eiasm-cmt-modal__body h2 { font-size: 16px; }
.eiasm-cmt-modal .eiasm-cmt-modal__body h3 { font-size: 14.5px; }
.eiasm-cmt-modal .eiasm-cmt-modal__body h4 { font-size: 13.5px; }

.eiasm-cmt-modal .eiasm-cmt-modal__body ul,
.eiasm-cmt-modal .eiasm-cmt-modal__body ol {
    margin: 0 0 10px 18px;
    padding: 0;
}

.eiasm-cmt-modal .eiasm-cmt-modal__body li {
    margin: 0 0 3px;
}

.eiasm-cmt-modal .eiasm-cmt-modal__body strong {
    color: #001f33;
}

.eiasm-cmt-modal .eiasm-cmt-modal__body .course-description {
    margin: 0;
}

/* Body scrollbar — keep narrow and unobtrusive. */
.eiasm-cmt-modal .eiasm-cmt-modal__body::-webkit-scrollbar {
    width: 6px;
}
.eiasm-cmt-modal .eiasm-cmt-modal__body::-webkit-scrollbar-thumb {
    background: #d6dee4;
    border-radius: 3px;
}

/* ─── Loading + empty states ───────────────────────────────────── */

.eiasm-cmt-modal .eiasm-cmt-modal__skeleton {
    height: 12px;
    margin: 0 0 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #eef2f5 0%, #f7f9fb 50%, #eef2f5 100%);
    background-size: 200% 100%;
    animation: eiasm-cmt-skel 1.2s linear infinite;
}

.eiasm-cmt-modal .eiasm-cmt-modal__skeleton:nth-child(2) { width: 90%; }
.eiasm-cmt-modal .eiasm-cmt-modal__skeleton:nth-child(3) { width: 75%; }
.eiasm-cmt-modal .eiasm-cmt-modal__skeleton:nth-child(4) { width: 85%; }

@keyframes eiasm-cmt-skel {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.eiasm-cmt-modal .eiasm-cmt-modal__empty {
    color: #4f7a8c;
    font-style: italic;
    margin: 0;
}

.eiasm-cmt-modal .eiasm-cmt-modal__error {
    color: #b32d2e;
    margin: 0;
}

/* ─── Mobile ───────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .eiasm-cmt-modal.eiasm-cmt-modal,
    .eiasm-cmt-modal-fallback-shell {
        width: 96vw;
        border-radius: 10px;
    }
    .eiasm-cmt-modal .eiasm-cmt-modal__head {
        padding: 14px 44px 10px 14px;
        gap: 8px;
    }
    .eiasm-cmt-modal .eiasm-cmt-modal__title {
        font-size: 17px;
    }
    .eiasm-cmt-modal .eiasm-cmt-modal__close {
        top: 8px;
        right: 8px;
    }
    .eiasm-cmt-modal .eiasm-cmt-modal__body {
        padding: 12px 14px 16px;
        font-size: 14px;
    }
}
