/* ═══════════════════════════════════════════════════════
   Statuspage — основные стили (публичная страница)
   ═══════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green:   #27ae60;
    --yellow:  #f39c12;
    --orange:  #e67e22;
    --red:     #e74c3c;
    --blue:    #3498db;
    --gray:    #7f8c8d;
    --bg:      #f5f6fa;
    --card:    #ffffff;
    --border:  #e0e0e0;
    --text:    #2c3e50;
    --muted:   #666;
    --radius:  8px;
    --shadow:  0 1px 4px rgba(0,0,0,.08);
}

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
       background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 860px; margin: 0 auto; padding: 0 20px; }

/* ── Header ─────────────────────────────────────────────── */
.site-header { background: #1a2332; color: #fff; padding: 28px 0 22px; }
.site-title  { font-size: 1.7rem; font-weight: 700; letter-spacing: -.3px; }
.site-subtitle { color: #aab; margin-top: 4px; font-size: .9rem; }

/* ── Общий статус ───────────────────────────────────────── */
.overall-status {
    display: flex; align-items: center; gap: 14px;
    margin: 28px 0 24px;
    padding: 20px 24px;
    border-radius: var(--radius);
    font-size: 1.15rem; font-weight: 600;
    color: #fff;
}
.overall-icon { font-size: 1.4rem; }

/* ── Section ────────────────────────────────────────────── */
.section { margin-bottom: 36px; }
.section-title { font-size: 1.05rem; font-weight: 600; text-transform: uppercase;
                 letter-spacing: .5px; color: var(--muted); margin-bottom: 14px; }

/* ── Service Group ──────────────────────────────────────── */
.service-group {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 16px;
    box-shadow: var(--shadow); overflow: hidden;
}
.group-title { padding: 14px 20px; font-size: 1rem; font-weight: 600;
               border-bottom: 1px solid var(--border); }
.group-desc  { padding: 0 20px 10px; color: var(--muted); font-size: .9rem; }

/* ── Service Item (обёртка строка + uptime-бар) ─────────── */
.service-item {
    border-bottom: 1px solid var(--border);
}
.service-item:last-child { border-bottom: none; }

/* ── Service Row ────────────────────────────────────────── */
.service-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 20px;
}
.service-row.empty-group { color: var(--muted); font-style: italic; }

.service-info { display: flex; flex-direction: column; gap: 2px; }
.service-name { font-weight: 500; }
.service-desc { font-size: .85rem; color: var(--muted); }

.service-status { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 500; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ── Status colours ─────────────────────────────────────── */
.status-operational  .status-dot { background: var(--green); }
.status-degraded     .status-dot { background: var(--yellow); }
.status-partial      .status-dot { background: var(--orange); }
.status-major        .status-dot { background: var(--red); }
.status-maintenance  .status-dot { background: var(--blue); }

.status-operational  .status-text { color: var(--green); }
.status-degraded     .status-text { color: var(--yellow); }
.status-partial      .status-text { color: var(--orange); }
.status-major        .status-text { color: var(--red); }
.status-maintenance  .status-text { color: var(--blue); }

.overall-status.status-operational  { background: var(--green); }
.overall-status.status-degraded     { background: var(--yellow); }
.overall-status.status-partial      { background: var(--orange); }
.overall-status.status-major        { background: var(--red); }
.overall-status.status-maintenance  { background: var(--blue); }

/* ── Incident Card ──────────────────────────────────────── */
.incident-card {
    background: var(--card); border-radius: var(--radius);
    border: 1px solid var(--border); border-left: 5px solid var(--orange);
    margin-bottom: 16px; padding: 18px 22px;
    box-shadow: var(--shadow);
}
.incident-card.incident-investigating { border-left-color: var(--red); }
.incident-card.incident-identified    { border-left-color: var(--orange); }
.incident-card.incident-monitoring    { border-left-color: var(--yellow); }
.incident-card.incident-resolved      { border-left-color: var(--green); }

.incident-header { display: flex; justify-content: space-between; align-items: flex-start;
                   gap: 12px; margin-bottom: 10px; }
.incident-title  { font-size: 1.05rem; font-weight: 600; }

.incident-badge {
    font-size: .78rem; padding: 3px 10px; border-radius: 20px;
    font-weight: 600; white-space: nowrap;
    background: #eee; color: var(--text);
}
.incident-badge.incident-investigating { background: #fdecea; color: var(--red); }
.incident-badge.incident-identified    { background: #fef3e2; color: var(--orange); }
.incident-badge.incident-monitoring    { background: #fef9e7; color: #b7770d; }
.incident-badge.incident-resolved      { background: #eafaf1; color: var(--green); }

.incident-desc { color: var(--muted); margin-bottom: 10px; }
.incident-meta { font-size: .85rem; color: var(--muted); display: flex; gap: 20px; margin-bottom: 12px; }

/* Затронутые сервисы */
.incident-services { margin: 10px 0; font-size: .9rem; }
.service-tag {
    display: inline-block; margin: 3px 4px; padding: 2px 10px;
    border-radius: 20px; font-size: .82rem; font-weight: 500;
    background: #eee;
}
.service-tag.status-partial { background: #fef3e2; color: var(--orange); }
.service-tag.status-major   { background: #fdecea; color: var(--red); }
.service-tag.status-degraded { background: #fef9e7; color: #b7770d; }

/* Сервер + сайты */
.server-block { margin: 12px 0; padding: 12px 16px; background: #f8f9fa; border-radius: 6px; }
.server-name  { margin-bottom: 8px; }
.server-ip    { color: var(--muted); font-size: .88rem; }
.sites-label  { font-size: .85rem; color: var(--muted); margin-bottom: 6px; margin-top: 2px; }
.sites-list   { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.sites-list li { font-size: .88rem; padding: 2px 10px; background: #fff;
                 border: 1px solid var(--border); border-radius: 4px; }
.site-desc    { color: var(--muted); }
.sites-more { margin-top: 4px; }
.sites-more summary {
    cursor: pointer; font-size: .83rem; color: var(--blue);
    padding: 4px 0; user-select: none;
}
.sites-more summary:hover { text-decoration: underline; }
.sites-more .sites-list { margin-top: 6px; }

/* История обновлений */
.incident-updates { margin-top: 14px; }
.incident-updates summary { cursor: pointer; color: var(--blue); font-size: .9rem; }
.update-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.update-item:last-child { border-bottom: none; }
.update-time   { color: var(--muted); margin-right: 10px; }
.update-status { font-weight: 600; margin-right: 10px; }
.update-msg    { margin-top: 4px; color: var(--text); }

/* ── Uptime bar (90 дней) ────────────────────────────────── */
.uptime-bar { padding: 2px 20px 12px; }

.uptime-segments {
    display: flex;
    gap: 2px;
    height: 28px;
}
.seg {
    flex: 1;
    border-radius: 2px;
    background: var(--green);
    transition: opacity .1s;
    min-width: 0;
}
.seg.seg-incident {
    background: var(--red);
    cursor: pointer;
}
.seg.seg-incident:hover { opacity: .7; }
.seg.seg-selected { outline: 2px solid var(--text); outline-offset: 1px; }

.uptime-footer {
    display: flex;
    justify-content: space-between;
    font-size: .72rem;
    color: var(--muted);
    margin-top: 4px;
}
.uptime-pct { font-weight: 600; color: var(--text); }

/* ── История инцидентов ──────────────────────────────────── */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.history-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}
.history-nav button {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 3px 11px;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text);
    line-height: 1.4;
    transition: background .12s;
}
.history-nav button:hover { background: var(--bg); }
.history-nav button:disabled { opacity: .35; cursor: default; }
.history-nav button:disabled:hover { background: var(--card); }
.history-nav-title {
    font-size: .9rem;
    font-weight: 600;
    min-width: 130px;
    text-align: center;
}

/* Строка инцидента в истории */
.hist-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--green);
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: .88rem;
    transition: background .1s;
}
.hist-row:hover { background: #f8f9fa; }
.hist-row.incident-investigating { border-left-color: var(--red); }
.hist-row.incident-identified    { border-left-color: var(--orange); }
.hist-row.incident-monitoring    { border-left-color: var(--yellow); }
.hist-row.incident-resolved      { border-left-color: var(--green); }
.hist-row.hist-filtered          { box-shadow: 0 0 0 2px var(--text); }

.hist-date {
    font-size: .8rem;
    color: var(--muted);
    white-space: nowrap;
    min-width: 44px;
}
.hist-body { flex: 1; min-width: 0; }
.hist-title-text { font-weight: 500; }
.hist-svc { font-size: .8rem; color: var(--muted); margin-top: 1px; }
.hist-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.hist-duration { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.hist-badge {
    font-size: .72rem; padding: 1px 7px; border-radius: 10px;
    font-weight: 600; white-space: nowrap; background: #eafaf1; color: var(--green);
}
.hist-badge.incident-investigating { background: #fdecea; color: var(--red); }
.hist-badge.incident-identified    { background: #fef3e2; color: var(--orange); }
.hist-badge.incident-monitoring    { background: #fef9e7; color: #b7770d; }
.hist-badge.incident-resolved      { background: #eafaf1; color: var(--green); }

/* ── История: раскрываемые комментарии ──────────────────── */
.hist-row { flex-direction: column; align-items: stretch; }
.hist-main { display: flex; align-items: center; gap: 10px; }

/* ── История: пагинация ─────────────────────────────────── */
.hist-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.hist-pager-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 20px;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text);
    line-height: 1.4;
    transition: background .15s;
    min-width: 44px;
}
.hist-pager-btn:hover:not(:disabled) { background: var(--border); }
.hist-pager-btn:disabled { opacity: .35; cursor: default; }
.hist-pager-info { font-size: .85rem; color: var(--text-muted, #888); min-width: 52px; text-align: center; }

.hist-updates {
    margin-top: 8px;
    border-top: 1px solid var(--border);
    padding-top: 6px;
}
.hist-updates summary {
    font-size: .8rem;
    color: var(--blue);
    cursor: pointer;
    user-select: none;
    padding: 2px 0;
}
.hist-updates summary:hover { text-decoration: underline; }
.hist-update-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: .82rem;
}
.hist-update-item:last-child { border-bottom: none; padding-bottom: 0; }
.hist-update-time { color: var(--muted); font-size: .78rem; }
.hist-update-msg { margin: 3px 0 0; color: var(--text); white-space: pre-wrap; }

[data-theme="dark"] .hist-updates { border-top-color: var(--border); }
[data-theme="dark"] .hist-update-item { border-bottom-color: var(--border); }

@media (prefers-color-scheme: dark) {
    [data-theme="auto"] .hist-updates { border-top-color: var(--border); }
    [data-theme="auto"] .hist-update-item { border-bottom-color: var(--border); }
}

/* ── Footer ─────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--border); padding: 18px 0; margin-top: 40px; }
.site-footer p { font-size: .85rem; color: var(--muted); }

/* ── Misc ───────────────────────────────────────────────── */
.empty-msg { color: var(--muted); font-style: italic; padding: 20px; }
.btn-link {
    border: none; background: none; color: var(--blue);
    cursor: pointer; font-size: .88rem; padding: 0;
}
.btn-link:hover { text-decoration: underline; }
.hist-filter-label { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }

/* ── Content grid (dashboard layout) ──────────────────────── */
.content-grid {
    display: block;
}
.content-main { min-width: 0; }
.content-side  { min-width: 0; }

/* Dashboard: two-column layout */
.layout-dashboard .content-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
    align-items: start;
}
.layout-dashboard .content-side {
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}
/* section-full always spans both columns in dashboard */
.layout-dashboard .section-full {
    grid-column: 1 / -1;
}

/* ── Dark theme ────────────────────────────────────────────── */
[data-theme="dark"] {
    --bg:     #0f1117;
    --card:   #1a1f2e;
    --border: #2d3748;
    --text:   #e2e8f0;
    --muted:  #94a3b8;
    --shadow: 0 1px 4px rgba(0,0,0,.4);
}
[data-theme="dark"] .site-header { background: #0a0e18; }
[data-theme="dark"] .server-block { background: #131720; }
[data-theme="dark"] .hist-row:hover { background: #131720; }
[data-theme="dark"] .history-nav button { background: var(--card); color: var(--text); }
[data-theme="dark"] .history-nav button:hover { background: var(--border); }
[data-theme="dark"] .history-nav button:disabled:hover { background: var(--card); }
[data-theme="dark"] .incident-badge { background: #2d3748; color: var(--text); }
[data-theme="dark"] .incident-badge.incident-investigating { background: #3b1f1e; }
[data-theme="dark"] .incident-badge.incident-identified    { background: #3b2b1a; }
[data-theme="dark"] .incident-badge.incident-monitoring    { background: #302b14; }
[data-theme="dark"] .incident-badge.incident-resolved      { background: #1a3028; }
[data-theme="dark"] .service-tag { background: #2d3748; }
[data-theme="dark"] .sites-list li { background: var(--card); }
[data-theme="dark"] .hist-badge { background: #1a3028; }
[data-theme="dark"] .hist-badge.incident-investigating { background: #3b1f1e; }
[data-theme="dark"] .hist-badge.incident-identified    { background: #3b2b1a; }
[data-theme="dark"] .hist-badge.incident-monitoring    { background: #302b14; }
[data-theme="dark"] .hist-badge.incident-resolved      { background: #1a3028; }
[data-theme="dark"] .hist-pager-btn { border-color: #2a3040; color: #c9d1e0; }
[data-theme="dark"] .hist-pager-btn:hover:not(:disabled) { background: #1e2636; }

/* Auto theme — follows OS preference */
@media (prefers-color-scheme: dark) {
    [data-theme="auto"] {
        --bg:     #0f1117;
        --card:   #1a1f2e;
        --border: #2d3748;
        --text:   #e2e8f0;
        --muted:  #94a3b8;
        --shadow: 0 1px 4px rgba(0,0,0,.4);
    }
    [data-theme="auto"] .site-header { background: #0a0e18; }
    [data-theme="auto"] .server-block { background: #131720; }
    [data-theme="auto"] .hist-row:hover { background: #131720; }
    [data-theme="auto"] .history-nav button { background: var(--card); color: var(--text); }
    [data-theme="auto"] .history-nav button:hover { background: var(--border); }
    [data-theme="auto"] .history-nav button:disabled:hover { background: var(--card); }
    [data-theme="auto"] .incident-badge { background: #2d3748; color: var(--text); }
    [data-theme="auto"] .incident-badge.incident-investigating { background: #3b1f1e; }
    [data-theme="auto"] .incident-badge.incident-identified    { background: #3b2b1a; }
    [data-theme="auto"] .incident-badge.incident-monitoring    { background: #302b14; }
    [data-theme="auto"] .incident-badge.incident-resolved      { background: #1a3028; }
    [data-theme="auto"] .service-tag { background: #2d3748; }
    [data-theme="auto"] .sites-list li { background: var(--card); }
    [data-theme="auto"] .hist-badge { background: #1a3028; }
    [data-theme="auto"] .hist-badge.incident-investigating { background: #3b1f1e; }
    [data-theme="auto"] .hist-badge.incident-identified    { background: #3b2b1a; }
    [data-theme="auto"] .hist-badge.incident-monitoring    { background: #302b14; }
    [data-theme="auto"] .hist-badge.incident-resolved      { background: #1a3028; }
}

@media (max-width: 900px) {
    .layout-dashboard .content-grid {
        display: block;
    }
    .layout-dashboard .content-side {
        position: static;
        max-height: none;
        overflow-y: visible;
    }
}

@media (max-width: 600px) {
    .service-row { flex-direction: column; align-items: flex-start; gap: 6px; }
    .incident-header { flex-direction: column; }
    .incident-meta { flex-direction: column; gap: 4px; }
}
