/* ============ PDF Panel ============ */
#pdf-panel {
    display: none;
}

#tree-container.split-layout #pdf-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0d1117;
    border-left: 2px solid #30363d;
}

#pdf-header {
    padding: 10px 15px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    font-size: 14px;
    color: #8b949e;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#pdf-content {
    flex: 1;
    overflow: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#pdf-canvas {
    max-width: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#pdf-page-container {
    position: relative;
    display: inline-block;
}

#pdf-placeholder {
    color: #8b949e;
    text-align: center;
    padding: 40px 20px;
}

/* PDF Text Layer */
#pdf-text-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    line-height: 1.0;
}

#pdf-text-layer > span {
    color: transparent !important;
    position: absolute;
    white-space: pre;
    transform-origin: 0% 0%;
}

#pdf-text-layer .highlight {
    background-color: rgba(255, 215, 0, 0.5);
    color: transparent !important;
    border-radius: 3px;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.9);
    animation: highlightPulse 1.5s ease-in-out infinite;
}

#pdf-text-layer ::selection {
    background: rgba(0, 0, 255, 0.3);
}

@keyframes highlightPulse {
    0%, 100% {
        background-color: rgba(255, 215, 0, 0.5);
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.9);
    }
    50% {
        background-color: rgba(255, 235, 59, 0.7);
        box-shadow: 0 0 20px rgba(255, 235, 59, 1);
    }
}

/* PDF Navigation */
#pdf-nav {
    padding: 10px;
    background: #161b22;
    border-top: 1px solid #30363d;
    display: flex;
    justify-content: center;
    gap: 10px;
}

#pdf-nav button {
    padding: 6px 15px;
    background: #238636;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
}

#pdf-nav button:hover {
    background: #2ea043;
}

#pdf-nav button:disabled {
    background: #4a5568;
    cursor: not-allowed;
}

/* ============ PDF Toggle Button ============ */
#pdf-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #238636;
    border: none;
    cursor: pointer;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: background 0.2s, transform 0.2s;
}

#pdf-toggle-btn:hover {
    background: #2ea043;
    transform: scale(1.05);
}

#pdf-toggle-btn::before {
    content: '📄';
}

#pdf-toggle-btn.expanded::before {
    content: '✕';
}

/* ============ Mobile Responsive (≤768px) ============ */
@media (max-width: 768px) {
    /* Hide the old toggle button on mobile - now in menu */
    #pdf-toggle-btn {
        display: none !important;
    }

    /* PDF panel becomes full screen overlay on mobile */
    #tree-container.split-layout #pdf-panel {
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        height: 100%;
        z-index: 90;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        border-left: none;
    }

    #tree-container.split-layout.pdf-expanded #pdf-panel {
        transform: translateX(0);
    }

    /* Tree view takes full width on mobile */
    #tree-container.split-layout #tree-view {
        flex: 1;
        width: 100%;
    }

    /* Hide desktop controls on mobile */
    #controls {
        display: none !important;
    }

    /* Hide legend on mobile */
    #legend {
        display: none !important;
    }

    /* Hide info on mobile */
    #info {
        display: none !important;
    }

    /* Mobile menu button */
    #mobile-menu-btn {
        position: fixed;
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        background: rgba(22, 33, 62, 0.95);
        border: 1px solid #30363d;
        color: white;
        font-size: 20px;
        cursor: pointer;
        z-index: 100;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    #mobile-menu-btn:hover {
        background: rgba(35, 50, 90, 0.95);
    }

    /* Mobile menu dropdown */
    #mobile-menu {
        position: fixed;
        top: 55px;
        right: 10px;
        background: rgba(22, 33, 62, 0.95);
        border: 1px solid #30363d;
        border-radius: 8px;
        padding: 8px;
        z-index: 100;
        display: none;
        flex-direction: column;
        gap: 5px;
    }

    #mobile-menu.open {
        display: flex !important;
    }

    #mobile-menu button {
        padding: 8px 12px;
        background: #4299e1;
        color: white;
        border: none;
        border-radius: 5px;
        cursor: pointer;
        font-size: 13px;
        white-space: nowrap;
        text-align: left;
    }

    #mobile-menu button:hover {
        background: #3182ce;
    }

    #mobile-menu #mobile-pdf-toggle {
        background: #238636;
    }

    #mobile-menu #mobile-pdf-toggle:hover {
        background: #2ea043;
    }
}
