/*
 * Enhanced Travel Blog TOC — External Stylesheet
 * Deduplicated: shared rules for desktop (.custom-blog-toc) and mobile (.mobile-toc-body)
 * Save as: /wp-content/plugins/enhanced-travel-blog-toc/toc-styles.css
 */

/* ============================================
   SHARED TOC STYLES (desktop + mobile)
   ============================================ */

.custom-blog-toc,
.mobile-toc-body {
    overflow: visible;
}

.custom-blog-toc .toc-list,
.mobile-toc-body .toc-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
    overflow: visible;
}

.custom-blog-toc .toc-item,
.mobile-toc-body .toc-item {
    position: relative;
    overflow: visible;
}

.custom-blog-toc .toc-item.has-open-dropdown,
.mobile-toc-body .toc-item.has-open-dropdown {
    z-index: 30;
}

.custom-blog-toc .toc-main-link,
.mobile-toc-body .toc-main-link {
    display: flex;
    align-items: center;
    background: #f8fafc;
    transition: all .3s ease;
    border-radius: 10px;
    text-decoration: none;
    color: #2d3748;
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: -1px;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    font-family: "Geologica", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.custom-blog-toc .toc-item.has-open-dropdown .toc-main-link,
.mobile-toc-body .toc-item.has-open-dropdown .toc-main-link {
    border-radius: 10px 10px 0 0;
}

.custom-blog-toc .toc-main-link:hover,
.mobile-toc-body .toc-main-link:hover {
    background: #EBF8FF;
    color: #1a202c;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,.15);
}

.custom-blog-toc .toc-toggle-btn,
.mobile-toc-body .toc-toggle-btn {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #e2e8f0;
    border-radius: 8px;
    transition: all .2s ease;
    z-index: 10;
    border: none;
}

.custom-blog-toc .toc-toggle-btn:hover,
.mobile-toc-body .toc-toggle-btn:hover {
    background: #cbd5e0;
}

.custom-blog-toc .toc-toggle-btn.expanded,
.mobile-toc-body .toc-toggle-btn.expanded {
    background: #4fd1c7;
}

.custom-blog-toc .toc-toggle-btn.expanded:hover,
.mobile-toc-body .toc-toggle-btn.expanded:hover {
    background: #38b2ac;
}

.custom-blog-toc .toc-toggle-arrow,
.mobile-toc-body .toc-toggle-arrow {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 7px solid #4a5568;
    transition: transform .2s ease;
}

.custom-blog-toc .toc-toggle-btn.expanded .toc-toggle-arrow,
.mobile-toc-body .toc-toggle-btn.expanded .toc-toggle-arrow {
    transform: rotate(180deg);
    border-top-color: white;
}

.custom-blog-toc .toc-sublist,
.mobile-toc-body .toc-sublist {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,.2);
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease;
    z-index: 25;
    padding: 0;
    list-style: none;
    margin: 0;
}

.custom-blog-toc .toc-sublist.expanded,
.mobile-toc-body .toc-sublist.expanded {
    overflow-y: auto;
    box-shadow: 0 12px 30px rgba(0,0,0,.25);
}

.custom-blog-toc .toc-sublist.expanded::-webkit-scrollbar,
.mobile-toc-body .toc-sublist.expanded::-webkit-scrollbar {
    width: 6px;
}

.custom-blog-toc .toc-sublist.expanded::-webkit-scrollbar-track,
.mobile-toc-body .toc-sublist.expanded::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.custom-blog-toc .toc-sublist.expanded::-webkit-scrollbar-thumb,
.mobile-toc-body .toc-sublist.expanded::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.custom-blog-toc .toc-sublist.expanded::-webkit-scrollbar-thumb:hover,
.mobile-toc-body .toc-sublist.expanded::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.custom-blog-toc .toc-subitem,
.mobile-toc-body .toc-subitem {
    list-style: none;
}

.custom-blog-toc .toc-sub-link,
.mobile-toc-body .toc-sub-link {
    display: flex;
    align-items: center;
    background: #edf2f7;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    text-decoration: none;
    color: #4a5568;
    font-weight: 500;
    transition: all .2s ease;
    line-height: 1.4;
}

.custom-blog-toc .toc-subitem:last-child .toc-sub-link,
.mobile-toc-body .toc-subitem:last-child .toc-sub-link {
    margin-bottom: 0;
}

.custom-blog-toc .toc-sub-link:hover,
.mobile-toc-body .toc-sub-link:hover {
    background: #EBF8FF;
    border-color: #90CDF4;
    color: #2d3748;
    transform: translateY(-1px);
}

.custom-blog-toc .toc-sub-link::before,
.mobile-toc-body .toc-sub-link::before {
    content: "→";
    margin-right: 6px;
    color: #a0aec0;
    font-weight: bold;
}

.custom-blog-toc.has-active-dropdown .toc-item:not(.has-open-dropdown),
.mobile-toc-body.has-active-dropdown .toc-item:not(.has-open-dropdown) {
    opacity: .4;
    transition: opacity .3s ease;
}

.custom-blog-toc.has-active-dropdown .toc-item:not(.has-open-dropdown):hover,
.mobile-toc-body.has-active-dropdown .toc-item:not(.has-open-dropdown):hover {
    opacity: .6;
}


/* ============================================
   DESKTOP TOC — specific overrides only
   ============================================ */

.custom-blog-toc {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    border: 1px solid #e5e7eb;
    margin: 10px 0;
    padding: 0;
    max-width: 100%;
}

.custom-blog-toc .toc-header-wrapper {
    background: #e2e8f0;
    border-radius: 12px 12px 0 0;
    padding: 12px 16px;
    text-align: center;
    position: relative;
}

.custom-blog-toc .toc-sections-label {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #555;
    margin: 0;
}

.custom-blog-toc .toc-content {
    padding: 6px;
    overflow: visible;
    border-radius: 0 0 12px 12px;
    background: white;
}

.custom-blog-toc .toc-list {
    gap: 10px;
}

.custom-blog-toc .toc-main-link {
    padding: 12px 40px 12px 14px;
    font-size: 17px;
    min-height: 60px;
}

.custom-blog-toc .toc-toggle-btn {
    right: 6px;
    top: 16px;
    width: 32px;
    height: 32px;
}

.custom-blog-toc .toc-sublist.expanded {
    max-height: 280px;
    padding: 12px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 #f1f5f9;
}

.custom-blog-toc .toc-sub-link {
    padding: 10px 14px;
    font-size: 14px;
    margin-bottom: 8px;
}


/* ============================================
   MOBILE TOC BODY — specific overrides only
   ============================================ */

.mobile-toc-body {
    padding: 12px 16px 30px 16px;
}

.mobile-toc-body .toc-list {
    gap: 8px;
}

.mobile-toc-body .toc-main-link {
    padding: 10px 32px 10px 12px;
    font-size: 15px;
    min-height: 50px;
}

.mobile-toc-body .toc-toggle-btn {
    right: 4px;
    top: 13px;
    width: 28px;
    height: 28px;
}

.mobile-toc-body .toc-toggle-arrow {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #4a5568;
}

.mobile-toc-body .toc-sublist.expanded {
    max-height: 200px;
    padding: 10px;
}

.mobile-toc-body .toc-sublist.expanded::-webkit-scrollbar {
    width: 4px;
}

.mobile-toc-body .toc-sub-link {
    padding: 8px 12px;
    font-size: 12px;
    margin-bottom: 6px;
}


/* ============================================
   FLOATING BUTTON + MODAL
   ============================================ */

.floating-toc-btn {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    height: 44px;
    padding: 0 16px;
    background: #D4E0ED;
    border: none;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(212,224,237,.3);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all .3s ease;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1px;
    color: #555;
    text-transform: uppercase;
    white-space: nowrap;
}

.floating-toc-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.floating-toc-btn:hover {
    background: #c1d3e7;
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 16px rgba(212,224,237,.4);
}

.mobile-toc-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,.5);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: all .3s ease;
}

.mobile-toc-modal.active {
    opacity: 1;
    visibility: visible;
}

.mobile-toc-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    max-height: 80vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform .3s ease;
    margin: 0 16px;
}

.mobile-toc-modal.active .mobile-toc-content {
    transform: translateY(0);
}

.mobile-toc-header {
    padding: 20px 20px 10px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.mobile-toc-header h3 {
    margin: 0;
    font-size: 18px;
    color: #1f2937;
}

.mobile-toc-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}


/* ============================================
   RESPONSIVE
   ============================================ */

@media (min-width: 769px) {
    .floating-toc-btn {
        right: 110px;
        left: auto;
        transform: none;
        height: 50px;
        padding: 0 20px;
        border-radius: 12px;
        max-width: 200px;
    }

    .floating-toc-btn.visible {
        transform: translateY(0);
    }

    .floating-toc-btn:hover {
        transform: translateY(-3px);
    }

    .mobile-toc-content {
        position: fixed !important;
        bottom: 90px !important;
        right: 20px !important;
        left: auto !important;
        top: auto !important;
        border-radius: 16px;
        max-width: 700px;
        width: 500px;
        max-height: 70vh;
        box-shadow: 0 20px 25px -5px rgba(0,0,0,.1), 0 10px 10px -5px rgba(0,0,0,.04);
        transform: scale(.8) translateY(20px) !important;
        transform-origin: bottom right;
        transition: all .3s cubic-bezier(.34, 1.56, .64, 1);
        opacity: 0;
    }

    .mobile-toc-modal.active .mobile-toc-content {
        transform: scale(1) translateY(0) !important;
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .custom-blog-toc .toc-sections-label {
        font-size: 13px;
        letter-spacing: 1.5px;
    }

    .custom-blog-toc .toc-header-wrapper {
        padding: 12px 16px;
    }
    
    .custom-blog-toc .toc-content {
        padding: 12px;
    }
    
    .custom-blog-toc .toc-list {
        gap: 8px;
    }
    
    .custom-blog-toc .toc-main-link {
        padding: 10px 32px 10px 12px;
        font-size: .9em;
        min-height: 50px;
    }
    
    .custom-blog-toc .toc-toggle-btn {
        right: 4px;
        top: 13px;
        width: 28px;
        height: 28px;
    }
    
    .custom-blog-toc .toc-toggle-arrow {
        border-top: 6px solid #4a5568;
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
    }
    
    .custom-blog-toc .toc-sub-link {
        padding: 8px 12px;
        font-size: 12px;
        margin-bottom: 6px;
    }

    .custom-blog-toc .toc-sublist.expanded {
        max-height: 200px;
        padding: 10px;
    }
    
    .custom-blog-toc .toc-sublist.expanded::-webkit-scrollbar {
        width: 4px;
    }
}

@media (max-width: 480px) {
    .custom-blog-toc .toc-list,
    .mobile-toc-body .toc-list {
        grid-template-columns: 1fr;
    }
}
