/* ==========================================================================
   Manahil Estate — Sitemap Content Explorer (Gold Master CSS)
   ========================================================================== */

/* --- 1. Root & Wrapper --- */
.me-sitemap-wrapper {
    max-width: 1200px;
    margin: 40px auto 80px;
    font-family: var(--font-body, system-ui, sans-serif);
    color: var(--me-text, #333);
    line-height: 1.5;
}

/* --- Panel Visibility Logic (Updated) --- */
.me-sitemap-panel {
    display: none !important;  /* Force hide all panels by default */
}

.me-sitemap-panel.is-active {
    display: block !important; /* Force show ONLY the active panel */
    animation: meFadeInUp 0.3s ease-out; /* Add smooth entry */
}


/* --- 2. Controls Row (Search + Sort) --- */
.me-sitemap-controls {
    display: flex;
    gap: 16px;
    margin-bottom: 40px;
    align-items: center;
}

.me-search-wrap {
    position: relative;
    flex: 2; /* Editorial priority on search */
}

/* --- Search Load More Button --- */
.me-search-load-wrap {
    display: flex;
    justify-content: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--me-border);
}

.me-search-load-more {
    min-width: 200px;
    font-weight: 700;
}

.me-sort-wrap {
    flex: 1;
    min-width: 180px;
}

/* --- 3. Inputs (Overlap Bug Fixed) --- */
.me-sitemap-search,
.me-sitemap-sort {
    width: 100%;
    height: 48px;
    padding: 0 16px; 
    border: 1px solid var(--me-border, #ddd);
    border-radius: var(--me-radius, 8px);
    font-size: 15px;
    outline: none;
    background-color: #fff;
    color: var(--me-text-d, #111);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, padding 0.2s ease;
    appearance: none;
}

/* Magnifying Glass as stable background instead of overlay <span> */
.me-sitemap-search {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3ccircle cx='11' cy='11' r='8'%3e%3c/circle%3e%3cline x1='21' y1='21' x2='16.65' y2='16.65'%3e%3c/line%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 14px center;
    padding-left: 42px; /* Reserves space for the icon */
}

/* Shift padding and hide icon when user interacts */
.me-sitemap-search:focus,
.me-sitemap-search:not(:placeholder-shown) {
    background-image: none;
    padding-left: 16px; /* Text shifts comfortably to the left */
    border-color: var(--me-green, #88C22A);
    box-shadow: 0 0 0 3px rgba(136, 194, 42, 0.1);
}

.me-sitemap-sort {
    cursor: pointer;
    padding-right: 36px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

.me-sitemap-sort:focus {
    border-color: var(--me-green, #88C22A);
}

/* --- Spinner (Stays Positioned Right) --- */
.me-search-spinner {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid #eee;
    border-top-color: var(--me-green, #88C22A);
    border-radius: 50%;
    animation: meSpin 0.6s linear infinite;
    display: none;
    z-index: 5;
}
.me-search-spinner.is-loading { display: block; }

/* --- 5. Tabs (Pill Style) --- */
.me-sitemap-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid var(--me-border, #eee);
    margin-bottom: 30px;
    padding-bottom: 15px;
}

.me-sitemap-tab {
    background: var(--me-bg, #f9f9f9);
    border: 1px solid var(--me-border, #eee);
    padding: 8px 20px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    color: var(--me-text-l, #666);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    white-space: nowrap;
}

.me-sitemap-tab:hover {
    background: #eee;
    color: var(--me-text-d, #111);
}

.me-sitemap-tab.is-active {
    background: var(--me-green, #88C22A);
    color: #fff;
    border-color: var(--me-green, #88C22A);
    box-shadow: 0 4px 10px rgba(136, 194, 42, 0.2);
}

/* --- 6. Year Accordions --- */
.me-year-toggle {
    border-bottom: 1px solid var(--me-border, #f0f0f0);
}

.me-year-btn {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 20px 0;
    font-family: var(--font-heading, serif);
    font-size: clamp(1.2rem, 2.5vw, 1.5rem); /* Premium Responsive Size */
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--me-text-d, #111);
    transition: color 0.2s ease;
}

.me-year-btn:hover { color: var(--me-green, #88C22A); }

.me-year-icon {
    font-weight: 300;
    font-size: 1.5rem;
    color: var(--me-muted, #999);
    transition: color 0.2s ease;
}

.me-year-content {
    display: none;
    padding-bottom: 30px;
    opacity: 0;
    transform: translateY(10px);
}

.me-year-content.is-open {
    display: block;
    animation: meFadeInUp 0.4s forwards;
}

/* --- 7. Multi-Column List --- */
.me-sitemap-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    /* Clean 3-column index on desktop */
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px 48px;
}

.me-sitemap-link {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    text-decoration: none;
    color: var(--me-text, #444);
    font-size: 14px;
    padding: 6px 0;
    border-bottom: 1px dashed transparent;
    transition: color 0.2s ease;
}

.me-sitemap-link:hover {
    color: var(--me-green, #88C22A);
    border-bottom-color: rgba(136, 194, 42, 0.3);
}

.link-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-date {
    font-size: 11px;
    color: var(--me-text-l, #999);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 15px;
    font-feature-settings: "tnum"; /* Monospaced numbers for alignment */
}

/* --- 8. Search Results & Badges --- */
.me-sitemap-search-results {
    margin-bottom: 40px;
    border: 1px solid var(--me-border);
    border-radius: var(--me-radius, 10px);
    padding: 30px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}

.me-search-results-header {
    font-weight: 700;
    margin-bottom: 25px;
    color: var(--me-green);
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.me-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--me-bg, #f3f3f3);
    padding: 3px 8px;
    border-radius: 4px;
    margin-right: 10px;
    color: var(--me-text-l);
    vertical-align: middle;
    transition: all 0.2s ease;
}

.me-sitemap-link:hover .me-badge {
    background: var(--me-green);
    color: #fff;
}

/* --- 9. Animations --- */
@keyframes meSpin { to { transform: translateY(-50%) rotate(360deg); } }
@keyframes meFadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- 10. Responsive Tweaks --- */
@media (max-width: 768px) {
    .me-sitemap-controls { flex-direction: column; gap: 12px; }
    .me-sort-wrap { width: 100%; }
    .me-sitemap-list { grid-template-columns: 1fr; gap: 8px; }
    
    /* Smooth Scroll Tabs on Mobile */
    .me-sitemap-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 10px;
        scrollbar-width: thin;
    }
    .me-sitemap-tabs::-webkit-scrollbar { height: 4px; }
    .me-sitemap-tabs::-webkit-scrollbar-thumb { background: #ddd; border-radius: 10px; }
    
    .me-sitemap-tab { flex-shrink: 0; }
}