/* Energy Logserver Documentation - Custom Styles */

/* ── Tables ── */
.wy-table-responsive table {
    margin-bottom: 24px;
    max-width: 100%;
    background: transparent;
    border-collapse: collapse;
    table-layout: auto;
    word-wrap: break-word;
}

.wy-table-responsive table td,
.wy-table-responsive table th {
    white-space: normal !important;
    word-wrap: break-word;
    word-break: break-word;
    vertical-align: top;
    padding: 8px 12px;
    border: 1px solid #e1e4e5;
    max-width: 300px;
}

.wy-table-responsive table th {
    background-color: #f3f6f6;
    font-weight: bold;
    text-align: left;
}

/* Zebra-striping for better readability */
.wy-table-responsive table tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

.wy-table-responsive table tbody tr:hover {
    background-color: #f0f4f8;
}

/* Special styling for Permission Matrix */
.permission-matrix-table {
    width: 100%;
    table-layout: fixed;
}

.permission-matrix-table td:first-child {
    width: 20%;
    font-weight: bold;
}

.permission-matrix-table td:nth-child(2) {
    width: 35%;
}

.permission-matrix-table td:nth-child(3) {
    width: 25%;
}

.permission-matrix-table td:last-child {
    width: 20%;
}

/* Alert rule type × option matrix (Direction A prototype) */

/* Full-bleed wrapper — breaks out of the 800px content column */
.rule-matrix-wrap {
    position: relative;
    margin-left: calc(50% - 50vw + 100px);
    margin-right: calc(50% - 50vw + 24px);
    max-width: calc(100vw - 140px);
    overflow-x: auto;
    padding: 4px;
}

@media (max-width: 1100px) {
    .rule-matrix-wrap {
        margin-left: 0;
        margin-right: 0;
        max-width: 100%;
    }
}

table.rule-matrix {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9em;
    background: #ffffff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(15, 25, 40, 0.08), 0 0 0 1px #e5e8ec;
    margin: 8px 0 20px;
}

table.rule-matrix th,
table.rule-matrix td {
    text-align: center;
    vertical-align: middle;
    padding: 10px 12px;
    border-bottom: 1px solid #eef0f3;
    border-right: 1px solid #eef0f3;
    max-width: none;
    white-space: normal;
    word-break: normal;
}

table.rule-matrix tbody tr:last-child td {
    border-bottom: none;
}

table.rule-matrix th:last-child,
table.rule-matrix td:last-child {
    border-right: none;
}

table.rule-matrix thead th {
    background: linear-gradient(180deg, #2a4a6b 0%, #1f3a55 100%);
    color: #fff;
    font-weight: 600;
    font-size: 0.92em;
    letter-spacing: 0.02em;
    text-transform: none;
    border-bottom: none;
    border-right: 1px solid rgba(255,255,255,0.12);
    padding: 12px 14px;
    position: sticky;
    top: 0;
    z-index: 2;
}

table.rule-matrix thead th:first-child {
    background: linear-gradient(180deg, #243d59 0%, #1a2f45 100%);
    z-index: 3;
}

table.rule-matrix th:first-child,
table.rule-matrix td:first-child {
    text-align: left;
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-weight: 600;
    white-space: nowrap;
    background-color: #f7f9fb;
    color: #243a55;
    position: sticky;
    left: 0;
    z-index: 1;
    box-shadow: 1px 0 0 #e5e8ec;
}

table.rule-matrix tbody tr:hover td {
    background-color: #f4f7fb;
}

table.rule-matrix tbody tr:hover td:first-child {
    background-color: #e9eef5;
}

table.rule-matrix tbody tr:hover td.req {
    background-color: #fbcccc;
}

table.rule-matrix tbody tr:hover td.req-cond {
    background-color: #facfa0;
}

table.rule-matrix tbody tr:hover td.opt {
    background-color: #ffe8a3;
}

table.rule-matrix tbody tr:hover td.ns {
    background-color: #b8b8b8;
}

table.rule-matrix td.req {
    background-color: #fce2e2;
    color: #8b1d1d;
    font-weight: 700;
}

table.rule-matrix td.req-cond {
    background-color: #fde0bc;
    color: #7a4400;
    font-weight: 700;
}

table.rule-matrix td.opt {
    background-color: #fff1c2;
    color: #6e5300;
    font-weight: 600;
}

table.rule-matrix td.ns {
    background-color: #cfcfcf;
    color: #555;
    text-decoration: line-through;
    font-weight: 600;
}

table.rule-matrix td.na {
    background-color: #fbfbfc;
    color: transparent;
}

/* Legend chips for the rule matrix */
.rule-matrix-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    margin: 8px 0 18px;
    font-size: 0.9em;
    color: #2a3a4d;
}

.rule-matrix-legend .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.rule-matrix-legend .chip {
    display: inline-block;
    min-width: 56px;
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.06);
    font-weight: 700;
    text-align: center;
    font-size: 0.85em;
}

.rule-matrix-legend .chip.req { background-color: #fce2e2; color: #8b1d1d; }
.rule-matrix-legend .chip.req-cond { background-color: #fde0bc; color: #7a4400; }
.rule-matrix-legend .chip.opt { background-color: #fff1c2; color: #6e5300; }
.rule-matrix-legend .chip.ns { background-color: #cfcfcf; color: #555; text-decoration: line-through; }
.rule-matrix-legend .chip.na { background-color: #fbfbfc; color: #fbfbfc; border-color: #e5e8ec; }

/* Network Communication Requirements table */
.wy-table-responsive table.network-comm {
    table-layout: fixed;
}

.wy-table-responsive table.network-comm td:nth-child(1) {
    width: 20%;
}

.wy-table-responsive table.network-comm td:nth-child(2) {
    width: 20%;
}

.wy-table-responsive table.network-comm td:nth-child(3) {
    width: 10%;
}

.wy-table-responsive table.network-comm td:nth-child(4) {
    width: 15%;
}

.wy-table-responsive table.network-comm td:nth-child(5) {
    width: 35%;
}

/* ── Long technical strings ── */
.technical-content,
.uid-text,
code,
.literal {
    word-break: break-all !important;
    overflow-wrap: break-word !important;
    max-width: 100%;
    hyphens: auto;
}

.highlight .go,
pre code {
    word-break: break-all;
    white-space: pre-wrap;
}

/* ── Images ── */
.document img,
.figure img,
img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 4px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.figure .caption {
    text-align: center;
    font-style: italic;
    margin-top: 10px;
    color: #666;
}

/* ── Code blocks ── */
.highlight pre {
    padding: 12px;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    background-color: #f8f8f8;
    border: 1px solid #e1e4e5;
    border-radius: 4px;
}

/* ── Inline code ── */
code.literal,
p code,
li code,
td code,
dd code {
    background-color: #f0f4f8;
    border: 1px solid #dce3eb;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.88em;
}

/* ── Links ── */
.wy-nav-content a {
    transition: color 0.15s ease, border-color 0.15s ease;
}

a.external::after {
    content: " \2197";
    font-size: 0.8em;
    opacity: 0.7;
}

a.external {
    color: #2980b9;
    text-decoration: none;
    border-bottom: 1px dotted #2980b9;
}

a.external:hover {
    color: #3498db;
    border-bottom: 1px solid #3498db;
}

/* ── Section headings ── */
.wy-nav-content .section > h2,
.wy-nav-content .section > h3,
.wy-nav-content section > h2,
.wy-nav-content section > h3 {
    padding-bottom: 6px;
    border-bottom: 1px solid #e8ecf0;
    margin-top: 28px;
}

/* ── Installation indentation ── */
.installation-steps ol,
.installation-steps ul {
    margin-left: 20px;
    padding-left: 20px;
}

.installation-steps li {
    margin-bottom: 12px;
    line-height: 1.6;
}

.installation-steps li p {
    margin-bottom: 8px;
}

.installation-steps .highlight {
    margin: 8px 0;
}

/* ── Next steps boxes ── */
.next-steps {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 20px;
    margin: 30px 0;
}

.next-steps h2 {
    color: #2c5aa0;
    margin-bottom: 15px;
    border-bottom: 2px solid #2c5aa0;
    padding-bottom: 5px;
}

.next-steps ul {
    margin-left: 0;
    padding-left: 20px;
}

.next-steps li {
    margin-bottom: 8px;
}

.next-steps a {
    font-weight: 500;
    color: #2c5aa0;
}

/* ── Admonitions ── */
.admonition {
    margin: 20px 0;
    padding: 16px;
    border-left: 4px solid #f39c12;
    background-color: #fff8dc;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.admonition.warning {
    border-left-color: #e74c3c;
    background-color: #fdf2f2;
}

.admonition.danger {
    border-left-color: #c0392b;
    background-color: #fdf2f2;
}

.admonition.note {
    border-left-color: #3498db;
    background-color: #f0f7ff;
}

.admonition.tip {
    border-left-color: #27ae60;
    background-color: #f0fff4;
}

.admonition.important {
    border-left-color: #8e44ad;
    background-color: #f8f0ff;
}

.admonition .admonition-title {
    font-weight: 600;
    margin-bottom: 6px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .wy-table-responsive table {
        font-size: 0.85em;
    }

    .wy-table-responsive table td,
    .wy-table-responsive table th {
        padding: 6px 8px;
        max-width: 200px;
    }

    .wy-table-responsive table.network-comm td:nth-child(4),
    .wy-table-responsive table.network-comm th:nth-child(4) {
        display: none;
    }
}

@media (max-width: 480px) {
    .wy-table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .wy-table-responsive table {
        min-width: 600px;
    }

    .installation-steps {
        padding: 0 10px;
    }
}

/* ── Search highlighting ── */
.highlighted {
    background-color: #ffff88;
    padding: 1px 2px;
    border-radius: 2px;
}

/* ── Sidebar TOC ── */
.wy-menu-vertical li.toctree-l1>a {
    font-weight: bold;
}

.wy-menu-vertical li.current {
    background-color: transparent !important;
}

.wy-menu-vertical li.current>a {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    border-right: 3px solid #2c5aa0;
}

.wy-menu-vertical li.current li>a {
    color: rgba(255, 255, 255, 0.75) !important;
}

.wy-menu-vertical li.current li.current>a {
    color: #ffffff !important;
}

/* ── Requirements tables ── */
.requirements-table th,
.requirements-table td {
    text-align: center;
}

.requirements-table th:first-child,
.requirements-table td:first-child {
    text-align: left;
    font-weight: bold;
}

/* ── Scrollbar ── */
.wy-table-responsive::-webkit-scrollbar {
    height: 8px;
}

.wy-table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.wy-table-responsive::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.wy-table-responsive::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}


/* ── Sidebar search overrides ── */
.wy-side-nav-search {
    background: transparent !important;
    margin-bottom: 0 !important;
}

.wy-side-nav-search > a,
.wy-side-nav-search > a:hover {
    background: none !important;
    color: #fff !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 18px;
}

.wy-side-nav-search a img.logo {
    display: inline-block !important;
    vertical-align: middle !important;
    height: 52px !important;
    width: 52px !important;
    max-width: 52px !important;
    object-fit: contain;
}

.wy-side-scroll .wy-side-nav-search form#rtd-search-form {
    display: none !important;
}

/* Hide sidebar version badge (RTD flyout in bottom-right is sufficient) */
.wy-side-nav-search .version,
.wy-nav-side .rst-versions {
    display: none !important;
}

/* ── Topbar ── */
#els-topbar {
    position: fixed;
    top: 0;
    left: 300px;
    right: 0;
    z-index: 1000;
    background-image: url("img/top_bar_background.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: #fff;
}

.els-topbar__inner {
    max-width: 1200px;
    
    padding: 12px 16px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 16px;
    align-items: center;
}

.els-brand img {
    height: 40px;
    display: block;
}

.els-breadcrumb {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.els-breadcrumb__home {
    opacity: .85;
}

.els-breadcrumb__sep {
    margin: 0 6px;
    opacity: .6;
}

/* ── Topbar search ── */
.els-topbar__search input[type="text"] {
    width: 240px;
    height: 32px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    outline: none;
    padding: 0 14px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 0.9em;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.els-topbar__search input[type="text"]::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.els-topbar__search input[type="text"]:focus {
    background: rgba(255, 255, 255, 0.95);
    color: #111;
    border-color: rgba(255, 255, 255, 0.5);
}

.els-topbar__search input[type="text"]:focus::placeholder {
    color: #999;
}

/* ── Content area ── */
.wy-nav-content {
    width: 100% !important;
    max-width: 100% !important;
}

.wy-nav-content-wrap {
    padding-top: 70px;
    background: #fcfcfc;
}

/* Hide the empty contentinfo + its separator (we disable copyright/sphinx) */
footer hr,
footer div[role="contentinfo"] {
    display: none;
}

/* ── Sidebar expand/collapse arrows ── */
.wy-menu-vertical .toctree-expand {
    opacity: 0.6;
    visibility: visible;
}

.wy-menu-vertical li:hover > a .toctree-expand {
    opacity: 1;
}

.wy-menu-vertical li button.toctree-expand {
    opacity: 1 !important;
    display: block !important;
}

.wy-menu-vertical li.current > a button.toctree-expand,
.wy-menu-vertical li.on a button.toctree-expand {
    opacity: 1 !important;
}

/* ── AI Agent Modal ── */
.prem-overlay,
#sdc-assistant-root > .prem-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.7) !important;
    z-index: 9998 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.prem-chat {
    z-index: 9999 !important;
    position: relative !important;
}

#els-topbar {
    z-index: 100 !important;
}

.wy-nav-top {
    z-index: 100 !important;
}

/* ── Mobile topbar (RTD sidebar collapses below 768px) ── */
@media (max-width: 768px) {
    #els-topbar {
        left: 0;
    }

    .els-topbar__inner {
        padding: 10px 12px;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .els-topbar__search input[type="text"] {
        width: 100%;
        box-sizing: border-box;
    }

    .wy-nav-content-wrap {
        padding-top: 100px;
    }

    /* Scroll hint: fade the right edge of horizontally scrollable tables so
       users see there is more content to swipe to. */
    .wy-table-responsive {
        position: relative;
    }

    .wy-table-responsive::after {
        content: "";
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 28px;
        background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(0, 0, 0, 0.18));
        pointer-events: none;
    }

    /* Drop the duplicate "Energy Logserver" link from the RTD mobile bar.
       The breadcrumb in #els-topbar already shows the project name. */
    .wy-nav-top > a {
        display: none;
    }

    /* Tighten code block padding on mobile — RTD default 12px eats horizontal
       space that matters more on a 375px viewport. */
    .highlight pre,
    .rst-content div[class^="highlight"] pre {
        padding: 8px 10px;
    }

    /* Enlarge Previous/Next footer buttons to WCAG 2.5.5 AAA 44×44 tap target. */
    .rst-footer-buttons .btn {
        min-height: 44px;
        padding: 10px 16px;
        display: inline-flex;
        align-items: center;
    }

    /* Keep the RTD mobile bar in normal flow — on some real devices it ends up
       position:fixed and overlaps #els-topbar. Static forces it to sit below
       the fixed topbar's reserved padding-top. */
    .wy-nav-top {
        position: static !important;
    }
}
