/* MaxMonitor — modern Bootstrap 5.3 theme.
   Preserves the legacy brand (red #e8515c accent, positive-tone green) while
   modernising spacing, cards and the article list. Dark mode rides on BS 5.3's
   native data-bs-theme="dark" plus the tweaks below. */

:root {
    --mm-red: #e8515c;
    --mm-red-dark: #d23b46;
    --mm-green: #6fae2f;
    --mm-blue: #2f6fb0;
    --bs-link-color: var(--mm-red);
    --bs-link-hover-color: var(--mm-red-dark);
    --bs-primary: var(--mm-red);
}

body {
    background: #f4f6f9;
    font-size: 14px;
}

/* The navbar and main content both use Bootstrap's widest built-in container
   (.container-xxl, max-width 1320px at >=1400px viewports — BS5 has no larger
   size than xxl out of the box). Widen it in two steps on bigger screens,
   past where Bootstrap itself stops scaling. */
@media (min-width: 1400px) {
    .container-xxl { max-width: 1400px; }
}
@media (min-width: 1600px) {
    .container-xxl { max-width: 1560px; }
}

[data-bs-theme="dark"] body {
    background: #15181d;
}

/* ---- Navbar -------------------------------------------------------------- */
.mm-navbar {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
    border-bottom: 3px solid var(--mm-red);
}
[data-bs-theme="dark"] .mm-navbar {
    background: #1d2127;
    border-bottom-color: var(--mm-red);
}
.mm-navbar .navbar-brand {
    display: flex;
    align-items: center;
}
.mm-navbar .navbar-brand img {
    height: 36px;
    width: auto;
}
[data-bs-theme="dark"] .mm-navbar .navbar-brand img {
    /* The logo's "max" wordmark is dark grey — unreadable on the dark navbar
       background, so give it a light chip to sit on. */
    background: #fff;
    padding: 4px 8px;
    border-radius: 6px;
}
.mm-navbar .nav-link {
    font-weight: 500;
    color: var(--bs-body-color);
    display: flex;
    align-items: center;
    gap: 6px;
}
.mm-navbar .nav-link:hover,
.mm-navbar .nav-link.active { color: var(--mm-red); }
.mm-navbar .nav-link.active { font-weight: 700; }
.mm-current-project { color: var(--mm-red) !important; font-weight: 600; }

/* ---- Notifications bell (navbar, right side) ------------------------------ */
.mm-notif-badge {
    position: absolute;
    top: 2px;
    right: -2px;
    font-size: 10px;
    padding: 2px 5px;
    line-height: 1;
}
.mm-notif-dropdown {
    width: 360px;
    max-width: calc(100vw - 24px);
    max-height: 420px;
    overflow-y: auto;
    padding-bottom: 0;
}
.mm-notif-dropdown .dropdown-item { white-space: normal; }
.mm-notif-dropdown form .dropdown-item { width: 100%; text-align: left; border: 0; background: none; border-bottom: 1px solid #eee; }

/* ---- Cards / panels ------------------------------------------------------ */
.card {
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.card-title { font-weight: 600; }
.muted, .text-muted-sm { color: var(--bs-secondary-color); font-size: 13px; }

/* ---- Topic pills (tabs) -------------------------------------------------- */
.mm-topic-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.mm-topic-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 13px;
    text-decoration: none;
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
    border: 1px solid transparent;
    transition: all .12s;
}
.mm-topic-pill:hover { border-color: var(--mm-red); color: var(--mm-red); }
.mm-topic-pill.active { background: var(--mm-red); color: #fff; }

/* ---- Article list -------------------------------------------------------- */
.mm-article {
    display: flex;
    gap: 12px;
    padding: 30px 14px;
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    margin-bottom: 8px;
    background: var(--bs-body-bg);
    transition: box-shadow .12s;
}
.mm-article:hover { box-shadow: 0 2px 10px rgba(0, 0, 0, .07); }
.mm-article.read { border: none; background-color: #f5f6f9; }
.mm-article.read, .mm-article.read * { font-weight: normal; }
.mm-article.read .mm-article-title { opacity: .8; }
.mm-article-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 0 26px;
    align-items: center;
    padding-top: 2px;
}
.mm-icon-btn {
    cursor: pointer;
    color: #6b7280;
    font-size: 14px;
    line-height: 1;
    background: none;
    border: 0;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
}
.mm-icon-btn:hover { color: var(--mm-red); }
/* Active: solid coloured circle with a white icon. */
.mm-icon-btn.active, .mm-icon-btn.active:hover { background: var(--mm-red); color: #fff; }
.mm-icon-btn.note-icon.active { background: var(--mm-blue); }
.mm-icon-btn.important-icon.active { background: #f0a500; }

.mm-article-body { flex: 1 1 auto; min-width: 0; }
.mm-article-title { font-size: 15px; font-weight: 600; margin: 0 0 4px; line-height: 1.35; }
.mm-article-title a { color: var(--bs-body-color); text-decoration: none; }
.mm-article-title a:hover { color: var(--mm-red); }
.mm-article-title b { color: var(--mm-red); background: rgba(232, 81, 92, .12); }
.mm-article-meta { font-size: 12.5px; color: var(--bs-secondary-color); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; }
.mm-article-meta .article-publication { font-weight: 600; color: var(--bs-body-color); }
.mm-article-meta a { color: var(--mm-blue); }
.mm-article-meta a:hover { color: var(--mm-red); }
.mm-article-topics { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.article-bodytext img { max-width: 100%; height: auto; border-radius: 4px; margin: 6px 0; display: block; }
.mm-article-listimg img { max-width: 100%; max-height: 320px; height: auto; border-radius: 6px; display: block; object-fit: cover; }
.mm-article-topic { color: var(--mm-red); font-size: 12.5px; font-weight: 500; }
.mm-article-score { font-family: monospace; font-size: 19px; font-weight: 700; color: var(--mm-blue); padding-left: 12px; align-self: center; }

/* note popover */
.mm-note-window { display: none; margin: 8px 0 0; padding: 10px; border: 1px solid var(--bs-border-color); border-radius: 8px; background: var(--bs-tertiary-bg); }
.mm-note-window.open { display: block; }
.mm-note-window textarea { width: 100%; min-height: 60px; }
.mm-note-comment { font-size: 12px; color: var(--bs-secondary-color); font-style: italic; margin-bottom: 4px; }

/* ---- Tone badges --------------------------------------------------------- */
.tone-positive { color: var(--mm-green); }
.tone-negative { color: var(--mm-red); }
.tone-neutral  { color: var(--bs-secondary-color); }

/* ---- "All media results" header ------------------------------------------ */
.mm-media-total .num { font-size: 30px; font-weight: 700; line-height: 1; }
.mm-media-total .lbl { font-size: 13px; color: var(--bs-secondary-color); }
.mm-donuts { display: flex; gap: 12px; flex-wrap: wrap; justify-content: space-around; margin-top: 10px; }
.mm-donut-item { text-align: center; }
.mm-donut-item.mm-donut-link a { text-decoration: none; color: inherit; display: block; }
.mm-donut-item.mm-donut-link a:hover .mm-donut { transform: scale(1.1); }
.mm-donut {
    position: relative;
    width: 76px; height: 76px;
    margin: 0 auto;
    border-radius: 50%;
    background: conic-gradient(var(--c) calc(var(--p) * 1%), color-mix(in srgb, var(--c) 18%, white) 0);
    transition: transform 0.15s ease;
}
.mm-donut span {
    position: absolute; inset: 9px;
    background: var(--bs-body-bg);
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 700;
}
.mm-donut-item .count { font-size: 15px; font-weight: 700; margin-top: 5px; }
.mm-donut-item .label { font-size: 12px; color: var(--bs-secondary-color); margin-top: 2px; }

.mm-chart-tabs .btn.active { background: var(--mm-red); color: #fff; border-color: var(--mm-red); }

/* ---- Auth screens -------------------------------------------------------- */
.mm-auth { max-width: 400px; margin: 8vh auto; }
.mm-auth .card-body { padding: 2rem; }
.mm-auth-brand { font-weight: 700; color: var(--mm-red); letter-spacing: .3px; }

/* ---- select2 ↔ Bootstrap 5 bridge --------------------------------------- */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border-color: var(--bs-border-color);
    border-radius: .375rem;
    background: var(--bs-body-bg);
    min-height: 31px;
}
.select2-container--default .select2-selection--single { height: 31px; }
.select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--bs-body-color); line-height: 29px; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 29px; }
.select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--bs-secondary-color); }
.select2-dropdown { background: var(--bs-body-bg); border-color: var(--bs-border-color); }
.select2-container--default .select2-results__option { color: var(--bs-body-color); }
.select2-container--default .select2-search--dropdown .select2-search__field {
    background: var(--bs-body-bg); color: var(--bs-body-color); border-color: var(--bs-border-color);
}
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--mm-red); }
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: var(--mm-red); color: #fff; border: 0;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove { color: #fff; }
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default .select2-selection--single:focus {
    border-color: var(--mm-red);
}
/* select2 appends its open dropdown to <body> with z-index:1051 — below
   Bootstrap 5's modal (1055), so a select inside a modal (e.g. the article
   filter) opens its options behind the modal instead of above it. */
.select2-container--open { z-index: 1056; }

/* Highcharts' export menu (.highcharts-contextmenu, appended to <body>) has no
   z-index high enough to reliably beat later page content — #articleFilterCard
   sits after #mm-charts in the DOM, so with neither side forcing a z-index the
   later element wins stacking ties and the export menu opens behind it. */
#mm-charts { z-index: 1010 !important; }

.project-right-list > .fw-bold { color: rgb(232, 81, 92); }

.list-group-item.active {
    color: #ffffff !important;
    background-color: rgb(232, 81, 92);
    border-color: rgb(232, 81, 92);
}

/* ---- Misc ---------------------------------------------------------------- */
.front-block { margin-top: 22px; }
a { text-decoration: none; }
.table > :not(caption) > * > * { padding: 1.55rem .6rem; }
.page-title { font-weight: 600; margin-bottom: 2px; }

/* Coding list: briefly flash the row for the article just coded, so it's
   findable among possibly many other table-success (already coded) rows. */
@keyframes coding-row-flash {
    0%, 100% { background-color: inherit; }
    30% { background-color: #ffe69c; }
}
.coding-row-flash { animation: coding-row-flash 1.6s ease-in-out; }

/* mm-charts widget's topic filter — select2 replaces the <select> with a
   sibling .select2-container, so target that for the select's own styling.
   Multi-select normally grows taller as chips wrap onto new lines; pin it to
   one line instead — the JS below collapses the chips to a "N selected" count
   once more than one topic is picked, so there's nothing left to wrap. */
.mm-chart-topic-select + .select2-container .select2-selection__rendered { text-align: right; }
/* .mm-chart-filters starts hidden (display:none) by default, so select2's own
   width:'resolve' JS measurement — taken at page-load init time, before the
   settings button ever reveals it — sees zero width and locks that in. Force
   it via CSS instead, which doesn't care when/whether it was ever visible. */
.mm-chart-topic-select + .select2-container {
    width: 100% !important;
}
.mm-chart-topic-select + .select2-container .select2-selection--multiple {
    max-height: 31px;
    overflow: hidden;
}
.mm-chart-topic-select + .select2-container .select2-selection__rendered {
    display: flex;
    flex-wrap: nowrap;
    overflow: hidden;
    white-space: nowrap;
}
.mm-chart-topic-select + .select2-container .select2-selection__choice {
    flex: 0 0 auto;
}
/* Leave room on the right for the Deselect-all "x" button overlaid inside the
   box (see .mm-chart-topic-clear-btn) so chip text never runs under it. */
.mm-chart-topic-select + .select2-container .select2-selection__rendered {
    padding-right: 22px;
}
.mm-chart-topic-clear-btn {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    z-index: 2;
    border: 0;
    background: none;
    padding: 0;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    color: var(--bs-secondary-color);
    font-size: 12px;
    border-radius: 50%;
}
.mm-chart-topic-clear-btn:hover {
    color: var(--mm-red);
    background: var(--bs-tertiary-bg);
}

/* Newsfeed sidebar "Projects" card — collapsible header chevron. */
.project-list-chevron { transition: transform .15s ease; }
.card-header[aria-expanded="false"] .project-list-chevron { transform: rotate(-90deg); }

/* Article filter — used site-wide, so it gets a quiet accent (left border +
   faint tint) rather than blending into every other plain card. Blue, not
   red — red is already "error/negative" everywhere else in this app, so it
   read as something being wrong rather than just being important. */
#articleFilterCard {
    border: 1px solid rgba(47, 111, 176, .35);
    border-left: 4px solid var(--mm-blue);
    background: rgba(47, 111, 176, .09);
}
