/* /static/css/pages/news.css */
/* layer over base.css */

:root {
    --card-bg:
        linear-gradient(180deg, rgba(14, 24, 45, 0.96) 0%, rgba(8, 16, 33, 0.96) 100%);
    --card-border: rgba(147, 197, 253, 0.10);
    --card-border-strong: rgba(147, 197, 253, 0.16);
    --card-shadow:
        0 16px 50px rgba(0, 0, 0, 0.34),
        inset 0 1px 0 rgba(255, 255, 255, 0.02);
    --panel-soft:
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.01)),
        linear-gradient(180deg, rgba(15, 23, 42, 0.84), rgba(10, 18, 35, 0.92));
    --good: var(--ok);
}

/* PAGE */

body {
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 28%),
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.11), transparent 24%),
        linear-gradient(180deg, #04101f 0%, #071224 46%, #040b17 100%);
}

.news-page {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    max-width: none;
    align-self: stretch;
}

body[data-path="/news"] > .layout {
    min-height: 100vh !important;
    align-items: stretch !important;
}

body[data-path="/news"] > .layout > .content {
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

body[data-path="/news"] > .layout > .content > .main {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
}

body:has(.news-page) > .layout > .sidebar {
    position: relative !important;
    top: auto !important;
    height: auto !important;
    overflow: visible !important;
}

body:has(.news-page) > .layout > .content > .topbar {
    position: relative !important;
    top: auto !important;
}

.page-title {
    margin: 0 0 14px;
    font-size: 18px;
    line-height: 1.1;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #f3f4f6;
}

/* MAIN GRID */

.news-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    width: 100%;
    max-width: none;
}

.news-main,
.news-side {
    min-width: 0;
    display: grid;
    gap: 14px;
    width: 100%;
    max-width: none;
}

.news-main {
    grid-template-columns: 1fr;
}

.news-side {
    align-content: start;
}

/* CARD */

.card {
    position: relative;
    overflow: hidden;
    min-width: 0;
    border-radius: 20px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    box-shadow: var(--card-shadow);
}

.card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(96, 165, 250, 0.05), transparent 18%, transparent 82%, rgba(96, 165, 250, 0.04)),
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 28%);
}

.card > .hd {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 56px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.015), rgba(255, 255, 255, 0)),
        linear-gradient(90deg, rgba(59, 130, 246, 0.06), transparent 35%);
}

.card > .hd h2 {
    margin: 0;
    color: #f3f4f6;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.045em;
}

.card > .bd {
    position: relative;
    z-index: 1;
    padding: 14px;
    min-width: 0;
}

/* BUTTONS */

.btn {
    appearance: none;
    height: 34px;
    padding: 0 14px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.btn:hover {
    text-decoration: none;
    border-color: rgba(96, 165, 250, 0.28);
    background: linear-gradient(180deg, rgba(96, 165, 250, 0.14), rgba(96, 165, 250, 0.06));
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.14);
}

.btn.secondary {
    border-color: rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015));
}

.btn.danger {
    color: #fff1f2;
    border-color: rgba(239, 68, 68, 0.28);
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.20), rgba(239, 68, 68, 0.08));
}

.btn.danger:hover {
    border-color: rgba(248, 113, 113, 0.35);
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.24), rgba(239, 68, 68, 0.12));
}

/* COMMON */

.row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.small {
    font-size: 11px;
}

.hint {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.divider {
    height: 1px;
    margin: 14px 0;
    background: linear-gradient(90deg, rgba(255,255,255,.06), rgba(255,255,255,.02), rgba(255,255,255,.06));
}

/* CHIPS / PILLS / TAGS */

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip,
.pill,
.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 26px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(6, 16, 34, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.07);
    color: #c7d2fe;
    font-size: 11px;
    line-height: 1;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.chip.good {
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.24);
    background: rgba(20, 83, 45, 0.24);
}

.chip.warn,
.tag.warn {
    color: #fde68a;
    border-color: rgba(245, 158, 11, 0.24);
    background: rgba(120, 53, 15, 0.20);
}

.chip.bad {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.24);
    background: rgba(127, 29, 29, 0.18);
}

.tag {
    min-height: 24px;
    padding: 4px 9px;
}

/* LINKS */

.link {
    color: #93c5fd;
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

/* KPI */

.kpi {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.box {
    min-width: 0;
    min-height: 88px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: var(--panel-soft);
    box-shadow:
        0 0 0 1px rgba(96, 165, 250, 0.04),
        0 10px 30px rgba(30, 64, 175, 0.08);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.box .val {
    color: #eef2ff;
    font-size: 18px;
    line-height: 1.2;
    font-weight: 900;
    word-break: break-word;
}

.box .sub {
    margin-top: 6px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* FILTERS */

.filters {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) 140px minmax(220px, .8fr);
    gap: 12px;
    align-items: end;
}

.ctrl {
    min-width: 0;
}

.ctrl label {
    display: block;
    margin: 0 0 6px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.ctrl input,
.ctrl select {
    width: 100%;
    min-width: 0;
    height: 38px;
    border-radius: 12px;
    background: rgba(6, 16, 34, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text);
    padding: 8px 12px;
}

.ctrl input::placeholder {
    color: #7687a5;
}

/* EVENT LIST */

.event-list {
    display: grid;
    gap: 12px;
    height: 100%;
    overflow-y: auto;
    padding-right: 6px;
    align-content: start;
}

.news-events-card {
    height: 640px;
    display: flex;
    flex-direction: column;
}

.news-events-card > .bd {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.event-list::-webkit-scrollbar {
    width: 10px;
}

.event-list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    border: 2px solid transparent;
    background: rgba(96, 165, 250, 0.28);
    background-clip: padding-box;
}

.event-list::-webkit-scrollbar-track {
    background: transparent;
}

.event {
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: var(--panel-soft);
    box-shadow:
        0 0 0 1px rgba(96, 165, 250, 0.03),
        0 10px 30px rgba(30, 64, 175, 0.06);
    cursor: pointer;
    transition:
        border-color .18s ease,
        transform .18s ease,
        box-shadow .18s ease,
        background .18s ease;
}

.event:hover {
    border-color: rgba(96, 165, 250, 0.20);
    transform: translateY(-1px);
    box-shadow:
        0 0 0 1px rgba(96, 165, 250, 0.05),
        0 16px 32px rgba(30, 64, 175, 0.10);
}

.event .title {
    color: #f3f4f6;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.35;
}

.event .summary {
    margin-top: 8px;
    color: #d7dfeb;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.event .meta {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* CLUSTER PANEL */

.cluster {
    min-height: 220px;
    padding: 2px 0;
}

.cluster .article {
    margin-top: 10px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,.06);
    background: rgba(255,255,255,.02);
}

.cluster .at {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.cluster .src {
    color: #dbeafe;
    font-size: 11px;
}

.cluster .lnk {
    font-size: 11px;
    text-decoration: none;
}

.cluster .lnk:hover {
    text-decoration: underline;
}

.cluster .desc {
    color: #dce4f1;
    font-size: 12px;
    line-height: 1.45;
}

/* REF LIST */

.refs {
    display: grid;
    gap: 12px;
}

.ref {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(150px, 46%);
    gap: 12px;
    align-items: start;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: var(--panel-soft);
}

.ref .k {
    color: #e5e7eb;
    font-size: 13px;
    font-weight: 800;
}

.ref .v {
    color: #cbd5e1;
    font-size: 12px;
    word-break: break-word;
}

/* TABLE-LIKE PANELS INSIDE SIDE */

.news-side .kpi {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* DOT OVERRIDE FOR OK STATE IN THIS PAGE */

.dot.ok {
    background: var(--ok);
}

/* MODAL */

#jsonModal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(4px);
}

#jsonModal.open {
    display: flex;
}

#jsonModal .inner {
    width: min(1100px, 96vw);
    max-height: 88vh;
    overflow: auto;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(15, 23, 42, 0.94));
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

#jsonModal .mh {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(8, 12, 22, 0.88);
    backdrop-filter: blur(10px);
}

#jsonPre {
    margin: 0;
    padding: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    color: #dbeafe;
    font-size: 12px;
    line-height: 1.5;
}

/* SAFETY */

.news-grid,
.news-grid * {
    min-width: 0;
}

/* RESPONSIVE */

@media (max-width: 1450px) {
    .news-side {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1100px) {
    .card > .hd {
        flex-direction: column;
        align-items: start;
    }

    .kpi {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .news-events-card {
        height: 520px;
    }

    .news-side {
        grid-template-columns: 1fr;
    }

    .news-side .kpi,
    .kpi {
        grid-template-columns: 1fr;
    }

    .ref {
        grid-template-columns: 1fr;
    }

    .cluster .at {
        flex-direction: column;
        align-items: start;
    }
}

@media (max-width: 620px) {
    .news-events-card {
        height: 460px;
    }

    .btn {
        width: 100%;
    }

    .row {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .row > * {
        width: 100%;
    }
}

/* unified header spacing */
.news-page .page-title,
.news-page .page-subtitle {
  margin: 0 !important;
}

.news-page > .news-grid,
.news-page > .grid,
.news-page > .stack,
.news-page > section + section {
  margin-top: 0 !important;
}
