/* ================================================
   MODERN SIDEBAR NAVIGATION - VUE 2 COMPONENT
   ================================================

   Component: resources/js/components/SidebarNav.vue
   CSS: public/css/sidebar-nav.css
   Data: public/js/data/sidebar-nav.json
   ================================================ */

/* ==========================================
   BACKDROP OVERLAY (Mobile)
   ========================================== */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1045;
    backdrop-filter: blur(2px);
}

@media (min-width: 992px) {
    .sidebar-backdrop {
        display: none !important;
    }
}

/* ==========================================
   TAB GROUP - Two stacked tabs on left edge
   ========================================== */
@keyframes sidebarFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.sidebar-tab-group {
    animation: sidebarFadeIn 0.3s ease;
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.sidebar-tab {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    z-index: auto;
    cursor: pointer;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    background: linear-gradient(135deg, #3498db 0%, #217dbb 100%);
    color: #fff;
    padding: 24px 12px;
    border: none;
    border-radius: 0 14px 14px 0;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 2px;
    box-shadow: 3px 3px 16px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.sidebar-tab:hover {
    padding: 28px 14px;
    box-shadow: 3px 3px 20px rgba(0, 0, 0, 0.3);
}

.sidebar-tab--contents:hover {
    background: linear-gradient(135deg, #217dbb 0%, #1a5f8f 100%);
}

.sidebar-tab--index {
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
}

.sidebar-tab--index:hover {
    background: linear-gradient(135deg, #1a252f 0%, #0f171e 100%);
}

/* When panel is open, snap tabs to panel edge (no transition = no glitch) */
.sidebar-tab-group--open {
    left: 380px;
    z-index: 1055;
}

/* Active tab state - visually connected to the panel */
.sidebar-tab--active.sidebar-tab--contents {
    background: linear-gradient(135deg, #217dbb 0%, #1a5f8f 100%);
    box-shadow: 3px 3px 20px rgba(0, 0, 0, 0.3);
}

.sidebar-tab--active.sidebar-tab--index {
    background: linear-gradient(135deg, #1a252f 0%, #0f171e 100%);
    box-shadow: 3px 3px 20px rgba(0, 0, 0, 0.3);
}

.sidebar-tab-text {
    pointer-events: none;
}

/* ==========================================
   SLIDE-OUT PANEL
   ========================================== */
.sidebar-panel {
    position: fixed;
    left: 0;
    width: 380px;
    height: calc(100vh - 40px);
    top: 20px;
    background: #fff;
    z-index: 1050;
    box-shadow: 6px 0 30px rgba(0, 0, 0, 0.15);
    border-radius: 0 18px 18px 0;
    display: flex;
    flex-direction: column;
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================
   PANEL HEADER
   ========================================== */
.sidebar-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 28px 18px;
    border-bottom: 2px solid #0072c5;
    flex-shrink: 0;
}

.sidebar-panel-header--blue {
    background: linear-gradient(135deg, #3498db 0%, #217dbb 100%);
    border-bottom: 2px solid #217dbb;
    border-radius: 0 18px 0 0;
}

.sidebar-panel-header--dark {
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
    border-bottom: 2px solid #1a252f;
    border-radius: 0 18px 0 0;
}

.sidebar-panel-header--blue .sidebar-panel-title,
.sidebar-panel-header--dark .sidebar-panel-title {
    color: #fff;
}

.sidebar-panel-header--blue .sidebar-close-btn,
.sidebar-panel-header--dark .sidebar-close-btn {
    color: rgba(255, 255, 255, 0.7);
}

.sidebar-panel-header--blue .sidebar-close-btn:hover,
.sidebar-panel-header--dark .sidebar-close-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

.sidebar-panel-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: #000;
}

.sidebar-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: red;
    line-height: 0;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.sidebar-close-btn svg {
    stroke-width: 3;
}

.sidebar-close-btn:hover {
    color: #333;
    background: #e8f4f8;
    transform: rotate(90deg);
}

/* ==========================================
   MODE TOGGLE BUTTONS (CONTENTS / INDEX)
   ========================================== */
.sidebar-mode-btns {
    display: flex;
    gap: 6px;
    padding: 12px 20px 0;
    flex-shrink: 0;
}

.sidebar-mode-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    border: 2px solid #e0e4ea;
    background: #f5f7fa;
    color: #666;
    transition: all 0.2s ease;
}

.sidebar-mode-btn:hover {
    background: #e8ecf1;
}

.sidebar-mode-btn.active {
    background: #2c3e50;
    color: #fff;
    border-color: #2c3e50;
}

/* ==========================================
   FILTER BUTTONS (3D / AR)
   ========================================== */
.sidebar-filter-btns {
    display: flex;
    gap: 8px;
    padding: 14px 20px 0;
    flex-shrink: 0;
}

.sidebar-filter-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 10px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    color: #666;
    background: #f5f7fa;
}

.sidebar-filter-btn:hover {
    background: #e8ecf1;
    transform: translateY(-1px);
}

.sidebar-filter-3d.active {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: #fff;
    border-color: #4CAF50;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.sidebar-filter-ar.active {
    background: linear-gradient(135deg, #3498db 0%, #217dbb 100%);
    color: #fff;
    border-color: #3498db;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

/* ==========================================
   APPS BUTTON
   ========================================== */
.sidebar-apps-btn-wrap {
    display: flex;
    justify-content: center;
    padding: 10px 20px 0;
    flex-shrink: 0;
}

.sidebar-apps-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 32px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-decoration: none;
    color: #fff;
    background: linear-gradient(135deg, #ff9500 0%, #ff8000 100%);
    border: 2px solid transparent;
    box-shadow: 0 4px 12px rgba(255, 149, 0, 0.3);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-apps-btn:hover {
    background: linear-gradient(135deg, #ff8000 0%, #e67300 100%);
    box-shadow: 0 6px 16px rgba(255, 149, 0, 0.4);
    transform: translateY(-2px);
    text-decoration: none;
}

/* ==========================================
   SEARCH BAR
   ========================================== */
.sidebar-search-wrap {
    padding: 12px 20px 0;
    flex-shrink: 0;
    position: relative;
}

.sidebar-search-box {
    display: flex;
    align-items: center;
    background: #f5f7fa;
    border: 1.5px solid #e0e4ea;
    border-radius: 10px;
    padding: 0 12px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.sidebar-search-box:focus-within {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(0, 114, 197, 0.1);
}

.sidebar-search-icon {
    flex-shrink: 0;
}

.sidebar-search-input {
    flex: 1;
    border: none;
    background: none;
    padding: 10px 8px;
    font-size: 14px;
    color: #333;
    outline: none;
}

.sidebar-search-input::placeholder {
    color: #aaa;
}

.sidebar-search-clear {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #999;
    line-height: 0;
    border-radius: 50%;
    transition: background 0.15s;
}

.sidebar-search-clear:hover {
    background: #e0e4ea;
    color: #555;
}

/* Search results dropdown */
.sidebar-search-results {
    position: absolute;
    left: 20px;
    right: 20px;
    top: 100%;
    background: #fff;
    border: 1.5px solid #e0e4ea;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 320px;
    overflow-y: auto;
    z-index: 10;
    margin-top: 4px;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.sidebar-search-results::-webkit-scrollbar {
    width: 5px;
}

.sidebar-search-results::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.sidebar-search-result-item {
    display: block;
    padding: 10px 16px;
    font-size: 14px;
    color: #333;
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.1s;
}

.sidebar-search-result-item:last-child {
    border-bottom: none;
}

.sidebar-search-result-item:hover {
    background: #e8f4f8;
    color: #3498db;
    text-decoration: none;
}

.sidebar-search-result-item mark {
    background: #fff3cd;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

.sidebar-search-section {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #999;
    text-transform: uppercase;
    display: block;
    margin-top: 2px;
}

.sidebar-search-empty {
    padding: 16px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* ==========================================
   SCROLLABLE AREA
   ========================================== */
.sidebar-panel-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    padding: 12px 0 24px;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.sidebar-panel-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidebar-panel-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-panel-scroll::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* ==========================================
   SECTIONS (OSTEOLOGY, HEART ANATOMY)
   ========================================== */
.sidebar-section {
    margin-bottom: 4px;
}

.sidebar-section-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px 28px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #222;
    text-align: left;
    transition: background 0.15s;
}

.sidebar-section-toggle:hover {
    background: #f5f7fa;
}

/* ==========================================
   SUBCATEGORIES (Cranium, Thorax, etc.)
   ========================================== */
.sidebar-subcategory {
    margin-bottom: 2px;
}

.sidebar-subcat-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 8px 28px 8px 44px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #444;
    text-align: left;
    transition: background 0.15s;
}

.sidebar-subcat-toggle:hover {
    background: #f5f7fa;
}

/* ==========================================
   PAGE LINKS
   ========================================== */
.sidebar-links {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-links a {
    display: block;
    padding: 7px 28px 7px 62px;
    font-size: 15px;
    color: #444;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    line-height: 1.4;
}

.sidebar-links a:hover {
    background: #eef4fb;
    color: #0072c5;
    text-decoration: none;
}

.sidebar-links a.sidebar-active {
    background: linear-gradient(135deg, #3498db 0%, #217dbb 100%);
    color: #fff;
    font-weight: 600;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

/* ==========================================
   CHEVRON ROTATION (Alpine.js handles this)
   ========================================== */
.sidebar-chevron,
.sidebar-chevron-sm {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.rotate-90 {
    transform: rotate(90deg);
}

/* ==========================================
   INDEX MODE - Alphabetical Letter Groups
   ========================================== */
.sidebar-index-letter {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px 28px;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #2c3e50;
    background: #f0f2f5;
    border-bottom: 1px solid #e0e4ea;
}

.sidebar-index-link {
    display: block;
    padding: 8px 28px 8px 44px;
    font-size: 14px;
    color: #333;
    text-decoration: none;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.15s, color 0.15s;
    line-height: 1.4;
}

.sidebar-index-link:hover {
    background: #eef4fb;
    color: #0072c5;
    text-decoration: none;
}

.sidebar-index-page {
    display: block;
    font-size: 11px;
    color: #999;
    margin-top: 1px;
}

.sidebar-index-empty {
    padding: 40px 28px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* ==========================================
   SCROLL MARGIN for anchor targets
   ========================================== */
h4[id] {
    scroll-margin-top: 80px;
}

/* ==========================================
   TAB HIDE TOGGLE (hidden on desktop)
   ========================================== */
.sidebar-tab-hide {
    display: none;
}

/* ==========================================
   RESPONSIVE (Mobile)
   ========================================== */
@media (max-width: 991px) {
    .sidebar-tab-group {
        gap: 4px;
        top: auto;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 60px);
        transform: none;
    }

    .sidebar-tab {
        border-radius: 0 10px 10px 0;
        letter-spacing: 1.5px;
        padding: 20px 12px;
        font-size: 13px;
    }

    .sidebar-tab:hover {
        padding: 22px 13px;
    }

    .sidebar-panel {
        display: flex;
        width: calc(100vw - 50px);
        max-width: 360px;
        height: 100vh;
        top: 0;
        border-radius: 0 16px 16px 0;
    }

    .sidebar-panel-header {
        padding: 18px 20px 14px;
    }

    .sidebar-panel-header--blue,
    .sidebar-panel-header--dark {
        border-radius: 0 16px 0 0;
    }

    .sidebar-panel-title {
        font-size: 16px;
    }

    .sidebar-section-toggle {
        padding: 11px 20px;
        font-size: 15px;
    }

    .sidebar-subcat-toggle {
        padding: 8px 20px 8px 36px;
        font-size: 14px;
    }

    .sidebar-links a {
        padding: 8px 20px 8px 50px;
        font-size: 14px;
    }

    .sidebar-filter-btns {
        padding: 10px 16px 0;
        gap: 6px;
    }

    .sidebar-filter-btn {
        padding: 10px 8px;
        font-size: 13px;
    }

    .sidebar-search-wrap {
        padding: 10px 16px 0;
    }

    .sidebar-search-input {
        font-size: 16px;  /* 16px prevents iOS Safari auto-zoom on focus */
        padding: 9px 8px;
    }

    .sidebar-search-results {
        left: 16px;
        right: 16px;
    }

    .sidebar-tab-group--open {
        left: min(calc(100vw - 50px), 360px);
        z-index: 1055;
    }

    .sidebar-index-letter {
        padding: 8px 20px;
    }

    .sidebar-index-link {
        padding: 8px 20px 8px 36px;
        font-size: 13px;
    }

    /* --- Tab hide/show toggle (mobile only) --- */
    .sidebar-tab-hide {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        margin-top: 12px;
        border-radius: 0 10px 10px 0;
        background: rgba(44, 62, 80, 0.65);
        border: none;
        cursor: pointer;
        color: rgba(255, 255, 255, 0.8);
        padding: 0;
        transition: background 0.2s;
    }

    .sidebar-tab-hide:active {
        background: rgba(44, 62, 80, 0.9);
    }

    /* When hidden: slide most of the tab group off-screen, leave a sliver visible */
    .sidebar-tab-group--hidden {
        transform: translateX(calc(-100% + 8px));
        transition: transform 0.3s ease;
    }

    /* Keep the hide button visible at the screen edge */
    .sidebar-tab-group--hidden .sidebar-tab-hide {
        transform: translateX(calc(100% - 8px));
    }

    /* Smooth slide-back when un-hiding */
    .sidebar-tab-group:not(.sidebar-tab-group--hidden):not(.sidebar-tab-group--open) {
        transition: transform 0.3s ease;
    }
}
