/* My Custom TOC Plugin Styles - Version 1.5.3 (Alignment & Style Fix) */

/* Container - Right Aligned */
.mctoc-container {
    background: #ffffff;
    border: 1px solid #0073aa;
    border-radius: 8px;
    margin: 20px 0 30px auto;
    max-width: 500px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    overflow: hidden;
    text-align: right;
}
/* Header */
.mctoc-header {
    background: #0073aa;
    padding: 12px 18px;
    cursor: pointer;
    position: relative;
    text-align: right;
    transition: background-color 0.3s ease;
}
.mctoc-header:hover {
    background: #005a8b;
}
/* Title */
.mctoc-title {
    color: #ffffff;
    font-size: 1.1em;
    font-weight: bold;
    margin: 0;
}
/* Toggle Button - More Spacing */
.mctoc-toggle {
    color: #ffffff;
    font-size: 0.9em;
    margin-right: 15px;
    font-weight: normal;
}
/* List Container - RTL for Arabic */
.mctoc-list {
    display: none;
    padding: 15px 25px 15px 30px;
    margin: 0;
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    direction: rtl;
    text-align: right;
    /* FIX 1: Remove default browser numbering and set up our custom counter */
    list-style: none;
    counter-reset: toc-counter;
}
/* Show the list when container has 'expanded' class */
.mctoc-container.expanded .mctoc-list {
    display: block;
}
/* List Items - Reduced Spacing */
.mctoc-list li {
    line-height: 1.5; /* Slightly increased for better readability */
    color: #333;
    margin-bottom: 8px; /* Increased margin between items */
    /* FIX 1: Use Flexbox for perfect alignment */
    display: flex;
    align-items: flex-start; /* Aligns number to the top of the text */
}

/* FIX 1: Create and style the custom numbers */
.mctoc-list li::before {
    counter-increment: toc-counter;
    content: counter(toc-counter) ".";
    font-weight: 500;
    color: #333;
    min-width: 1em; /* Ensures space for double-digit numbers */
    padding-left: 5px; /* Space after the number */
    flex-shrink: 0; /* Prevents the number from shrinking */
}

/* Links with Hover/Visited States */
.mctoc-list li a {
    color: #0073aa;
    text-decoration: none;
    font-size: 0.95em;
    transition: all 0.2s ease;
    padding: 2px 5px;
    display: inline-block;
    border-radius: 3px;
}
.mctoc-list li a:hover {
    background: #e8f4f8;
    color: #005177;
}

/* FIX 2: Correct "greyed out" style - ONLY text color changes, NO background. */
.mctoc-list li a:visited,
.mctoc-list li a.mctoc-clicked {
    color: #666666;
    background: none; /* Explicitly remove background */
}
/* FIX 2: Ensure hover on a clicked/visited link doesn't bring back the blue color */
.mctoc-list li a.mctoc-clicked:hover {
    color: #666666;
    background: #f0f0f0; /* a light background on hover is ok */
}

.mctoc-list li a:active {
    background: #d0d0d0;
}
/* Remove Numbers for Non-H2 */
.mctoc-list .mctoc-no-number {
    list-style: none;
}
.mctoc-list .mctoc-no-number::before {
    content: ""; /* Hides number for this class */
    min-width: 2em;
}

/* Heading Level Indentation - Right Side */
.mctoc-list .mctoc-level-2 {
    font-weight: 500;
}
.mctoc-list .mctoc-level-3 {
    margin-right: 20px;
}
.mctoc-list .mctoc-level-4 {
    margin-right: 35px;
}
.mctoc-list .mctoc-level-5 {
    margin-right: 50px;
}
/* Responsive Design */
@media (max-width: 600px) {
    .mctoc-container {
        max-width: 95%;
        margin: 15px auto 25px;
    }

    .mctoc-list {
        padding: 15px 20px 15px 30px;
    }

    .mctoc-header {
        padding: 10px 15px;
    }
}
/* Print Styles */
@media print {
    .mctoc-container {
        border: 1px solid #000;
        box-shadow: none;
    }

    .mctoc-header {
        background: #f0f0f0;
        color: #000;
    }

    .mctoc-title,
    .mctoc-toggle {
        color: #000;
    }

    .mctoc-list {
        display: block !important;
    }

    .mctoc-toggle {
        display: none;
    }
}