/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');

/* ------------------ Base ------------------ */
body {
    background-color: #ffffff !important;
}

.md-content li,
.md-content ul,
.md-content ol {
    font-size: 1.15rem;
    line-height: 1.8;
}

.md-main {
    background-color: #ffffff !important;
    box-shadow: none !important;
}

body, .md-main, .md-sidebar--primary, .md-header, .md-content {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
        Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    color: #1a2636;
    line-height: 1.6;
}

/* ------------------ Top bar ------------------ */
.md-header {
    position: sticky;
    top: 0;
    z-index: 999;
    height: 64px !important;
    background: linear-gradient(135deg, #1e3a5f, #2d5986);
    color: white;
    font-weight: 600;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    padding: 0 2rem !important;
    box-shadow: 0 2px 12px rgba(30, 58, 95, 0.25);
}

.md-header__inner {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap;
    width: 100%;
}

.md-header__title {
    display: block !important;
    visibility: visible !important;
    font-weight: 700;
    font-size: 1.2rem;
    color: #e8f4fd;
    order: 1;
    flex-shrink: 0;
}

.md-header__button.md-logo {
    display: none !important;
}

/* ------------------ Search Bar ------------------ */
.md-search {
    order: 2;
    margin-left: auto !important;
    margin-right: 0 !important;
}

.md-search__form {
    background-color: rgba(232, 244, 253, 0.15);
    border-radius: 8px;
    border: 1px solid rgba(232, 244, 253, 0.3);
    transition: all 0.3s ease;
}

.md-search__form:hover {
    background-color: rgba(232, 244, 253, 0.22);
    border-color: rgba(232, 244, 253, 0.5);
    box-shadow: 0 0 0 3px rgba(232, 244, 253, 0.1);
}

.md-search__form:focus-within {
    background-color: #ffffff;
    border-color: #4a90d9;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.2);
}

.md-search__input {
    background-color: transparent;
    color: #e8f4fd;
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
}

.md-search__input::placeholder {
    color: rgba(232, 244, 253, 0.6);
    font-weight: 400;
}

.md-search__form:focus-within .md-search__input {
    color: #1a2636;
}

.md-search__form:focus-within .md-search__input::placeholder {
    color: rgba(26, 38, 54, 0.4);
}

.md-search__icon {
    color: rgba(232, 244, 253, 0.8);
}

.md-search__form:focus-within .md-search__icon {
    color: #4a90d9;
}

.md-search__output {
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(30, 58, 95, 0.15);
    margin-top: 0.5rem;
    border: 1px solid #d0e8f7;
}

.md-search-result__item {
    border-bottom: 1px solid #eaf4fb;
    transition: background-color 0.2s ease;
}

.md-search-result__item:hover {
    background-color: #f0f8ff;
}

.md-search-result__link {
    color: #1a2636;
}

.md-search-result__link:hover {
    color: #1e3a5f;
}

.md-search-result__title {
    font-weight: 600;
    color: #1e3a5f;
}

/* ------------------ Navbar social icons ------------------ */
.md-header__social {
    order: 3;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: 1rem !important;
    margin-right: 0.25rem;
    flex-shrink: 0;
}

.md-header__social a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(232, 244, 253, 0.12);
    border: 1px solid rgba(232, 244, 253, 0.25);
    transition: all 0.2s ease;
    text-decoration: none;
}

.md-header__social a:hover {
    background: rgba(232, 244, 253, 0.25);
    border-color: rgba(232, 244, 253, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

.md-header__social a svg {
    width: 16px;
    height: 16px;
    fill: #e8f4fd;
}

/* ------------------ Hide sidebar header ------------------ */
.md-sidebar__scrollwrap > .md-sidebar__inner > .md-nav--primary > .md-nav__title {
    display: none !important;
}

.md-sidebar-header {
    display: none !important;
}

.md-sidebar .md-logo {
    display: none !important;
}

/* ------------------ Sidebar ------------------ */
.md-sidebar--primary {
    position: fixed;
    top: 64px !important;
    left: 0;
    width: var(--sidebar-width, 260px);
    height: calc(100vh - 64px) !important;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f0f6fc;
    border-right: 1px solid #c8dff0;
    box-shadow: 2px 0 8px rgba(30, 58, 95, 0.08);
    padding: 1.5rem 0.5rem;
    min-width: 160px;
    max-width: 500px;
}

.md-sidebar--primary::-webkit-scrollbar { width: 4px; }
.md-sidebar--primary::-webkit-scrollbar-track { background: transparent; }
.md-sidebar--primary::-webkit-scrollbar-thumb {
    background: rgba(74, 144, 217, 0.3);
    border-radius: 3px;
}
.md-sidebar--primary::-webkit-scrollbar-thumb:hover {
    background: rgba(74, 144, 217, 0.55);
}

.md-sidebar--primary .md-sidebar__scrollwrap,
.md-sidebar--primary .md-sidebar__inner,
.md-sidebar--primary .md-nav--primary {
    width: 100% !important;
    max-width: 100% !important;
}

/* ------------------ Resize handle ------------------ */
.sidebar-resize-handle {
    position: fixed;
    top: 64px !important;
    left: var(--sidebar-width, 260px);
    width: 6px;
    height: calc(100vh - 64px) !important;
    cursor: col-resize;
    z-index: 1001;
    background: transparent;
    transition: background 0.2s ease;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
    background: rgba(74, 144, 217, 0.45);
}

/* ------------------ Nav items ------------------ */
.md-nav--primary { padding: 0; }

.md-nav__list { padding: 0; margin: 0; width: 100%; }

.md-nav__item { margin-bottom: 0.25rem; width: 100%; }

.md-nav__item--nested { margin-bottom: 0.25rem; width: 100%; }

.md-nav__item--nested > .md-nav__link {
    font-weight: 600;
    color: #1e3a5f;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    margin: 0;
    transition: all 0.2s ease;
    white-space: normal;
    overflow: visible;
    word-break: break-word;
    width: 100%;
    box-sizing: border-box;
}

.md-nav__item--nested > .md-nav__link:hover {
    background-color: rgba(74, 144, 217, 0.12);
    color: #1253a4;
}

.md-nav__toggle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.md-nav__icon {
    color: rgba(74, 144, 217, 0.6);
    transition: transform 0.25s ease, color 0.25s ease;
    width: 1rem;
    height: 1rem;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.md-nav__toggle:checked ~ .md-nav__link .md-nav__icon {
    transform: rotate(180deg);
}

.md-nav--secondary { padding-left: 0; margin-top: 0.25rem; width: 100%; }
.md-nav--secondary .md-nav__list { padding-left: 0; width: 100%; }
.md-nav--secondary .md-nav__item { margin-bottom: 0.15rem; width: 100%; }

.md-nav--secondary .md-nav__link {
    padding: 0.45rem 0.75rem 0.45rem 1.5rem;
    color: #3a6186;
    border-radius: 8px;
    margin: 0;
    transition: all 0.2s ease;
    display: block;
    white-space: normal;
    overflow: visible;
    word-break: break-word;
    width: 100%;
    box-sizing: border-box;
}

.md-nav--secondary .md-nav__link:hover {
    background-color: rgba(74, 144, 217, 0.1);
    color: #1253a4;
}

.md-nav__link {
    font-weight: 500;
    color: #2c5282;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    margin: 0;
    transition: all 0.2s ease;
    display: block;
    white-space: normal;
    overflow: visible;
    word-break: break-word;
    width: 100%;
    box-sizing: border-box;
}

.md-nav__link:hover {
    background-color: rgba(74, 144, 217, 0.1);
    color: #1253a4;
}

.md-nav__link:focus {
    background-color: rgba(74, 144, 217, 0.15);
    color: #1253a4;
    outline: none;
}

.md-nav__link--active {
    background: linear-gradient(135deg, #1e3a5f, #2d6aa0);
    color: #ffffff !important;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.2);
}

.md-nav__link--active:hover {
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

.md-nav--secondary .md-nav__link--active {
    background: linear-gradient(135deg, #1e3a5f, #2d6aa0);
    color: #ffffff !important;
    font-weight: 600;
}

.md-nav__title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(74, 144, 217, 0.5);
    font-weight: 700;
    padding: 0.5rem 0.75rem 0.3rem 0.75rem;
    margin-top: 1rem;
}

/* ------------------ Main content ------------------ */
.md-main {
    margin-left: var(--sidebar-width, 260px);
    overflow: auto;
    padding: 2rem 3rem;
    background-color: #ffffff;
    color: #1a2636;
}

.md-content { margin: 0; padding: 0; max-width: none; }

.md-content img {
    display: block;
    width: auto;
    height: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    box-shadow: none;
}

.md-content h1,
.md-content h2,
.md-content h3 {
    margin: 1.2rem 0 0.6rem 0;
    font-weight: 700;
    color: #1e3a5f;
}

.md-content p {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    line-height: 1.8;
    color: #1a2636;
}

/* ------------------ Footer ------------------ */
.md-custom-footer {
    margin-left: var(--sidebar-width, 260px);
    padding: 1rem 3rem;
    background: #f0f6fc;
    color: #4a7fa8;
    font-size: 0.85rem;
    text-align: center;
    border-top: 1px solid #c8dff0;
    letter-spacing: 0.03em;
}

/* ------------------ Zoom Controls ------------------ */
.md-zoom-controls {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
}

.md-zoom-controls button {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #1e3a5f, #2d6aa0);
    color: #e8f4fd;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.md-zoom-controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(30, 58, 95, 0.35);
}

.md-zoom-controls button:active {
    transform: scale(0.95);
}

.md-content-zoom {
    transform-origin: top left;
    transition: transform 0.15s ease-in-out;
    width: fit-content;
}

.md-sidebar--secondary {
    display: none !important;
}

.md-content__inner {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* ------------------ Mobile / Responsive Fix ------------------ */
@media screen and (max-width: 76.1875em) {
    .md-main {
        margin-left: 0 !important;
        padding: 1.5rem 1.25rem !important;
    }

    .md-custom-footer {
        margin-left: 0 !important;
        padding: 1rem 1.25rem !important;
    }

    .sidebar-resize-handle {
        display: none !important;
    }

    .md-sidebar--primary {
        top: 0 !important;
        height: 100vh !important;
    }
}

@media screen and (max-width: 600px) {
    .md-main {
        margin-left: 0 !important;
        padding: 1rem 0.75rem !important;
    }

    .md-custom-footer {
        margin-left: 0 !important;
        padding: 0.75rem !important;
    }

    .md-header {
        padding: 0 1rem !important;
    }

    .md-header__social {
        gap: 0.4rem;
        margin-left: 0.5rem !important;
    }

    .md-zoom-controls {
        bottom: 1rem;
        right: 0.75rem;
    }

    .md-zoom-controls button {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .md-content p {
        font-size: 1rem;
    }

    .md-content li,
    .md-content ul,
    .md-content ol {
        font-size: 1rem;
    }
}