/* ===== GLOBAL DARK GRAY PREMIUM THEME ===== */
:root {
    /* Backgrounds (Premium Milk Gray) */
    --ph-bg-primary: #141414;
    --ph-bg-secondary: #1a1a1a;
    --ph-bg-tertiary: #212121;
    --ph-bg-elevated: #282828;

    /* Text */
    --ph-text-primary: #f5f5f4;
    --ph-text-secondary: #d6d3d1;
    --ph-text-muted: #a8a29e;
    --ph-text-placeholder: #78716c;

    /* Accent (Neutral Warm White) */
    --ph-accent: #f5f5f4;
    --ph-accent-hover: #ffffff;
    --ph-accent-subtle: rgba(255, 255, 255, 0.06);

    /* Borders */
    --ph-border: rgba(255, 255, 255, 0.08);
    --ph-border-light: rgba(255, 255, 255, 0.04);

    /* Code */
    --ph-code-bg: #171717;
    --ph-code-border: rgba(255, 255, 255, 0.08);
    --ph-code-text: #fafaf9;
    --ph-inline-code-bg: rgba(255, 255, 255, 0.05);

    /* ===== ADMONITIONS – SUBTLE NEUTRAL PALETTE ===== */
    /* Note: soft warm gray, slightly lighter */
    --ph-note-bg: rgba(255, 255, 255, 0.03);
    --ph-note-border: #7a736e;
    /* warm stone */

    /* Tip: very light haze */
    --ph-tip-bg: rgba(255, 255, 255, 0.04);
    --ph-tip-border: #a09a94;
    /* lighter stone */

    /* Warning: deeper muted tone */
    --ph-warning-bg: rgba(255, 255, 255, 0.025);
    --ph-warning-border: #57534e;
    /* dark pebble */

    /* Danger: darkest subtle border */
    --ph-danger-bg: rgba(255, 255, 255, 0.02);
    --ph-danger-border: #44403c;
    /* deep warm gray */

    /* Tables */
    --ph-table-bg: #181818;
    --ph-table-border: var(--ph-border);
    --ph-table-stripe: #1d1d1d;

    /* Material for MkDocs */
    --md-default-bg-color: var(--ph-bg-primary);
    --md-default-fg-color: var(--ph-text-primary);
    --md-default-fg-color--light: var(--ph-text-secondary);
    --md-typeset-a-color: var(--ph-accent);
    --md-accent-fg-color: var(--ph-accent-hover);
    --md-accent-bg-color: var(--ph-accent-subtle);
}

/* ===== HEADER – SAME TONE AS FOOTER ===== */
.md-header-custom {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    height: 3rem;
    display: flex;
    align-items: center;
    background-color: var(--ph-bg-secondary);
    border-bottom: 1px solid var(--ph-border);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.header-container {
    width: 100%;
    max-width: 75rem;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

/* HAMBURGER */
.md-header__button.md-icon--menu {
    display: none;
}

@media (max-width: 767px) {
    .md-header__button.md-icon--menu {
        display: inline-flex;
    }
}

.header-hamburger {
    cursor: pointer;
    color: #b0b0b0;
    transition: color 0.15s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-hamburger:hover {
    color: #ffffff;
}

.header-hamburger svg {
    width: 24px;
    height: 24px;
}

/* BRAND */
.header-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: inherit;
    text-decoration: none;
    flex-shrink: 0;
}

.header-logo {
    display: none;
    color: #b0b0b0;
    transition: color 0.15s ease;
}

.header-right {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.header-beta {
    padding: .15rem .4rem;

    background: #2f2f2f;

    color: #8e8e93;
    font-size: .68rem;
    font-weight: 500;

    border-radius: 5px;
}

@media (min-width: 640px) {
    .header-logo {
        display: block;
    }
}

.header-title {
    font-weight: 700;
    font-size: 20px;
    letter-spacing: -0.025em;
    color: #e8e8e8;
    white-space: nowrap;
    transition: color 0.15s ease;
}

.header-left:hover .header-title {
    color: #ffffff;
}

/* SEARCH */
.header-search {
    display: none;
    position: relative;
    flex: 1;
    max-width: 28rem;
    min-width: 0;
}

@media (min-width: 768px) {
    .header-search {
        display: flex;
        width: 16rem;
    }
}

@media (min-width: 1024px) {
    .header-search {
        width: 20rem;
    }
}

@media (max-width: 767px) {
    .header-search {
        display: none !important;
    }
}

.header-search__icon {
    position: absolute;
    inset: 0 auto 0 0;
    display: flex;
    align-items: center;
    padding-left: 0.75rem;
    color: #888888;
    z-index: 10;
    pointer-events: none;
}

.header-search__icon-svg {
    width: 1rem;
    height: 1rem;
}

.header-search:focus-within .header-search__icon {
    color: #cccccc;
}

.search-input {
    width: 100%;
    background-color: #2a2a2a;
    color: #e8e8e8;
    font-size: 0.875rem;
    border-radius: 9999px;
    padding: 6px 1rem 6px 2.25rem;
    border: none;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    min-width: 0;
}

.search-input::placeholder {
    color: #777777;
    font-weight: 400;
}

.search-input:focus {
    outline: none;
    background-color: #1a1a1a;
    box-shadow: 0 0 0 2px rgba(150, 150, 150, 0.3);
}

/* REPOSITORY LINK */
.header-repo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 14px;
    font-weight: 500;
    color: #b0b0b0;
    text-decoration: none;
    transition: color 0.15s ease, background-color 0.15s ease;
    flex-shrink: 0;
    padding: 4px 8px;
    border-radius: 6px;
}

.header-repo:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.06);
}

.header-repo__label {
    display: none;
}

@media (min-width: 640px) {
    .header-repo__label {
        display: block;
    }
}

/* Reset Material header overrides */
.md-header {
    background: transparent !important;
    box-shadow: none !important;
    position: relative !important;
}

.md-search__form,
.md-search__form:hover {
    background-color: transparent !important;
    box-shadow: none !important;
}

.md-search {
    display: flex !important;
}

/* ===== RESPONSIVE HEADER ===== */
@media (max-width: 480px) {
    .header-container {
        padding: 0 0.5rem;
        gap: 0.25rem;
    }

    .header-left {
        gap: 0.25rem;
    }

    .header-right {
        gap: 0.25rem;
    }

    .header-title {
        font-size: 13px;
    }

    .header-repo {
        padding: 2px 4px;
    }

    .header-repo svg {
        width: 16px;
        height: 16px;
    }
}

@media (min-width: 481px) and (max-width: 767px) {
    .header-container {
        gap: 0.5rem;
    }

    .header-title {
        font-size: 14px;
    }
}

/* ===== HEADING HIERARCHY ===== */
.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
    color: var(--md-default-fg-color);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.3;
    scroll-margin-top: 4rem;
}

.md-typeset h1 {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--ph-h-border);
}

.md-typeset h1:first-child {
    margin-top: 0;
}

.md-typeset h2 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 3rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--ph-h-border);
}

.md-typeset h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 2rem 0 0.75rem;
}

.md-typeset h4 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 1.75rem 0 0.6rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--ph-h-accent);
}

.md-typeset h5 {
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ph-h-muted);
    margin: 1.5rem 0 0.5rem;
}

.md-typeset h6 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ph-h-muted);
    margin: 1.25rem 0 0.5rem;
}

/* ===== BASE TYPOGRAPHY & CONTENT ===== */
.md-typeset {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--ph-text-secondary);
}

.md-typeset p {
    margin-bottom: 1.25rem;
}

.md-typeset strong {
    color: var(--ph-text-primary);
}

.md-typeset a {
    color: var(--ph-accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.md-typeset a:hover {
    color: var(--ph-accent-hover);
    border-bottom-color: var(--ph-accent-hover);
}

.md-typeset ul,
.md-typeset ol {
    padding-left: 1.5rem;
}

/* ===== NAVIGATION / SIDEBAR ===== */
.md-nav {
    color: var(--ph-text-secondary);
}

.md-nav__title {
    color: var(--ph-text-primary);
    font-weight: 600;
}

.md-nav__item .md-nav__link {
    color: var(--ph-text-secondary);
    transition: color 0.15s, background 0.15s;
    border-radius: 6px;
    padding: 4px 8px;
}

.md-nav__item .md-nav__link:hover {
    color: var(--ph-text-primary);
    background-color: var(--ph-bg-tertiary);
}

.md-nav__item .md-nav__link--active {
    color: var(--ph-accent);
    background-color: var(--ph-accent-subtle);
}

.md-sidebar__scrollwrap::-webkit-scrollbar {
    width: 4px;
}

.md-sidebar__scrollwrap::-webkit-scrollbar-thumb {
    background: var(--ph-bg-tertiary);
    border-radius: 4px;
}

/* ===== CODE BLOCKS & INLINE CODE ===== */
.md-typeset code {
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, monospace;
    font-size: 0.85rem;
    background-color: var(--ph-inline-code-bg);
    color: var(--ph-inline-code-text);
    border-radius: 4px;
    padding: 0.2em 0.4em;
}

.md-typeset pre {
    background-color: var(--ph-code-bg);
    border: 1px solid var(--ph-code-border);
    border-radius: 8px;
    box-shadow: var(--ph-shadow-sm);
}

.md-typeset pre>code {
    background: transparent;
    padding: 1rem;
}

.hljs {
    background: transparent;
    color: var(--ph-code-text);
}

/* ===== ADMONITIONS ===== */
.md-typeset .admonition {
    --accent: var(--ph-border);

    border: 1px solid var(--ph-border);
    border-left: 4px solid var(--accent);

    border-radius: 8px;
    box-shadow: var(--ph-shadow-sm);
}

.md-typeset .admonition.note {
    --accent: var(--ph-note-border);
    background: var(--ph-note-bg);
}

.md-typeset .admonition.tip {
    --accent: var(--ph-tip-border);
    background: var(--ph-tip-bg);
}

.md-typeset .admonition.warning {
    --accent: var(--ph-warning-border);
    background: var(--ph-warning-bg);
}

.md-typeset .admonition.danger {
    --accent: var(--ph-danger-border);
    background: var(--ph-danger-bg);
}

/* ===== TABLES ===== */
.md-typeset table {
    background-color: var(--ph-table-bg);
    border: 1px solid var(--ph-table-border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--ph-shadow-sm);
}

.md-typeset table th {
    background-color: var(--ph-table-header-bg);
    font-weight: 600;
    color: var(--ph-text-primary);
    padding: 0.75rem 1rem;
}

.md-typeset table td {
    border-top: 1px solid var(--ph-table-border);
    padding: 0.65rem 1rem;
}

.md-typeset table tr:nth-child(even) {
    background-color: var(--ph-table-stripe);
}

/* ===== STANDARD FOOTER (if used) ===== */
.md-footer {
    background-color: var(--ph-bg-secondary);
    border-top: 1px solid var(--ph-border);
    color: var(--ph-text-muted);
}

.md-footer-meta {
    background-color: var(--ph-bg-tertiary);
}

.md-footer__link {
    color: var(--ph-text-secondary);
    transition: color 0.15s;
}

.md-footer__link:hover {
    color: var(--ph-text-primary);
}

/* ===== CUSTOM FOOTER – SAME TONE AS HEADER ===== */
footer[data-md-component="footer"] {
    background-color: var(--ph-bg-secondary) !important;
    border-color: var(--ph-border) !important;
}

footer nav {
    border-color: var(--ph-border) !important;
}

/* All gray/black text -> secondary */
footer .text-gray-500,
footer .text-gray-400,
footer .text-gray-600,
footer .text-gray-800,
footer .text-gray-900,
footer .text-black {
    color: var(--ph-text-secondary) !important;
}

/* Hover accent for links inside footer */
footer a:hover .text-gray-800,
footer a:hover .text-blue-600,
footer a:hover .text-gray-500,
footer .group:hover .text-blue-500,
footer .group:hover .text-blue-600 {
    color: var(--ph-accent-hover) !important;
}

/* "Previous" / "Next" label text */
footer .text-gray-400 {
    color: var(--ph-text-muted) !important;
}

footer .group:hover .text-gray-400 {
    color: var(--ph-accent-hover) !important;
}

/* Thin dividers */
footer .bg-gray-300 {
    background-color: var(--ph-border) !important;
}

/* Copyright and info links */
footer .text-gray-500 {
    color: var(--ph-text-muted) !important;
}

footer a:hover .text-gray-500,
footer a:hover.text-gray-500 {
    color: var(--ph-text-secondary) !important;
}

/* "Made with" link */
footer .text-gray-700 {
    color: var(--ph-text-secondary) !important;
}

footer a:hover .text-gray-700,
footer a:hover.text-gray-700 {
    color: var(--ph-text-primary) !important;
}

/* Inline hover classes */
footer .hover\:text-gray-900:hover {
    color: var(--ph-text-secondary) !important;
}

footer .hover\:text-black:hover {
    color: var(--ph-text-primary) !important;
}

footer svg {
    color: inherit;
}

/* ===== GLOBAL SCROLLBAR & SELECTION ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--ph-bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--ph-bg-tertiary);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4a5568;
}

::selection {
    background-color: var(--ph-accent-subtle);
    color: var(--ph-text-primary);
}