/* =====================================================
   PATMA KNOWLEDGE HUB STYLESHEET
   CLEAN REFACTOR — PART 1
   Theme Compatibility + Foundation + Typography + Layout
   ===================================================== */


/* =====================================================
   THEME COMPATIBILITY (MkDocs / Bootstrap)
   ===================================================== */

html {
    /* Nav header is 3.5rem high + main container margin */
    scroll-padding-top: calc(3.5rem + 20px);
}

.source-links {
    float: right;
}

hr {
    border-top: 1px solid #aaa;
}

.modal-dialog {
    margin-top: 60px;
}

@media print {
    #sidebar-holder {
        display: none;
    }
}


/* =====================================================
   GLOBAL FOUNDATION
   ===================================================== */

body {
    font-size: 17px;
    line-height: 1.7;

    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;

    background: #f8fafc;
    color: #1f1f1f;
}

#main-content {
    max-width: 900px;
}


/* =====================================================
   TYPOGRAPHY
   ===================================================== */

p,
li {
    line-height: 1.7;
    color: #4d5560;
}

p {
    margin-bottom: 1rem;
}

/* Headings — keep existing sizes/weights, modernise colours */

h1 {
    font-size: 2.2rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.4rem;

    font-weight: 600;
    color: #1f1f1f;

    border-bottom: 1px solid #e8edf2;
}

h2 {
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 0.7rem;

    font-weight: 600;
    color: #1f1f1f;
}

h3 {
    font-size: 1.25rem;
    margin-top: 1.4rem;
    margin-bottom: 0.5rem;

    font-weight: 600;
    color: #1f1f1f;
}

h4 {
    font-size: 1.1rem;
    margin-top: 1.2rem;
    margin-bottom: 0.4rem;

    font-weight: 600;
    color: #1f1f1f;
}

h5,
h6 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #1f1f1f;
}

/* Header anchor links */

.headerlink {
    font-family: FontAwesome;
    font-size: 14px;
    display: none;
    padding-left: 0.5em;
}

h1:hover .headerlink,
h2:hover .headerlink,
h3:hover .headerlink,
h4:hover .headerlink,
h5:hover .headerlink,
h6:hover .headerlink {
    display: inline-block;
}


/* =====================================================
   SECTION SPACING
   ===================================================== */

section {
    margin-bottom: 4rem;
}


/* =====================================================
   ADMONITIONS / ALERT BOXES
   ===================================================== */

.admonition {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
    text-align: left;
}

.admonition-title {
    font-weight: bold;
    text-align: left;
}

.admonition.note {
    color: #3a87ad;
    background-color: #d9edf7;
    border-color: #bce8f1;
}

.admonition.warning {
    color: #c09853;
    background-color: #fcf8e3;
    border-color: #fbeed5;
}

.admonition.danger {
    color: #b94a48;
    background-color: #f2dede;
    border-color: #eed3d7;
}

/* =====================================================
   CLEAN REFACTOR — PART 2
   Sidebar + Navigation + Links + Code Blocks
   ===================================================== */


/* =====================================================
   SIDEBAR / NAVIGATION
   ===================================================== */

.bs-sidebar {
    font-size: 0.95rem;
    max-width: 255px;
    margin-top: 1.8rem;
}

.bs-sidebar.affix {
    position: sticky;
    top: 110px;
}

.bs-sidebar.card {
    padding: 0;
    padding-right: 0;
    max-height: 90%;
    overflow-y: auto;
}

/* Sidebar collapse behaviour */
.bs-sidebar .navbar-toggler span {
    transform: scale(1, -1);
}

.bs-sidebar .navbar-toggler.collapsed span {
    transform: scale(1, 1);
}

/* Navigation container */
.bs-sidebar > .navbar-collapse > .nav {
    padding-top: 10px;
    padding-bottom: 10px;
    border-radius: 5px;
    width: 100%;
}

/* All navigation links */
.bs-sidebar .nav > li > a {
    display: block;
    padding: 5px 20px;
    z-index: 1;

    font-weight: bold;
    color: #4a4f55;
}

/* Nested navigation */
.bs-sidebar .nav .nav > li > a {
    font-weight: normal;
    color: #55697d;
}

.bs-sidebar .nav .nav .nav > li > a {
    margin-left: 1em;
    color: #6b7d90;
}

/* Hover */
.bs-sidebar .nav > li > a:hover,
.bs-sidebar .nav > li > a:focus {
    text-decoration: none;
    background: #f7f7f7;
    color: #1f1f1f;
    border-right: 2px solid #dddddd;
}

/* Active page */
.bs-sidebar .nav > li > a.active,
.bs-sidebar .nav > li > a.active:hover,
.bs-sidebar .nav > li > a.active:focus {
    font-weight: bold;
    color: #1f1f1f;
    background: #fafafa;
    border-right: 2px solid #c62828;
}


/* =====================================================
   LINKS
   ===================================================== */

/* Default links inherit parent colour so nav/sidebar/etc
   keep their own styling */
a,
a:visited {
    color: inherit;
    text-decoration-color: #d7dde5;

    transition:
        color 0.18s ease,
        text-decoration-color 0.18s ease;
}

/* Global hover accent */
a:hover,
a:focus {
    color: #c62828;
    text-decoration-color: #dca3a3;
}

/* Inline content links inside article body */
#main-content p a,
#main-content li a,
#main-content td a {
    color: #2f3742;
}

#main-content p a:hover,
#main-content li a:hover,
#main-content td a:hover {
    color: #c62828;
}

/* Dropdown menu links (first column) */
details td:first-child a,
details td:first-child a:visited {
    color: #1f1f1f !important;
    font-weight: 600;
    text-decoration-color: transparent;
}

details td:first-child a:hover {
    color: #c62828 !important;
}

/* Preserve code colouring inside links */
a code {
    color: inherit;
}

a:hover code,
a:focus code {
    color: inherit;
}

/* =====================================================
   SEARCH BUTTON
   ===================================================== */

.search-btn {
    margin-top: 0.1rem;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}


/* =====================================================
   CODE BLOCKS
   ===================================================== */

pre,
.rst-content tt {
    max-width: 100%;
    background: #fff;
    border: 1px solid #e1e4e5;
    color: #333;
    overflow-x: auto;
}

code {
    padding: 2px 5px;
    background: #fff;
    border: 1px solid #e1e4e5;
    color: #333;

    font-size: 0.95em;

    white-space: pre-wrap;
    word-wrap: break-word;
}

code.code-large,
.rst-content tt.code-large {
    font-size: 90%;
}

pre code {
    display: block;
    background: transparent;
    border: none;

    white-space: pre;
    word-wrap: normal;

    font-family:
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        "Liberation Mono",
        "Courier New",
        monospace;

    font-size: 13px;
    line-height: 1.5;
}

kbd {
    padding: 2px 4px;
    font-size: 90%;
    color: #fff;
    background-color: #333;
    border-radius: 3px;

    box-shadow: inset 0 -1px 0 rgba(0,0,0,.25);
}


/* =====================================================
   DROPDOWN MENUS (Bootstrap compatibility)
   ===================================================== */

.dropdown-item.open {
    color: #fff;
    background-color: #2FA4E7;
}

.dropdown-submenu > .dropdown-menu {
    margin: 0 0 0 1.5rem;
    padding: 0;
    border-width: 0;
}

.dropdown-submenu > a::after {
    display: block;
    content: " ";
    float: right;

    width: 0;
    height: 0;

    border-color: transparent;
    border-style: solid;
    border-width: 5px 0 5px 5px;
    border-left-color: #ccc;

    margin-top: 5px;
    margin-right: -10px;
}

.dropdown-submenu:hover > a::after {
    border-left-color: #fff;
}

@media (min-width: 992px) {
    .dropdown-menu {
        overflow-y: auto;
        max-height: calc(100vh - 3.5rem);
    }

    .dropdown-submenu {
        position: relative;
    }

    .dropdown-submenu > .dropdown-menu {
        position: fixed !important;
        margin-top: -9px;
        margin-left: -2px;
        border-width: 1px;
        padding: 0.5rem 0;
    }

    .dropdown-submenu.pull-left > .dropdown-menu {
        left: -100%;
        margin-left: 10px;
    }
}

@media (max-width: 991.98px) {
    .navbar-collapse.show {
        overflow-y: auto;
        max-height: calc(100vh - 3.5rem);
    }
}

/* =====================================================
   CLEAN REFACTOR — PART 3
   Tables + Images
   ===================================================== */


/* =====================================================
   SHARED CARD SHADOW SYSTEM
   ===================================================== */

:root {
    --kb-card-shadow:
        0 1px 2px rgba(15,23,42,0.02),
        0 6px 18px rgba(15,23,42,0.035);
}

.kb-product-card,
.kb-whats-new-card,
.kb-video-banner,
details {
    will-change: box-shadow;
}


/* =====================================================
   TABLES (STANDALONE DATA TABLES)
   ===================================================== */

table {
    width: 100%;
    border-collapse: collapse;

    margin-top: 0.8rem;
    margin-bottom: 2rem;

    font-size: 0.95rem;
    background: #ffffff;

    border: 1px solid #e8edf2;
    border-radius: 16px;

    overflow: hidden;
    box-shadow: var(--kb-card-shadow);
}

/* Header row */
thead {
    background: #fafbfd;
}

th {
    text-align: left;
    padding: 10px 14px;

    font-weight: 600;
    color: #1f1f1f;

    border-bottom: 1px solid #e8edf2;
}

/* Cells */
td {
    padding: 9px 14px;
    vertical-align: top;

    color: #444c56;
    border-bottom: 1px solid #f1f4f7;
}

/* Zebra striping for real tables only */
table:not(details table) tbody tr:nth-child(even) {
    background-color: #fcfdff;
}

table:not(details table) tbody tr:hover {
    background-color: #f8fafc;
}

tbody tr:last-child td {
    border-bottom: none;
}


/* =====================================================
   TABLES INSIDE DROPDOWNS
   Styled as menu rows, not spreadsheets
   ===================================================== */

details {
    padding-bottom: 0 !important;
}

details table {
    margin: 0 !important;
    margin-bottom: 0 !important;
    width: 100%;

    border: none;
    border-radius: 0 0 16px 16px !important;
    overflow: hidden;

    background: #ffffff;
    box-shadow: none !important;
}

/* Remove zebra striping inside dropdowns */
details tr,
details tbody tr {
    background: #ffffff !important;
}

/* Dropdown rows */
details td {
    padding: 12px 16px;
    vertical-align: middle;

    color: #444c56;
    border-bottom: 1px solid #eef2f6;
}

/* First column (guide links / menu labels) */
details td:first-child {
    width: 280px;
}

/* First-column links */
details td:first-child a,
details td:first-child a:visited {
    color: #1f1f1f !important;
    font-weight: 500;
    text-decoration: none;
}

/* Hover state */
details tr:hover {
    background: #f8fafc !important;
}

details td:first-child a:hover {
    color: #c62828 !important;
}

/* Remove bottom border on last row */
details tr:last-child td {
    border-bottom: none;
}

/* Prevent rounded corner glitches */
details table tr:first-child td,
details table tr:first-child th {
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
}

/* =====================================================
   IMAGES
   ===================================================== */

#main-content img {
    max-width: 95%;
    height: auto;

    display: block;
    margin: 1rem auto;
    padding: 0;

    background: #ffffff;
    border: 1px solid #e8edf2;
    border-radius: 16px;

    box-shadow: var(--kb-card-shadow);
}

/* =====================================================
   CLEAN REFACTOR — PART 4
   Dropdowns / Details
   ===================================================== */


/* =====================================================
   DETAILS CONTAINER
   ===================================================== */

details {
    margin-top: 1rem;
    margin-bottom: 1.5rem;

    background: #ffffff;

    border: 1px solid #e8edf2;
    border-radius: 16px;

    overflow: hidden;
    box-shadow: var(--kb-card-shadow);
}


/* =====================================================
   SUMMARY (CLICKABLE HEADER)
   ===================================================== */

details summary {
    cursor: pointer;
    list-style: none;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 14px 22px;

    font-weight: 300;
    color: #1f1f1f;

    background: linear-gradient(to bottom, #ffffff, #fbfcfd);

    border: none;

    transition:
        background 0.2s ease,
        border-color 0.2s ease;
}

/* Remove default browser arrow */
details summary::-webkit-details-marker {
    display: none;
}


/* =====================================================
   CUSTOM ARROW
   ===================================================== */

details summary::after {
    content: "▸";

    font-size: 1.15rem;
    font-weight: 300;
    color: #7a828a;

    transition: transform 0.2s ease;
}


/* =====================================================
   SUMMARY HOVER
   ===================================================== */

details summary:hover {
    background: linear-gradient(to bottom, #ffffff, #f8fafc);
}


/* =====================================================
   OPEN STATE
   ===================================================== */

details[open] summary {
    border-bottom: 1px solid #e8edf2;
}

details[open] summary::after {
    transform: rotate(90deg);
}


/* =====================================================
   DROPDOWN CONTENT
   ===================================================== */

details table,
details p {
    margin-top: 0;
    margin-bottom: 0;
}

details[open] > *:not(summary) {
    background: #ffffff;
}

/* =====================================================
   CLEAN REFACTOR — PART 5
   Product Cards + Changelog Grid
   ===================================================== */


/* =====================================================
   PRODUCT GRID
   ===================================================== */

.kb-product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin: 2rem 0;
}


/* =====================================================
   PRODUCT CARDS
   ===================================================== */

.kb-product-card {
    display: flex;
    flex-direction: column;

    padding: 1.45rem;

    background: #ffffff;
    border: 1px solid #e8edf2;
    border-radius: 16px;

    text-decoration: none !important;
    box-shadow: var(--kb-card-shadow);

    transition:
        box-shadow 0.2s ease,
        border-color 0.2s ease;
}

.kb-product-card strong {
    color: #1f1f1f;
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
}

.kb-product-card span {
    color: #4d5560;
    font-size: 0.9rem;
    line-height: 1.4;
}

.kb-product-card:hover {
    border-color: #dde5ec;

    box-shadow:
        0 0 0 1px rgba(198,40,40,0.06),
        0 8px 24px rgba(0,0,0,0.05);
}


/* =====================================================
   CHANGELOG GRID
   ===================================================== */

.kb-changelog-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 2rem 0;
}


/* =====================================================
   GRID RESPONSIVENESS
   ===================================================== */

@media (max-width: 992px) {
    .kb-product-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .kb-changelog-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .kb-product-grid {
        grid-template-columns: 1fr;
    }
}

/* =====================================================
   CLEAN REFACTOR — PART 6
   What's New + Video Banner + Badges + Responsive
   ===================================================== */


/* =====================================================
   LATEST GUIDES / WHAT'S NEW
   ===================================================== */

.kb-whats-new-intro {
    margin-bottom: 1rem;
    color: #4d5560;
}

.kb-whats-new-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.kb-whats-new-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;

    padding: 1.4rem;

    background: #ffffff;

    border: 1px solid #e8edf2;
    border-left: 4px solid #c62828;
    border-radius: 16px;

    text-decoration: none !important;
    box-shadow: var(--kb-card-shadow);

    transition:
        box-shadow 0.2s ease,
        border-color 0.2s ease;
}

.kb-whats-new-card:hover {
    border-left-color: #d32f2f;

    box-shadow:
        0 0 0 1px rgba(198,40,40,0.08),
        0 8px 24px rgba(0,0,0,0.05);
}

.kb-whats-new-card strong {
    color: #1f1f1f;
}

.kb-whats-new-card span:not(.kb-update-badge) {
    color: #4d5560;
    line-height: 1.5;
}

/* =====================================================
   BADGES
   ===================================================== */

.kb-update-badge {
    display: inline-block;
    width: fit-content;

    padding: 0.25rem 0.5rem;

    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;

    border-radius: 999px;
}

/* Badge variants */
.kb-update-badge.updated {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
}

.kb-update-badge.new {
    background: #fff3f3;
    color: #c62828;
    border: 1px solid #f4d4d4;
}

.kb-update-badge.video {
    background: #fdf2f8;
    color: #be185d;
    border: 1px solid #fbcfe8;
}


/* =====================================================
   VIDEO BANNER
   ===================================================== */

.kb-video-banner {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;

    margin-top: 1.25rem;
    padding: 1.25rem 1.75rem;

    background: linear-gradient(135deg, #ffffff 0%, #fbfcfd 100%);

    border: 1px solid #e8edf2;
    border-left: 4px solid #c62828;
    border-radius: 16px;

    text-decoration: none !important;
    box-shadow: var(--kb-card-shadow);

    transition:
        box-shadow 0.2s ease,
        border-color 0.2s ease;
}

.kb-video-banner:hover {
    box-shadow:
        0 0 0 1px rgba(198,40,40,0.08),
        0 8px 24px rgba(0,0,0,0.05);
}

.kb-video-banner strong {
    display: block;
    margin: 0;

    color: #1f1f1f;
    line-height: 1.2;
}

.kb-video-banner span:not(.kb-update-badge) {
    color: #4d5560;
    line-height: 1.5;
}


/* =====================================================
   GLOBAL RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
    body {
        font-size: 16px;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.35rem;
    }

    h3 {
        font-size: 1.15rem;
    }

    #main-content {
        max-width: 100%;
    }

    .bs-sidebar {
        max-width: 100%;
    }

    table {
        font-size: 0.9rem;
    }

    th,
    td {
        padding: 8px 10px;
    }

    .kb-video-banner {
        padding: 1rem 1.25rem;
    }
}