/* Mega menú — Centro Médico Gallego */
:root {
    --cmg-green: #8fab7b;
    --cmg-green-dark: #4d6b3f;
    --cmg-green-ink: #5e784b;
    --cmg-tint: #f3f7f0;
    --cmg-tint-2: #e8f0e3;
    --cmg-text: #3f4a3c;
    --cmg-muted: #5f6b5b;
}

/* Botón de nivel 1: mismo aspecto que los enlaces del navbar */
.navbar-nav > li > .cmg-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    padding: 10px 15px;
    line-height: 20px;
    background: none;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    line-height: 20px;
    text-transform: inherit;
    letter-spacing: inherit;
    color: #7e986c;
    font-weight: 500;
    text-transform: uppercase;
    cursor: pointer;
}
.navbar-nav > li > .cmg-toggle:hover,
.navbar-nav > li > .cmg-toggle:focus-visible,
.navbar-nav > li.is-open > .cmg-toggle { color: var(--cmg-green-dark); }
.navbar-nav > li.is-open > .cmg-toggle { background: var(--cmg-tint-2); color: var(--cmg-green-dark); }
.navbar-default .navbar-nav > li.active > .cmg-toggle { background: #8fab7b; color: #fff; border-radius: 0; }
.navbar-default .navbar-nav > li.active.is-open > .cmg-toggle { background: #7e986c; }
.navbar-nav > li > .cmg-toggle:focus-visible,
.cmg-panel a:focus-visible { outline: 2px solid var(--cmg-green-ink); outline-offset: 2px; }
.cmg-chevron { transition: transform .2s ease; flex: none; }
.cmg-has-panel.is-open .cmg-chevron { transform: rotate(180deg); }
.navbar-nav > li.cmg-has-panel { display: flex; flex-wrap: wrap; align-items: center; }
.cmg-toggle--caret { padding-left: 4px !important; padding-right: 8px !important; }

/* Panel */
.cmg-panel { display: none; text-transform: none; letter-spacing: normal; font-weight: 400; }
.cmg-has-panel.is-open > .cmg-panel { display: block; }
.cmg-panel__inner {
    background: #fff;
    border: 1px solid #e3ebde;
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(61, 85, 52, .16), 0 2px 6px rgba(61, 85, 52, .06);
    overflow: hidden;
}
.cmg-panel__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: var(--cmg-tint);
    border-bottom: 1px solid #e3ebde;
}
.cmg-panel__head-ico { display: inline-flex; color: var(--cmg-green-ink); }
.cmg-panel__head-ico svg { width: 26px; height: 26px; }
.cmg-panel__title { font-weight: 700; font-size: 16px; letter-spacing: .06em; text-transform: uppercase; color: var(--cmg-green-dark); }
.cmg-panel__subtitle { margin-left: auto; font-style: italic; font-size: 14px; color: var(--cmg-muted); text-align: right; }

.cmg-panel__cols { display: grid; grid-template-columns: repeat(var(--cmg-cols, 1), minmax(0, 1fr)); gap: 8px 20px; padding: 18px 20px 14px; }
.cmg-col { min-width: 0; }
.cmg-col + .cmg-col { position: relative; }
.cmg-panel--wide .cmg-col + .cmg-col::before {
    content: "";
    position: absolute;
    left: -11px; top: 4px; bottom: 4px;
    border-left: 1px solid #e8eee4;
}
.cmg-col__title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    margin: 0 0 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--cmg-tint);
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--cmg-green-dark);
}
.cmg-col__title a { color: inherit; }
.cmg-col__title-svg { width: 18px; height: 18px; color: var(--cmg-green-ink); }
.cmg-badge {
    display: inline-block;
    padding: 0 7px;
    border: 1px solid #dfe6da;
    border-radius: 999px;
    background: transparent;
    color: var(--cmg-muted);
    font-size: 11px;
    font-weight: 400;
    line-height: 1.6;
    letter-spacing: 0;
    text-transform: lowercase;
    white-space: nowrap;
}

.cmg-col__list { list-style: none; margin: 0; padding: 0; }
.cmg-col__list > li { margin: 0; }
.cmg-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 7px 8px;
    border-radius: 12px;
    color: var(--cmg-text);
    font-size: 15px;
    line-height: 1.3;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}
.cmg-link:hover, .cmg-link:focus-visible { background: var(--cmg-tint); color: var(--cmg-green-dark); text-decoration: none; }
.cmg-link.is-current { color: var(--cmg-green-dark); font-weight: 600; }
.cmg-ico {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 46px; height: 46px;
    border-radius: 12px;
    background: var(--cmg-tint);
    color: var(--cmg-green-ink);
    transition: background-color .15s ease, transform .15s ease;
}
.cmg-ico__svg { width: 26px; height: 26px; }
.cmg-ico--empty { display: none; }
.cmg-link:hover .cmg-ico, .cmg-link:focus-visible .cmg-ico, .cmg-link.is-current .cmg-ico { background: var(--cmg-tint-2); }
.cmg-panel__note { margin: 0; padding: 10px 24px 14px; font-size: 12.5px; line-height: 1.45; color: var(--cmg-muted); border-top: 1px solid #eef2eb; }

/* ---------- Escritorio ---------- */
@media (min-width: 992px) {
    .cabecera_Estrecha .navbar-nav > li > .cmg-toggle { padding-top: 7px; padding-bottom: 7px; }
    .navbar-fixed-top > .container { position: relative; }
    .navbar-nav > li.cmg-has-panel { position: relative; }
    .navbar-nav > li.cmg-has-panel--wide { position: static; }
    .cmg-panel {
        position: absolute;
        z-index: 1050;
        top: 100%;
        padding-top: 12px;
    }
    .cmg-has-panel--compact > .cmg-panel { right: 0; min-width: 300px; }
    .cmg-has-panel--wide > .cmg-panel { left: 15px; right: 15px; }
    /* Flecha */
    .cmg-panel::before {
        content: "";
        position: absolute;
        top: 6px;
        right: 40px;
        width: 14px; height: 14px;
        background: #fff;
        border-left: 1px solid #e3ebde;
        border-top: 1px solid #e3ebde;
        transform: rotate(45deg);
        z-index: 1;
    }
    .cmg-has-panel--wide > .cmg-panel::before { right: auto; left: var(--cmg-arrow-x, 50%); }
    .cmg-has-panel.is-open > .cmg-panel { animation: cmg-in .18s ease-out; }
    .cmg-panel__head .cmg-panel__head-ico svg { width: 24px; height: 24px; }
}
@keyframes cmg-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Móvil: acordeón ---------- */
@media (max-width: 991px) {
    .navbar-fixed-top .navbar-collapse { max-height: calc(100vh - 80px); max-height: calc(100dvh - 80px); }
    .navbar-nav > li.cmg-has-panel { display: flex; }
    .navbar-nav > li > .cmg-toggle { flex: 1 1 auto; justify-content: space-between; width: 100%; padding: 10px 15px; text-align: left; }
    .navbar-nav > li > .cmg-toplink { flex: 1 1 auto; }
    .cmg-toggle--caret { width: auto !important; flex: 0 0 auto !important; }
    .cmg-panel { flex: 1 0 100%; padding: 4px 8px 10px; }
    .cmg-panel__inner { border-radius: 12px; box-shadow: none; }
    .cmg-panel__head { display: none; }
    .cmg-panel__cols { grid-template-columns: 1fr !important; padding: 10px; gap: 6px; }
    .cmg-col__title { font-size: 13.5px; padding: 6px 10px; }
    .cmg-ico { width: 36px; height: 36px; border-radius: 10px; }
    .cmg-ico__svg { width: 20px; height: 20px; }
    .cmg-link { padding: 6px; font-size: 15px; }
    .cmg-panel__note { padding: 8px 14px 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .cmg-chevron, .cmg-link, .cmg-ico { transition: none; }
    .cmg-has-panel.is-open > .cmg-panel { animation: none; }
}

/* Mismo hover para todos los elementos de nivel 1 (antes solo lo tenían los desplegables) */
.navbar-default .navbar-nav > li:not(.active) > a {
    border-radius: 8px;
    transition: background-color .15s ease, color .15s ease;
}
.navbar-default .navbar-nav > li:not(.active) > a:hover,
.navbar-default .navbar-nav > li:not(.active) > a:focus-visible,
.navbar-default .navbar-nav > li:not(.active) > .cmg-toggle:hover {
    background-color: var(--cmg-tint-2);
    color: var(--cmg-green-dark);
}
