/* Google Font for Bitter */
@import url('https://fonts.googleapis.com/css2?family=Bitter:wght@400;600;700&display=swap');

.topic-details-page {
    font-family: 'Bitter', serif;
}

/* Sidebar Navigation */
.topic-sidebar-link {
    display: flex;
    /* Flex for icon alignment */
    align-items: flex-start;
    /* Align top for multi-line titles */
    padding: 10px 15px;
    margin-bottom: 4px;
    color: #555;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border-radius: 6px;
    /* Slightly squarer than pills */
    border-left: 3px solid transparent;
    transition: all 0.2s;
    line-height: 1.4;
}

.topic-sidebar-link:hover {
    background-color: #fff0f6;
    /* Light pink */
    color: #a61e4d;
    /* Dark pink */
}

.topic-sidebar-link.active {
    background-color: rgba(214, 51, 132, 0.05);
    /* Very light pink bg */
    color: #d63384;
    /* Pink text */
    border-left-color: #d63384;
    /* Pink border accent */
    font-weight: 600;
}

.topic-sidebar-link i {
    width: 20px;
    margin-right: 10px;
    margin-top: 3px;
    /* Align icon with first line of text */
    color: #aaa;
    transition: color 0.2s;
}

.topic-sidebar-link.active i {
    color: #d63384;
    /* Pink icon */
}

/* Content Area Typography */
.content-area {
    color: #000;
}

.content-area h1,
.content-area h2,
.content-area h3,
.content-area h4 {
    font-family: 'Bitter', serif;
    color: rgb(56, 70, 73);
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 1.25rem;
}

.content-area h1 {
    font-size: 24px;
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.content-area h2 {
    font-size: 20px;
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
}

.content-area h3 {
    font-size: 18px;
    margin-top: 2rem;
    margin-bottom: 1.25rem;
}

.content-area h4 {
    font-size: 16px;
    margin-top: 1.75rem;
    margin-bottom: 1rem;
}

.content-area p {
    font-family: 'Bitter', serif;
    font-size: 15px;
    line-height: 1.75;
    margin-bottom: 1.75rem;
    color: #222;
}

.content-area p:last-child {
    margin-bottom: 0;
}

.content-area ul,
.content-area ol {
    margin-top: 1.5rem;
    margin-bottom: 1.75rem;
    padding-left: 20px;
}

.content-area li {
    font-family: 'Bitter', serif;
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.content-area li:last-child {
    margin-bottom: 0;
}

/* Add spacing for other content elements */
.content-area blockquote {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.content-area img {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.content-area hr {
    margin-top: 2.5rem;
    margin-bottom: 2.5rem;
}

.content-area > *:first-child {
    margin-top: 0;
}

.content-area > *:last-child {
    margin-bottom: 0;
}

/* Topic Body Content - Desktop/Web View Spacing */
.topic-body-content {
    font-family: 'Bitter', serif;
}

.topic-body-content p {
    font-size: 15px;
    line-height: 1.75;
    margin-bottom: 1.75rem;
    color: #222;
}

.topic-body-content p:last-child {
    margin-bottom: 0;
}

/* Handle inline content without paragraph tags */
.topic-body-content > span,
.topic-body-content > b {
    display: block;
    font-size: 15px;
    line-height: 1.75;
    color: #222;
}

/* Bold headings/section titles - create visual breaks */
.topic-body-content > b {
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: rgb(56, 70, 73);
}

.topic-body-content > b:first-child {
    margin-top: 0;
}

/* Consecutive spans should flow together (inline) */
.topic-body-content > span + span {
    display: inline;
    margin-top: 0;
    margin-bottom: 0;
}

/* When a span is followed by a bold heading, add spacing before the bold */
.topic-body-content > span + b {
    margin-top: 2rem;
}

/* When a span is followed by a blockquote, add spacing before the blockquote */
.topic-body-content > span + blockquote {
    margin-top: 1.75rem;
}

/* When a blockquote is followed by a span, add spacing after the blockquote */
.topic-body-content > blockquote + span {
    margin-top: 1.75rem;
}

/* When a blockquote is followed by a bold heading, add spacing */
.topic-body-content > blockquote + b {
    margin-top: 2rem;
}

/* Last span in content should have bottom margin */
.topic-body-content > span:last-child {
    margin-bottom: 1.75rem;
}

.topic-body-content h1,
.topic-body-content h2,
.topic-body-content h3,
.topic-body-content h4,
.topic-body-content h5,
.topic-body-content h6 {
    font-family: 'Bitter', serif;
    color: rgb(56, 70, 73);
    font-weight: 700;
}

.topic-body-content h1 {
    font-size: 24px;
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.topic-body-content h2 {
    font-size: 20px;
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
}

.topic-body-content h3 {
    font-size: 18px;
    margin-top: 2rem;
    margin-bottom: 1.25rem;
}

.topic-body-content h4 {
    font-size: 16px;
    margin-top: 1.75rem;
    margin-bottom: 1rem;
}

.topic-body-content h5 {
    font-size: 15px;
    margin-top: 1.5rem;
    margin-bottom: 0.875rem;
}

.topic-body-content h6 {
    font-size: 14px;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
}

.topic-body-content ul,
.topic-body-content ol {
    margin-top: 1.5rem;
    margin-bottom: 1.75rem;
    padding-left: 20px;
}

.topic-body-content li {
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.topic-body-content li:last-child {
    margin-bottom: 0;
}

.topic-body-content blockquote {
    margin-top: 2rem;
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    border-left: 3px solid #d63384;
    background-color: #f8f9fa;
    font-size: 14px;
    line-height: 1.6;
    border-radius: 4px;
}

.topic-body-content img {
    margin-top: 2rem;
    margin-bottom: 2rem;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.topic-body-content hr {
    margin-top: 2.5rem;
    margin-bottom: 2.5rem;
    border: none;
    border-top: 1px solid #e9ecef;
}

.topic-body-content table {
    margin-top: 1.5rem;
    margin-bottom: 1.75rem;
    width: 100%;
    border-collapse: collapse;
}

.topic-body-content pre {
    margin-top: 1.5rem;
    margin-bottom: 1.75rem;
    padding: 1.25rem;
    background-color: #f8f9fa;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 14px;
}

.topic-body-content code {
    font-size: 14px;
    word-break: break-word;
    padding: 2px 6px;
    background-color: #f8f9fa;
    border-radius: 3px;
}

.topic-body-content > *:first-child {
    margin-top: 0;
}

.topic-body-content > *:last-child {
    margin-bottom: 0;
}

/* Writer Widget */
.writer-widget {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.back-link {
    font-family: 'Bitter', serif;
    font-weight: 600;
    color: #555;
    transition: color 0.2s;
}

.back-link:hover {
    color: #d63384;
}

/* Mobile Responsive Styles */
@media (max-width: 991.98px) {
    /* Container padding adjustment for mobile */
    .topic-details-page .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* Reduce row gap on mobile */
    .topic-details-page .row.g-3.g-lg-4 {
        --bs-gutter-y: 0.75rem;
        --bs-gutter-x: 0.75rem;
    }

    /* Hero section mobile adjustments */
    .topic-hub-hero {
        padding: 1.5rem 0;
    }

    .topic-hub-hero .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .topic-hub-hero h1 {
        font-size: 24px;
        line-height: 1.3;
        margin-bottom: 1rem;
    }

    .topic-hub-hero .mb-3 {
        margin-bottom: 1rem !important;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .topic-hub-hero .badge {
        font-size: 0.75rem;
        padding: 6px 12px;
    }

    .topic-hub-hero .text-muted {
        display: none; /* Hide separator on mobile */
    }

    /* Content area mobile adjustments */
    .content-area {
        padding: 0 !important;
    }

    .content-area h1 {
        font-size: 20px !important;
        line-height: 1.3;
        margin-bottom: 1.25rem;
        padding-right: 0.5rem;
    }

    .topic-body-content {
        font-size: 15px !important;
        line-height: 1.65;
    }

    .topic-body-content p {
        font-size: 15px !important;
        line-height: 1.65;
        margin-bottom: 1.5rem !important;
    }

    .topic-body-content p:last-child {
        margin-bottom: 0 !important;
    }

    .topic-body-content h2 {
        font-size: 18px !important;
        margin-top: 2rem !important;
        margin-bottom: 1.25rem !important;
        line-height: 1.3;
    }

    .topic-body-content h3 {
        font-size: 16px !important;
        margin-top: 1.75rem !important;
        margin-bottom: 1rem !important;
        line-height: 1.3;
    }

    .topic-body-content h4 {
        font-size: 15px !important;
        margin-top: 1.5rem !important;
        margin-bottom: 0.875rem !important;
        line-height: 1.3;
    }

    .topic-body-content ul,
    .topic-body-content ol {
        padding-left: 1.25rem;
        margin-top: 1.25rem !important;
        margin-bottom: 1.5rem !important;
    }

    .topic-body-content li {
        font-size: 15px !important;
        line-height: 1.65;
        margin-bottom: 0.625rem;
    }

    .topic-body-content li:last-child {
        margin-bottom: 0;
    }

    .topic-body-content blockquote {
        margin-top: 1.75rem !important;
        margin-bottom: 1.75rem !important;
    }

    .topic-body-content img {
        margin-top: 1.75rem !important;
        margin-bottom: 1.75rem !important;
    }

    /* Ensure images and media are responsive */
    .topic-body-content img {
        max-width: 100%;
        height: auto;
        border-radius: 8px;
        margin: 1.25rem 0;
    }

    .topic-body-content table {
        width: 100%;
        overflow-x: auto;
        display: block;
        font-size: 13px;
        margin: 1rem 0;
    }

    .topic-body-content blockquote {
        padding: 0.875rem;
        margin: 1.25rem 0;
        border-left: 3px solid #d63384;
        background-color: #f8f9fa;
        font-size: 14px;
        line-height: 1.6;
        border-radius: 4px;
    }

    .topic-body-content pre {
        overflow-x: auto;
        font-size: 13px;
        padding: 0.875rem;
        border-radius: 6px;
        margin: 1rem 0;
    }

    .topic-body-content code {
        font-size: 13px;
        word-break: break-word;
    }

    /* Better spacing for content sections */
    .content-area {
        margin-bottom: 1rem;
    }

    /* Mobile dropdown navigation - Modern Design */
    .dropdown-toggle {
        font-size: 0.95rem;
        font-weight: 600;
        padding: 0.875rem 1.125rem;
        border-radius: 12px;
        border: 2px solid #e9ecef;
        background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
        color: #212529;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        transition: all 0.3s ease;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }

    .dropdown-toggle:hover {
        border-color: var(--primary-color);
        background: linear-gradient(135deg, #ffffff 0%, #fff0f6 100%);
        box-shadow: 0 4px 12px rgba(214, 51, 132, 0.15);
        transform: translateY(-1px);
    }

    .dropdown-toggle:focus,
    .dropdown-toggle.show {
        border-color: var(--primary-color);
        background: linear-gradient(135deg, #ffffff 0%, #fff0f6 100%);
        box-shadow: 0 4px 12px rgba(214, 51, 132, 0.2);
        outline: none;
    }

    .dropdown-toggle span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex: 1;
        min-width: 0;
        color: #212529;
    }

    .dropdown-toggle i.fa-list {
        color: var(--primary-color);
        margin-right: 0.5rem;
    }

    /* Style Bootstrap's default dropdown arrow */
    .dropdown-toggle::after {
        color: var(--primary-color);
        transition: transform 0.3s ease;
        margin-left: auto;
        flex-shrink: 0;
    }

    .dropdown-toggle.show::after {
        transform: rotate(180deg);
    }

    .dropdown-menu {
        max-height: 60vh;
        overflow-y: auto;
        border-radius: 12px;
        margin-top: 0.75rem;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        border: 1px solid #e9ecef;
        max-width: 100%;
        width: 100%;
        word-wrap: break-word;
        padding: 0.5rem;
        background: #ffffff;
    }

    .dropdown-menu::-webkit-scrollbar {
        width: 6px;
    }

    .dropdown-menu::-webkit-scrollbar-track {
        background: #f1f3f5;
        border-radius: 10px;
    }

    .dropdown-menu::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 10px;
    }

    .dropdown-item {
        padding: 0.875rem 1rem;
        font-size: 0.9rem;
        font-weight: 500;
        white-space: normal;
        word-wrap: break-word;
        word-break: break-word;
        overflow-wrap: break-word;
        line-height: 1.5;
        hyphens: auto;
        color: #495057;
        border-radius: 8px;
        margin-bottom: 0.25rem;
        transition: all 0.2s ease;
        position: relative;
    }

    .dropdown-item:last-child {
        margin-bottom: 0;
    }

    .dropdown-item:hover,
    .dropdown-item:focus {
        white-space: normal;
        background: linear-gradient(135deg, rgba(214, 51, 132, 0.08) 0%, rgba(214, 51, 132, 0.05) 100%);
        color: var(--primary-color);
        transform: translateX(4px);
        padding-left: 1.25rem;
    }

    .dropdown-item:active {
        background: linear-gradient(135deg, rgba(214, 51, 132, 0.15) 0%, rgba(214, 51, 132, 0.1) 100%);
        color: var(--primary-color);
    }

    /* Active/current item styling */
    .dropdown-item.active {
        background: linear-gradient(135deg, rgba(214, 51, 132, 0.12) 0%, rgba(214, 51, 132, 0.08) 100%);
        color: var(--primary-color);
        font-weight: 600;
        border-left: 3px solid var(--primary-color);
        padding-left: calc(1rem - 3px);
    }

    .dropdown-item.active i {
        color: var(--primary-color);
    }

    /* Icon styling in dropdown items */
    .dropdown-item i {
        transition: transform 0.2s ease;
    }

    .dropdown-item:hover i {
        transform: scale(1.1);
    }

    /* Right sidebar mobile adjustments */
    .col-lg-3.col-xl-3 {
        margin-top: 1.5rem;
    }

    .writer-widget {
        padding: 1rem;
        margin-bottom: 1.25rem;
        border-radius: 12px;
    }

    .writer-widget h6 {
        font-size: 0.75rem;
        margin-bottom: 1rem;
    }

    .writer-widget .avatar {
        width: 45px !important;
        height: 45px !important;
        font-size: 1.1rem;
    }

    .writer-widget ul li {
        margin-bottom: 1rem;
    }

    .writer-widget ul li a {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .writer-widget .small {
        font-size: 0.75rem !important;
        margin-top: 0.25rem;
    }

    /* Remove sticky positioning on mobile */
    .sticky-top {
        position: relative !important;
        top: 0 !important;
    }

    /* Back link mobile */
    .topic-hub-hero .mb-4 {
        margin-bottom: 1rem !important;
    }

    .topic-hub-hero .mb-4 a {
        font-size: 0.75rem;
        padding: 0 1rem;
        display: inline-block;
    }

    /* Better spacing for article */
    .content-area {
        margin-top: 0.5rem;
    }

    /* Improve mobile dropdown button */
    .d-lg-none .dropdown {
        margin-bottom: 1rem;
        position: relative;
    }

    /* Ensure dropdown menu doesn't overflow */
    .d-lg-none .dropdown-menu {
        position: absolute !important;
        left: 0 !important;
        right: 0 !important;
        max-width: 100vw;
        width: 100% !important;
        transform: translate3d(0px, 0px, 0px) !important;
        margin-top: 0.5rem !important;
    }

    /* Prevent dropdown from going off screen */
    .d-lg-none .dropdown-menu.show {
        max-width: calc(100vw - 1rem);
        left: 0 !important;
        right: auto !important;
    }
}

@media (max-width: 576px) {
    /* Extra small mobile adjustments */
    .topic-hub-hero h1 {
        font-size: 18px;
        padding: 0 0.5rem;
    }

    .topic-hub-hero .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .topic-hub-hero .badge {
        font-size: 0.65rem;
        padding: 4px 8px;
    }

    .content-area h1 {
        font-size: 18px !important;
        margin-bottom: 1rem;
    }

    .topic-body-content {
        font-size: 14px !important;
        line-height: 1.6;
    }

    .topic-body-content p {
        font-size: 14px !important;
        line-height: 1.6;
        margin-bottom: 1.25rem !important;
    }

    .topic-body-content p:last-child {
        margin-bottom: 0 !important;
    }

    .topic-body-content h2 {
        font-size: 16px !important;
        margin-top: 1.75rem !important;
        margin-bottom: 1rem !important;
    }

    .topic-body-content h3 {
        font-size: 15px !important;
        margin-top: 1.5rem !important;
        margin-bottom: 0.875rem !important;
    }

    .topic-body-content h4 {
        font-size: 14px !important;
        margin-top: 1.25rem !important;
        margin-bottom: 0.75rem !important;
    }

    .topic-body-content li {
        font-size: 14px !important;
        line-height: 1.6;
        margin-bottom: 0.5rem;
    }

    .topic-body-content li:last-child {
        margin-bottom: 0;
    }

    .topic-body-content ul,
    .topic-body-content ol {
        padding-left: 1rem;
        margin-top: 1rem !important;
        margin-bottom: 1.25rem !important;
    }

    .topic-body-content blockquote {
        margin-top: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }

    .topic-body-content img {
        margin-top: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }

    .writer-widget {
        padding: 0.875rem;
        margin-bottom: 1rem;
    }

    .topic-details-page .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* Further reduce row gap on small screens */
    .topic-details-page .row.g-3.g-lg-4 {
        --bs-gutter-y: 0.5rem;
        --bs-gutter-x: 0.5rem;
    }

    .dropdown-toggle {
        font-size: 0.875rem;
        padding: 0.75rem 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        border-radius: 10px;
    }

    .dropdown-toggle span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex: 1;
        min-width: 0;
    }

    .dropdown-menu {
        border-radius: 10px;
        padding: 0.375rem;
    }

    .dropdown-item {
        padding: 0.75rem 0.875rem;
        font-size: 0.875rem;
        white-space: normal;
        word-wrap: break-word;
        word-break: break-word;
        overflow-wrap: break-word;
        line-height: 1.5;
        border-radius: 6px;
    }

    .dropdown-item:hover,
    .dropdown-item:focus {
        transform: translateX(3px);
        padding-left: 1.125rem;
    }

    .topic-body-content img {
        margin: 1rem 0;
    }

    .topic-body-content blockquote {
        padding: 0.75rem;
        margin: 1rem 0;
        font-size: 13px;
    }

    .topic-body-content table {
        font-size: 12px;
    }

    .topic-body-content pre {
        font-size: 12px;
        padding: 0.75rem;
    }

    .topic-body-content code {
        font-size: 12px;
    }

    .topic-body-content img {
        margin: 1rem 0;
    }

    .topic-body-content blockquote {
        padding: 0.75rem;
        margin: 1rem 0;
        font-size: 14px;
    }
}