/* Clean, Simple Navigation - Two-Tier Structure */

/* Custom Header Bar - Match Left Nav */
.md-header {
    background: #ffffff !important;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.md-header__title {
    font-weight: 600;
    color: #111827;
}

.md-header__button {
    color: #111827 !important;
}

/* Hide default left sidebar - we'll create custom */
.md-sidebar--primary {
    display: none;
}

/* Hide right TOC */
.md-sidebar--secondary {
    display: none !important;
}

/* Hide in-page TOC */
.md-content__inner>.md-typeset>.md-nav--secondary {
    display: none !important;
}

/* Full width content */
.md-content {
    max-width: 100% !important;
    margin: 0 auto;
}

/* Custom Left Navigation */
.custom-nav {
    position: fixed;
    left: 0;
    top: 0;
    width: 270px;
    height: 100vh;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    z-index: 100;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.nav-brand-header {
    padding: 1.5rem 1.5rem 1.25rem 1.5rem;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 0.75rem;
}

.nav-brand-header img {
    height: 60px;
    /* Increased to 60px */
    width: auto;
    display: block;
}

.custom-nav-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 2rem;
}

.custom-nav h3 {
    padding: 0 1.5rem;
    margin: 1.5rem 0 1rem 0;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #9ca3af;
    letter-spacing: 0.08em;
}

.custom-nav h3:first-child {
    margin-top: 0;
}

.custom-nav-section {
    margin-bottom: 0.5rem;
}

/* Overview Items (Always Visible) */
.custom-nav-item {
    padding: 0.7rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    color: #374151;
    font-size: 0.875rem;
    border-left: 3px solid transparent;
}

.custom-nav-item:hover {
    background: #f9fafb;
    color: #2563eb;
}

.custom-nav-item.active {
    background: #eff6ff;
    color: #2563eb;
    border-left-color: #2563eb;
    font-weight: 500;
}

/* Module Headers (Collapsible) */
.custom-nav-module {
    margin: 0.3rem 0;
}

.custom-nav-module-header {
    padding: 0.7rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    color: #111827;
    font-size: 0.875rem;
    font-weight: 600;
    border-left: 3px solid transparent;
    position: relative;
}

.custom-nav-module-header:hover {
    background: #f3f4f6;
    color: #2563eb;
}

.module-arrow {
    margin-left: auto;
    font-size: 0.7rem;
    color: #9ca3af;
    transition: transform 0.2s;
}

.custom-nav-module.expanded .module-arrow {
    transform: rotate(90deg);
}

.custom-nav-module.expanded>.custom-nav-module-header {
    background: #f9fafb;
    color: #2563eb;
    border-left-color: #2563eb;
}

/* Module Content (Collapsible) */
.custom-nav-module-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.custom-nav-module.expanded>.custom-nav-module-content {
    max-height: 500px;
}

/* Subitems */
.custom-nav-subitem {
    padding: 0.5rem 1.5rem 0.5rem 3rem;
    cursor: pointer;
    transition: all 0.15s;
    color: #6b7280;
    font-size: 0.8rem;
}

.custom-nav-subitem:hover {
    background: #f9fafb;
    color: #2563eb;
}

.custom-nav-subitem.active {
    background: #eff6ff;
    color: #2563eb;
    font-weight: 500;
}

/* Icons */
.custom-nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.6;
}

.custom-nav-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.custom-nav-item.active .custom-nav-icon,
.custom-nav-module.expanded .custom-nav-icon {
    opacity: 1;
}

/* Shift content for custom nav */
.md-main {
    margin-left: 270px;
}

.nav-branding-footer {
    padding: 1.25rem 1.5rem;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    font-family: inherit;
}

.branding-logo img {
    height: 45px;
    /* Increased to 45px */
    margin-bottom: 0.75rem;
    opacity: 0.95;
}

.branding-role {
    font-size: 0.75rem;
    color: #4b5563;
    margin: 0 0 0.75rem 0 !important;
    line-height: 1.4;
    font-weight: 500;
}

.branding-desc {
    font-size: 0.7rem;
    color: #4b5563;
    line-height: 1.5;
    margin: 0.75rem 0 1.25rem 0 !important;
    font-style: italic;
    display: none;
    /* Hidden by default, toggled via About */
    padding: 0.75rem;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.branding-desc.visible {
    display: block;
}

.about-toggle {
    font-size: 0.7rem;
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.about-toggle:hover {
    text-decoration: underline;
}

.branding-links {
    display: flex;
    gap: 1.2rem;
}

.branding-links a {
    font-size: 0.7rem;
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
}

.branding-links a:hover {
    text-decoration: underline;
}

/* Downloads Widget - Right Side Initial styles merged below */

/* Reading Progress Bar */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 2px;
    background: #2563eb;
    z-index: 9999;
    transition: width 0.1s ease;
}

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    background: #2563eb;
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
    font-size: 1.2rem;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
}

/* Modern Floating Widgets Base Styles */
.downloads-widget,
.keywords-widget {
    position: fixed;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    z-index: 95;
    transition: box-shadow 0.2s, height 0.3s ease, width 0.3s ease, transform 0.2s;
    overflow: hidden;
    width: 280px;
    /* Increased width to prevent truncation */
}

.downloads-widget {
    right: 2rem;
    top: 100px;
}

.keywords-widget {
    right: 2rem;
    top: 320px;
    /* Positioned below downloads by default */
    max-height: calc(100vh - 400px);
    display: flex;
    flex-direction: column;
}

.downloads-widget h3,
.keywords-widget h3 {
    margin: 0 0 1rem 0;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #374151;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
}

/* Downloads specific links */
.downloads-widget a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-decoration: none;
    color: #475569;
    font-size: 0.8rem;
    transition: all 0.15s ease;
}

.downloads-widget a:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #2563eb;
    transform: translateX(4px);
}

.downloads-widget a svg {
    width: 18px;
    height: 18px;
    color: #64748b;
}

.downloads-widget a:hover svg {
    color: #2563eb;
}

.keywords-widget.collapsed,
.downloads-widget.collapsed {
    width: auto !important;
    min-width: 140px;
    height: 40px !important;
    padding: 0 1rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    overflow: hidden;
    border-radius: 20px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
}

.keywords-widget.collapsed .keyword-search-wrapper,
.keywords-widget.collapsed .keywords-container,
.downloads-widget.collapsed a {
    display: none !important;
}

.keywords-widget.collapsed h3,
.downloads-widget.collapsed h3 {
    margin: 0 !important;
    font-size: 0.7rem;
    white-space: nowrap;
}

.widget-controls {
    display: flex;
    gap: 6px;
    margin-left: auto;
    align-items: center;
}

.control-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 8px;
    color: transparent;
    transition: all 0.2s;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.control-btn:hover {
    color: rgba(255, 255, 255, 0.8);
}

.btn-min {
    background: #ffbd2e;
}

.btn-max {
    background: #28c940;
}

.btn-close {
    background: #ff5f56;
}

.widget-controls:hover .control-btn {
    color: rgba(0, 0, 0, 0.5);
}

.keywords-widget.hidden,
.downloads-widget.hidden {
    display: none !important;
}

.restore-widgets-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #2563eb;
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    cursor: pointer;
    z-index: 1000;
    display: none;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.restore-widgets-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.restore-widgets-btn.visible {
    display: flex;
}

.downloads-widget.dragging,
.keywords-widget.dragging {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    cursor: grabbing !important;
    opacity: 0.9;
}

.drag-handle {
    cursor: grab;
    padding: 0.5rem;
    margin: -1.25rem -1.25rem 0.5rem -1.25rem;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: flex-end;
    color: #9ca3af;
}

.drag-handle:hover {
    background: #f9fafb;
    color: #6b7280;
}

.drag-handle svg {
    width: 14px;
    height: 14px;
}

.keywords-widget h3 {
    margin: 0 0 0.75rem 0;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #374151;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
}

.keyword-search-wrapper {
    margin-bottom: 1rem;
    position: relative;
}

.keyword-search-input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    font-size: 0.8rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f9fafb;
    outline: none;
    transition: all 0.2s ease;
}

.keyword-search-input:focus {
    border-color: #2563eb;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.keyword-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
}

.keywords-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Custom Scrollbar for Widget */
.keywords-container::-webkit-scrollbar {
    width: 4px;
}

.keywords-container::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 10px;
}

.keyword-tag {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    background: #f3f4f6;
    color: #4b5563;
    border-radius: 4px;
    font-weight: 500;
    white-space: normal;
    word-break: break-word;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.keyword-tag:hover {
    background: #e5e7eb;
    color: #111827;
}

/* Smooth Scroll */
html {
    scroll-behavior: smooth;
}

/* Custom Nav Scrollbar */
.custom-nav::-webkit-scrollbar {
    width: 6px;
}

.custom-nav::-webkit-scrollbar-track {
    background: transparent;
}

.custom-nav::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 3px;
}