/* ==========================================================================
   Solution Buddy - Essay Section
   Master Mobile-First Responsive Stylesheet (320px to 1920px+)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens & Root Variables
   -------------------------------------------------------------------------- */
:root {
    /* Brand Primary Palette */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-active: #1e40af;
    --primary-subtle: #eff6ff;
    --primary-border: #bfdbfe;
    
    /* Language Badges */
    --lang-en: #2563eb;
    --lang-en-bg: #eff6ff;
    --lang-en-border: #bfdbfe;
    
    --lang-hi: #dc2626;
    --lang-hi-bg: #fef2f2;
    --lang-hi-border: #fecaca;
    
    --lang-mr: #d97706;
    --lang-mr-bg: #fffbeb;
    --lang-mr-border: #fde68a;

    /* Neutrals & Surfaces */
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-muted: #f1f5f9;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;

    /* Typography Colors */
    --text-heading: #0f172a;
    --text-body: #334155;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* Font Families */
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-devanagari: 'Noto Sans Devanagari', 'Plus Jakarta Sans', sans-serif;

    /* Fluid Typography using clamp() */
    --font-size-hero-title: clamp(1.45rem, 5vw, 2.5rem);
    --font-size-article-title: clamp(1.35rem, 4.2vw, 2.25rem);
    --font-size-card-title: clamp(1.08rem, 2.4vw, 1.25rem);
    --font-size-body: clamp(0.98rem, 1.8vw, 1.15rem);

    /* Radii */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.25rem;
    --radius-pill: 9999px;

    /* Responsive Shadows */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 2px 4px -1px rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.1), 0 4px 8px -2px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 14px 28px -5px rgba(37, 99, 235, 0.14), 0 6px 12px -2px rgba(0, 0, 0, 0.05);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --------------------------------------------------------------------------
   Dark Mode Theme Overrides
   -------------------------------------------------------------------------- */
[data-bs-theme="dark"] {
    --bg-page: #0b0f19;
    --bg-card: #131b2e;
    --bg-muted: #1c263c;
    --border-color: #26354f;
    --border-hover: #3d5074;

    --text-heading: #f8fafc;
    --text-body: #cbd5e1;
    --text-muted: #94a3b8;
    --text-light: #64748b;

    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-active: #2563eb;
    --primary-subtle: rgba(59, 130, 246, 0.16);
    --primary-border: rgba(59, 130, 246, 0.35);

    --lang-en: #60a5fa;
    --lang-en-bg: rgba(59, 130, 246, 0.18);
    --lang-en-border: rgba(59, 130, 246, 0.35);

    --lang-hi: #f87171;
    --lang-hi-bg: rgba(239, 68, 68, 0.18);
    --lang-hi-border: rgba(239, 68, 68, 0.35);

    --lang-mr: #fbbf24;
    --lang-mr-bg: rgba(245, 158, 11, 0.18);
    --lang-mr-border: rgba(245, 158, 11, 0.35);

    --shadow-md: 0 4px 14px -2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 28px -4px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 14px 28px -5px rgba(0, 0, 0, 0.6), 0 0 16px rgba(59, 130, 246, 0.2);
}

/* Theme Toggle Button */
.theme-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-pill);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-body);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-xs);
    font-size: 1rem;
    padding: 0;
}

.theme-toggle-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: rotate(15deg) scale(1.08);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.25);
}

/* Icon visibility depending on active theme */
[data-bs-theme="dark"] .theme-icon-light {
    display: inline-block;
    color: #fbbf24;
}
[data-bs-theme="dark"] .theme-icon-dark {
    display: none;
}
:root:not([data-bs-theme="dark"]) .theme-icon-light,
[data-bs-theme="light"] .theme-icon-light {
    display: none;
}
:root:not([data-bs-theme="dark"]) .theme-icon-dark,
[data-bs-theme="light"] .theme-icon-dark {
    display: inline-block;
    color: #1e293b;
}
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden; /* Prevents any unwanted horizontal scrollbar */
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

main {
    flex: 1;
    width: 100%;
}

/* Responsive Media rules */
img, video, iframe, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Automatic Word Break Protection for All Screens */
h1, h2, h3, h4, h5, h6, p, span, a, li, button, td, th {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Large Screens (1280px, 1440px, 1920px+): Constrain content */
.container, .container-fluid {
    max-width: 1280px;
    padding-left: clamp(0.75rem, 3vw, 1.75rem);
    padding-right: clamp(0.75rem, 3vw, 1.75rem);
}

/* Devanagari Script Support (Hindi & Marathi) */
.devanagari-font {
    font-family: var(--font-devanagari);
    letter-spacing: 0.015em;
    line-height: 1.85;
}

/* --------------------------------------------------------------------------
   3. Touch-Friendly Interactive Elements
   -------------------------------------------------------------------------- */
.btn {
    font-weight: 600;
    border-radius: var(--radius-pill);
    padding: 0.55rem 1.25rem;
    min-height: 42px; /* Touch target */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    white-space: nowrap;
}

.btn-sm {
    min-height: 36px;
    padding: 0.38rem 0.95rem;
    font-size: 0.85rem;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border: none;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    color: #ffffff;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline-primary {
    color: var(--primary);
    border: 1.5px solid var(--primary);
    background-color: transparent;
}

.btn-outline-primary:hover {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

/* Form Controls */
.form-control, .form-select {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 0.65rem 1rem;
    min-height: 44px; /* Touch friendly height */
    font-size: 0.95rem;
    color: var(--text-heading);
    background-color: #ffffff;
    width: 100%;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

/* --------------------------------------------------------------------------
   4. Responsive Navigation Bar
   -------------------------------------------------------------------------- */
.main-nav {
    background-color: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color) !important;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.15rem;
    box-shadow: 0 3px 8px rgba(37, 99, 235, 0.28);
    flex-shrink: 0;
}

.brand-icon.small {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
}

.brand-icon-lg {
    width: 56px;
    height: 56px;
    font-size: 1.6rem;
    border-radius: 14px;
}

.brand-title {
    font-size: clamp(1.1rem, 2.5vw, 1.35rem);
    letter-spacing: -0.025em;
    color: #000000 !important; /* Solution Buddy explicitly black */
    font-weight: 800;
    white-space: nowrap;
}

[data-bs-theme="dark"] .brand-title {
    color: #ffffff !important;
}

.nav-search {
    width: 100%;
    max-width: 340px;
}

.nav-search .input-group {
    border-radius: var(--radius-pill);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background-color: var(--bg-muted);
}

.nav-search .input-group:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    background-color: #ffffff;
}

.nav-link {
    font-weight: 500;
    color: var(--text-body) !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: var(--radius-sm);
}

.nav-link:hover, .nav-link.active {
    color: var(--primary) !important;
}

/* --------------------------------------------------------------------------
   5. Hero Banner & Search (Mobile & Desktop)
   -------------------------------------------------------------------------- */
.hero-section {
    background: radial-gradient(ellipse at top, #eff6ff 0%, #ffffff 85%);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    padding: clamp(1.5rem, 5vw, 3rem) clamp(1rem, 4vw, 2.5rem);
    border-radius: var(--radius-xl);
}

.hero-title {
    font-size: var(--font-size-hero-title);
    font-weight: 800;
    line-height: 1.25;
    margin-bottom: 0.75rem;
    color: var(--text-heading);
}

.hero-desc {
    font-size: clamp(0.92rem, 2vw, 1.08rem);
    color: var(--text-muted);
    max-width: 620px;
    margin: 0 auto 1.5rem auto;
}

/* Responsive Search Input in Hero */
.search-form {
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
}

.search-box-wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-md);
    padding: 4px;
    transition: all var(--transition-normal);
}

.search-box-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15), var(--shadow-lg);
}

.search-box-input {
    border: none;
    outline: none;
    padding: 0.6rem 0.8rem;
    flex: 1;
    min-width: 0; /* Prevents overflow in flexbox */
    font-size: clamp(0.9rem, 2vw, 1rem);
    color: var(--text-heading);
    background: transparent;
}

.search-box-btn {
    border-radius: var(--radius-pill);
    flex-shrink: 0;
    padding: 0.6rem clamp(0.9rem, 2.5vw, 1.6rem);
}

/* On ultra-compact screens (< 360px), stack search input if needed */
@media (max-width: 359px) {
    .search-box-wrap {
        border-radius: var(--radius-lg);
        flex-direction: column;
        gap: 0.4rem;
        padding: 6px;
    }
    .search-box-btn {
        width: 100%;
        border-radius: var(--radius-md);
    }
}

/* --------------------------------------------------------------------------
   6. Filters Bar & Topic Navigation
   -------------------------------------------------------------------------- */
.filters-card {
    border-color: var(--border-color) !important;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: clamp(1rem, 3vw, 1.5rem);
}

/* Language Segmented Control */
.lang-segmented-control {
    display: flex;
    width: 100%;
    background-color: var(--bg-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    padding: 4px;
    gap: 2px;
}

.lang-segmented-control .btn {
    flex: 1;
    min-height: 36px;
    padding: 0.35rem 0.5rem;
    font-size: clamp(0.78rem, 2vw, 0.88rem);
    border-radius: var(--radius-pill);
}

/* Horizontal Topic Pills Bar with Smooth Native Touch Scrolling */
.category-pills-bar {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
}

.category-pills-bar::-webkit-scrollbar {
    height: 4px;
}

.category-pills-bar::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.category-pills-bar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.category-pill-btn {
    flex-shrink: 0;
    min-height: 36px;
    padding: 0.4rem 0.95rem;
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: var(--radius-pill);
    transition: all var(--transition-fast);
    border: 1px solid var(--border-color);
}

/* --------------------------------------------------------------------------
   7. Essay Cards Grid (Mobile, Tablet, Desktop)
   -------------------------------------------------------------------------- */
.essays-grid {
    display: grid;
    grid-template-columns: 1fr; /* Default Mobile: 1 column */
    gap: clamp(1rem, 2.5vw, 1.5rem);
    width: 100%;
}

/* Tablet (768px+): 2 columns */
@media (min-width: 768px) {
    .essays-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop (1024px+): 3 columns */
@media (min-width: 1024px) {
    .essays-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Essay Card Styling */
.essay-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.hover-elevate:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover) !important;
    border-color: #cbd5e1;
}

.essay-card-body {
    padding: clamp(1.1rem, 3vw, 1.5rem);
    display: flex;
    flex-direction: column;
    flex: 1;
}

.essay-title {
    font-size: var(--font-size-card-title);
    line-height: 1.45;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.essay-title a {
    color: var(--text-heading);
    transition: color var(--transition-fast);
}

.essay-card:hover .essay-title a {
    color: var(--primary);
}

/* Language Badges */
.badge-lang-english {
    background-color: var(--lang-en-bg);
    color: var(--lang-en);
    border: 1px solid var(--lang-en-border);
}

.badge-lang-hindi {
    background-color: var(--lang-hi-bg);
    color: var(--lang-hi);
    border: 1px solid var(--lang-hi-border);
}

.badge-lang-marathi {
    background-color: var(--lang-mr-bg);
    color: var(--lang-mr);
    border: 1px solid var(--lang-mr-border);
}

.card-footer-meta {
    border-color: var(--border-color) !important;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding-top: 0.85rem;
    margin-top: auto;
}

/* --------------------------------------------------------------------------
   8. Full Essay Reader Article Page (Mobile & Desktop)
   -------------------------------------------------------------------------- */
.reader-wrapper {
    width: 100%;
    max-width: 840px; /* Constrained reading width for high readability */
    margin: 0 auto;
}

.essay-container {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-xl);
    padding: clamp(1.2rem, 4vw, 3rem);
}

.article-title {
    font-size: var(--font-size-article-title);
    line-height: 1.35;
    letter-spacing: -0.02em;
    color: var(--text-heading);
    font-weight: 800;
}

.breadcrumb-active-title {
    max-width: clamp(120px, 30vw, 280px);
}

.essay-article {
    font-size: var(--font-size-body);
    line-height: 1.95;
    color: #2b2d42;
    margin-top: 1.5rem;
    transition: font-size var(--transition-fast);
}

/* Font Size Adjuster States */
.essay-article.font-sm {
    font-size: clamp(0.88rem, 1.5vw, 1rem) !important;
    line-height: 1.75 !important;
}

.essay-article.font-md {
    font-size: var(--font-size-body) !important;
    line-height: 1.95 !important;
}

.essay-article.font-lg {
    font-size: clamp(1.15rem, 2.3vw, 1.35rem) !important;
    line-height: 2.1 !important;
}

.reader-action-toolbar {
    background-color: var(--bg-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: background-color var(--transition-normal);
}

.font-size-group .btn {
    min-height: 28px;
    font-size: 0.8rem;
    font-weight: 700;
}

[data-bs-theme="dark"] .font-size-group {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

[data-bs-theme="dark"] .font-size-group .btn-light {
    background-color: transparent !important;
    color: var(--text-muted) !important;
    border-color: transparent !important;
}

[data-bs-theme="dark"] .font-size-group .btn-light.active {
    background-color: var(--primary) !important;
    color: #ffffff !important;
}

.essay-article p {
    margin-bottom: 1.5rem;
}

.essay-article strong {
    color: #0f172a;
    font-weight: 700;
}

.essay-article h2, .essay-article h3, .essay-article h4 {
    margin-top: 2rem;
    margin-bottom: 0.85rem;
    font-size: clamp(1.15rem, 3vw, 1.55rem);
}

.essay-article ul, .essay-article ol {
    margin-bottom: 1.5rem;
    padding-left: clamp(1.2rem, 3vw, 1.8rem);
}

.essay-article li {
    margin-bottom: 0.5rem;
}

.essay-article blockquote {
    border-left: 4px solid var(--primary);
    padding: 0.85rem 1.25rem;
    margin: 1.5rem 0;
    background-color: var(--bg-muted);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-style: italic;
    color: var(--text-body);
}

/* Article Reader Action Buttons */
.reader-action-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

@media (max-width: 480px) {
    .reader-action-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .reader-action-toolbar .btn {
        width: 100%;
    }
}

/* Related Essays Grid */
.related-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .related-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* --------------------------------------------------------------------------
   9. Admin CMS & Responsive Mobile Card View
   -------------------------------------------------------------------------- */
.stat-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(0.75rem, 2vw, 1rem);
    margin-bottom: 1.5rem;
}

@media (min-width: 992px) {
    .stat-cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.stat-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    flex-shrink: 0;
}

.admin-search-input {
    width: 100%;
    max-width: 260px;
}

/* Responsive Table-to-Card Transformation for Admin on Mobile */
@media (max-width: 767.98px) {
    .responsive-admin-table thead {
        display: none; /* Hide desktop table headers on mobile */
    }

    .responsive-admin-table, 
    .responsive-admin-table tbody, 
    .responsive-admin-table tr, 
    .responsive-admin-table td {
        display: block;
        width: 100%;
    }

    .responsive-admin-table tr {
        background: #ffffff;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: var(--shadow-xs);
    }

    .responsive-admin-table td {
        padding: 0.45rem 0 !important;
        border: none !important;
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: right;
        font-size: 0.88rem;
    }

    .responsive-admin-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.76rem;
        text-transform: uppercase;
        color: var(--text-muted);
        text-align: left;
        margin-right: 0.5rem;
    }

    .responsive-admin-table td.admin-essay-title-cell {
        display: block;
        text-align: left;
        padding-bottom: 0.75rem !important;
        margin-bottom: 0.5rem;
        border-bottom: 1px solid var(--border-color) !important;
    }

    .responsive-admin-table td.admin-essay-title-cell::before {
        display: none;
    }

    .responsive-admin-table td.admin-actions-cell {
        display: flex;
        justify-content: flex-end;
        padding-top: 0.75rem !important;
        margin-top: 0.5rem;
        border-top: 1px solid var(--border-color) !important;
    }

    .responsive-admin-table td.admin-actions-cell::before {
        display: none;
    }

    .responsive-admin-table td.admin-actions-cell .btn-group {
        width: 100%;
    }

    .responsive-admin-table td.admin-actions-cell .btn {
        flex: 1;
    }
}

/* Quill Editor Responsiveness */
.ql-toolbar.ql-snow {
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
    background-color: #f8fafc;
    border-color: #cbd5e1 !important;
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.ql-container.ql-snow {
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    border-color: #cbd5e1 !important;
    background-color: #ffffff;
}

.ql-editor {
    min-height: clamp(260px, 40vh, 380px);
    font-size: 1.05rem;
    line-height: 1.8;
    font-family: var(--font-sans);
    color: var(--text-heading);
    padding: clamp(0.75rem, 2.5vw, 1.25rem);
}

/* Category manager table */
.category-table-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
}

/* --------------------------------------------------------------------------
   10. Print Optimization
   -------------------------------------------------------------------------- */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
    .no-print, .main-nav, footer {
        display: none !important;
    }
    .essay-container {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
    }
    .essay-article {
        font-size: 12pt;
        line-height: 1.6;
        color: #000000;
    }
    .article-title {
        font-size: 20pt;
        color: #000000;
    }
}

/* --------------------------------------------------------------------------
   11. Helper Utilities
   -------------------------------------------------------------------------- */
.x-small {
    font-size: 0.76rem;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   12. Dark Mode Component Enhancements & Polished UI
   -------------------------------------------------------------------------- */
[data-bs-theme="dark"] .main-nav {
    background-color: rgba(19, 27, 46, 0.94) !important;
    border-color: var(--border-color) !important;
}

[data-bs-theme="dark"] .hero-section {
    background: radial-gradient(ellipse at top, #162540 0%, #131b2e 85%) !important;
    border-color: var(--border-color) !important;
}

[data-bs-theme="dark"] .search-box-wrap {
    background: #0b1120;
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .search-box-input {
    color: var(--text-heading);
}

[data-bs-theme="dark"] .filters-card {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

[data-bs-theme="dark"] .essay-card {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .essay-card:hover {
    border-color: var(--primary);
    box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.5), 0 0 15px rgba(59, 130, 246, 0.15);
}

[data-bs-theme="dark"] .essay-title a {
    color: #f1f5f9;
}

[data-bs-theme="dark"] .essay-title a:hover {
    color: var(--primary);
}

[data-bs-theme="dark"] .card-footer-meta {
    border-color: var(--border-color) !important;
    color: var(--text-muted);
}

[data-bs-theme="dark"] .reader-wrapper,
[data-bs-theme="dark"] .essay-container {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .excerpt-box {
    background-color: #1a253c;
    border-color: #2b3d64;
    color: var(--text-heading);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #0b1120 !important;
    color: var(--text-heading) !important;
    border-color: var(--border-color) !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25) !important;
}

[data-bs-theme="dark"] .bg-white {
    background-color: var(--bg-card) !important;
}

[data-bs-theme="dark"] .bg-light {
    background-color: var(--bg-muted) !important;
}

[data-bs-theme="dark"] .text-dark {
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .border {
    border-color: var(--border-color) !important;
}

[data-bs-theme="dark"] footer {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

[data-bs-theme="dark"] .category-pill-btn.bg-light {
    background-color: #182238 !important;
    color: #cbd5e1 !important;
    border-color: var(--border-color) !important;
}

[data-bs-theme="dark"] .lang-segmented-control {
    background-color: #0b1120;
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .lang-segmented-control .btn-light {
    background-color: transparent !important;
    color: var(--text-muted) !important;
}

[data-bs-theme="dark"] .ql-toolbar.ql-snow {
    background-color: #182238;
    border-color: var(--border-color) !important;
}

[data-bs-theme="dark"] .ql-container.ql-snow {
    background-color: #0b1120;
    border-color: var(--border-color) !important;
    color: #f8fafc;
}

[data-bs-theme="dark"] .ql-snow .ql-stroke {
    stroke: #cbd5e1;
}

[data-bs-theme="dark"] .ql-snow .ql-fill {
    fill: #cbd5e1;
}

[data-bs-theme="dark"] .ql-snow .ql-picker {
    color: #cbd5e1;
}

[data-bs-theme="dark"] .table {
    --bs-table-bg: var(--bg-card);
    --bs-table-color: var(--text-body);
    border-color: var(--border-color);
}

/* --------------------------------------------------------------------------
   Print-Specific Styles & Clutter Removal with Solution Buddy Credit
   -------------------------------------------------------------------------- */
.print-header,
.print-footer {
    display: none;
}

@media print {
    /* Completely hide clutter on print */
    nav,
    .navbar,
    .main-nav,
    .no-print,
    .theme-toggle-btn,
    .breadcrumb,
    .reader-action-toolbar,
    #metaBadges,
    #readingTime,
    #viewCount,
    #tagsSection,
    #relatedSection,
    footer,
    .adsbygoogle,
    ins,
    button {
        display: none !important;
    }

    /* Reset background and typography for clean paper print */
    html, body {
        background: #ffffff !important;
        background-color: #ffffff !important;
        color: #000000 !important;
        font-family: var(--font-sans);
        font-size: 11.5pt !important;
        line-height: 1.65 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    main {
        padding: 0 !important;
        margin: 0 !important;
    }

    .container, 
    .reader-wrapper, 
    .essay-container {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    /* Print Header display */
    .print-header {
        display: block !important;
        margin-bottom: 18pt !important;
    }

    .print-header img {
        width: 38px !important;
        height: 38px !important;
    }

    /* Print Footer / Credit display */
    .print-footer {
        display: block !important;
        margin-top: 24pt !important;
        page-break-inside: avoid;
    }

    .print-credit-box {
        border-top: 1.5pt solid #111827;
        padding-top: 10pt;
        text-align: center;
    }

    .credit-title {
        font-size: 10.5pt;
        font-weight: 700;
        color: #000000;
        margin-bottom: 2pt;
    }

    .credit-sub {
        font-size: 9pt;
        color: #374151;
        margin-bottom: 2pt;
    }

    .credit-copy {
        font-size: 8pt;
        color: #6b7280;
        margin-bottom: 0;
    }

    /* Article title for print */
    .article-title {
        font-size: 19pt !important;
        font-weight: 800 !important;
        color: #000000 !important;
        margin-bottom: 10pt !important;
        line-height: 1.25 !important;
    }

    /* Excerpt Box for print */
    #essayExcerptBox {
        background-color: #f8fafc !important;
        border-left: 3pt solid #000000 !important;
        border-top: none !important;
        border-right: none !important;
        border-bottom: none !important;
        padding: 8pt 12pt !important;
        margin-bottom: 14pt !important;
        color: #374151 !important;
        font-size: 10.5pt !important;
    }

    /* Article content for print */
    .essay-article {
        font-size: 11pt !important;
        line-height: 1.65 !important;
        color: #111827 !important;
    }

    .essay-article h2,
    .essay-article h3,
    .essay-article h4 {
        color: #000000 !important;
        page-break-after: avoid;
        margin-top: 12pt !important;
        margin-bottom: 4pt !important;
    }

    .essay-article p {
        margin-bottom: 8pt !important;
        text-align: justify;
    }

    .essay-article ul, 
    .essay-article ol {
        margin-bottom: 8pt !important;
        padding-left: 20pt !important;
    }

    .essay-article li {
        margin-bottom: 3pt !important;
    }

    @page {
        margin: 1.6cm 1.6cm 1.6cm 1.6cm;
    }
}
