/* Article Content (Rich Text HTML) Styling */
.article-content {
    line-height: 1.8;
    font-size: 1.05rem;
}

/* CRITICAL: Preserve display properties for grid layouts */
.article-content > div {
    /* Don't force block display on all divs */
}

.article-content h1 {
    font-size: 2rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.article-content h2 {
    font-size: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.article-content h3 {
    font-size: 1.25rem;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.article-content p {
    margin-bottom: 1rem;
}

.article-content ul,
.article-content ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.article-content li {
    margin-bottom: 0.5rem;
}

/* Inline code styling */
.article-content code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.95em;
    color: #c7254e;
}

/* Code blocks with Prism.js */
.article-content pre {
    background-color: #2d2d2d !important;
    padding: 0 !important;
    border-radius: 8px;
    overflow: hidden;
    margin: 1rem 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.article-content pre[class*="language-"] {
    margin: 1rem 0;
    padding: 1rem;
    overflow: auto;
    border-radius: 8px;
}

.article-content pre code {
    background-color: transparent !important;
    padding: 0 !important;
    border-radius: 0 !important;
    color: inherit !important;
    font-size: 0.95em;
    line-height: 1.6;
    display: block;
}

/* Line numbers styling */
.article-content pre.line-numbers {
    padding-left: 3.8em;
    position: relative;
}

.article-content pre.line-numbers > code {
    position: relative;
    white-space: pre;
}

/* Prism toolbar */
.article-content div.code-toolbar {
    margin: 1rem 0;
}

.article-content div.code-toolbar > .toolbar {
    opacity: 1;
}

.article-content div.code-toolbar > .toolbar button {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
}

.article-content div.code-toolbar > .toolbar button:hover {
    background: #e0e0e0;
}

/* Language badge */
.article-content pre[class*="language-"]::before {
    content: attr(class);
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 2px 8px;
    font-size: 0.75em;
    border-bottom-left-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.article-content blockquote {
    border-left: 4px solid #1976d2;
    padding-left: 1rem;
    margin-left: 0;
    margin-bottom: 1rem;
    font-style: italic;
    color: #666;
}

.article-content a {
    color: #1976d2;
    text-decoration: underline;
}

.article-content a:hover {
    color: #1565c0;
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.article-content table th,
.article-content table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.article-content table th {
    background-color: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.article-content table tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Video Embed Styling */
.article-content video {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: block;
}

.article-content iframe {
    max-width: 100%;
    margin: 1rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Responsive video container for embedded videos (YouTube, Vimeo) */
.article-content .video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    margin: 1rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.article-content .video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
}

/* Collapsible Sections Styling */
.article-content details {
    margin: 1rem 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.article-content details[open] {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.article-content details summary {
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    cursor: pointer;
    font-weight: 600;
    font-size: 1.05rem;
    user-select: none;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    position: relative;
}

.article-content details summary:hover {
    background: linear-gradient(135deg, #eeeeee 0%, #e0e0e0 100%);
}

.article-content details summary::marker {
    display: none;
    content: '';
}

.article-content details summary::-webkit-details-marker {
    display: none;
}

.article-content details summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.75rem;
    transition: transform 0.3s ease;
    color: #1976d2;
    font-size: 0.85em;
}

.article-content details[open] summary::before {
    transform: rotate(90deg);
}

.article-content details .details-content {
    padding: 1.25rem;
    background-color: #fafafa;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Collapsible section variants */
.article-content details.info {
    border-color: #1976d2;
}

.article-content details.info summary {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #0d47a1;
}

.article-content details.info summary:hover {
    background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
}

.article-content details.info summary::before {
    color: #1976d2;
}

.article-content details.info .details-content {
    background-color: #f3f9ff;
}

.article-content details.success {
    border-color: #4caf50;
}

.article-content details.success summary {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: #1b5e20;
}

.article-content details.success summary:hover {
    background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
}

.article-content details.success summary::before {
    color: #4caf50;
}

.article-content details.success .details-content {
    background-color: #f1f8f1;
}

.article-content details.warning {
    border-color: #ff9800;
}

.article-content details.warning summary {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    color: #e65100;
}

.article-content details.warning summary:hover {
    background: linear-gradient(135deg, #ffe0b2 0%, #ffcc80 100%);
}

.article-content details.warning summary::before {
    color: #ff9800;
}

.article-content details.warning .details-content {
    background-color: #fffaf3;
}

.article-content details.danger {
    border-color: #f44336;
}

.article-content details.danger summary {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    color: #b71c1c;
}

.article-content details.danger summary:hover {
    background: linear-gradient(135deg, #ffcdd2 0%, #ef9a9a 100%);
}

.article-content details.danger summary::before {
    color: #f44336;
}

.article-content details.danger .details-content {
    background-color: #fff5f5;
}

/* Nested collapsible sections */
.article-content details details {
    margin: 0.75rem 0;
    border-width: 1px;
}

.article-content details details summary {
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

.article-content details details .details-content {
    padding: 1rem;
}

/* Callout Boxes / Alert Blocks */
.article-content .callout {
    padding: 1.25rem 1.25rem 1.25rem 3.5rem;
    margin: 1.5rem 0;
    border-radius: 8px;
    border-left: 5px solid;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.article-content .callout:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.article-content .callout::before {
    position: absolute;
    left: 1.25rem;
    top: 1.25rem;
    font-size: 1.5rem;
    line-height: 1;
}

.article-content .callout > *:first-child {
    margin-top: 0;
}

.article-content .callout > *:last-child {
    margin-bottom: 0;
}

.article-content .callout strong:first-child,
.article-content .callout b:first-child {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

/* Callout Variants */

/* Info Callout (Blue) */
.article-content .callout-info {
    background-color: #e3f2fd;
    border-left-color: #1976d2;
    color: #0d47a1;
}

.article-content .callout-info::before {
    content: 'ℹ️';
}

/* Tip Callout (Teal/Cyan) */
.article-content .callout-tip {
    background-color: #e0f7fa;
    border-left-color: #00acc1;
    color: #006064;
}

.article-content .callout-tip::before {
    content: '💡';
}

/* Success Callout (Green) */
.article-content .callout-success {
    background-color: #e8f5e9;
    border-left-color: #4caf50;
    color: #1b5e20;
}

.article-content .callout-success::before {
    content: '✅';
}

/* Warning Callout (Orange) */
.article-content .callout-warning {
    background-color: #fff3e0;
    border-left-color: #ff9800;
    color: #e65100;
}

.article-content .callout-warning::before {
    content: '⚠️';
}

/* Danger Callout (Red) */
.article-content .callout-danger {
    background-color: #ffebee;
    border-left-color: #f44336;
    color: #b71c1c;
}

.article-content .callout-danger::before {
    content: '🚨';
}

/* Note Callout (Purple) */
.article-content .callout-note {
    background-color: #f3e5f5;
    border-left-color: #9c27b0;
    color: #4a148c;
}

.article-content .callout-note::before {
    content: '📝';
}

/* Question Callout (Indigo) */
.article-content .callout-question {
    background-color: #e8eaf6;
    border-left-color: #3f51b5;
    color: #1a237e;
}

.article-content .callout-question::before {
    content: '❓';
}

/* Example Callout (Amber) */
.article-content .callout-example {
    background-color: #fff8e1;
    border-left-color: #ffc107;
    color: #ff6f00;
}

.article-content .callout-example::before {
    content: '📋';
}

/* Quote Callout (Gray) */
.article-content .callout-quote {
    background-color: #f5f5f5;
    border-left-color: #757575;
    color: #424242;
}

.article-content .callout-quote::before {
    content: '💬';
}

/* Callout with custom titles */
.article-content .callout-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* Callout links */
.article-content .callout a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}

.article-content .callout a:hover {
    opacity: 0.8;
}

/* Callout lists */
.article-content .callout ul,
.article-content .callout ol {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.article-content .callout li {
    margin-bottom: 0.25rem;
}

/* Callout code blocks */
.article-content .callout code {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Callout in dark backgrounds - adjust for better readability */
.article-content .callout pre {
    background-color: rgba(0, 0, 0, 0.05) !important;
    margin: 0.75rem 0;
}

/* Compact callout variant */
.article-content .callout-compact {
    padding: 0.75rem 0.75rem 0.75rem 3rem;
    margin: 1rem 0;
}

.article-content .callout-compact::before {
    left: 0.75rem;
    top: 0.75rem;
    font-size: 1.25rem;
}

/* Tag System Styling */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.75rem;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    border-radius: 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #424242;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    text-decoration: none;
}

.tag-chip:hover {
    background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(25, 118, 210, 0.3);
}

.tag-chip-small {
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
}

.tag-chip-large {
    padding: 0.6rem 1rem;
    font-size: 1rem;
}

.tag-chip-active {
    background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
    color: white;
    border-color: #1976d2;
}

.tag-chip-count {
    margin-left: 0.4rem;
    padding: 0.1rem 0.4rem;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    font-size: 0.75em;
}

.tag-chip-active .tag-chip-count {
    background-color: rgba(255, 255, 255, 0.2);
}

/* ==========================================
   GRID LAYOUTS FROM BLOCK EDITOR
   ========================================== */

/* Base grid container with classes (NEW) */
.article-content .kb-grid {
    display: grid !important;
    gap: 20px;
    margin: 20px 0;
}

/* Two column layout */
.article-content .kb-grid-2col {
    grid-template-columns: 1fr 1fr !important;
}

/* Three column layout */
.article-content .kb-grid-3col {
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 15px;
}

/* Sidebar layout (2:1 ratio) */
.article-content .kb-grid-sidebar {
    grid-template-columns: 2fr 1fr !important;
}

/* Grid item styling */
.article-content .kb-grid-item {
    padding: 20px;
    background-color: #f5f5f5;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.article-content .kb-grid-3col .kb-grid-item {
    padding: 15px;
}

/* Sidebar specific styling */
.article-content .kb-grid-aside {
    background-color: #e8e8e8;
}

/* FALLBACK: Support OLD inline-style layouts too */
.article-content > div[style*="display: grid"],
.article-content > div[style*="display:grid"] {
    display: grid !important;
}

/* Force grid template columns for OLD content */
.article-content > div[style*="grid-template-columns: 1fr 1fr;"],
.article-content > div[style*="grid-template-columns:1fr 1fr;"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
}

.article-content > div[style*="grid-template-columns: 1fr 1fr 1fr;"],
.article-content > div[style*="grid-template-columns:1fr 1fr 1fr;"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
}

.article-content > div[style*="grid-template-columns: 2fr 1fr;"],
.article-content > div[style*="grid-template-columns:2fr 1fr;"] {
    display: grid !important;
    grid-template-columns: 2fr 1fr !important;
}

/* Force gap for OLD content */
.article-content > div[style*="gap: 20px"],
.article-content > div[style*="gap:20px"] {
    gap: 20px !important;
}

.article-content > div[style*="gap: 15px"],
.article-content > div[style*="gap:15px"] {
    gap: 15px !important;
}

/* Style the children of grid containers */
.article-content > div[style*="display: grid"] > div,
.article-content > div[style*="display:grid"] > div {
    /* These are the grid items */
}

/* Mobile responsiveness for grid layouts */
@media (max-width: 768px) {
    .article-content .kb-grid-2col,
    .article-content .kb-grid-3col,
    .article-content .kb-grid-sidebar {
        grid-template-columns: 1fr !important;
    }

    /* OLD inline-style content */
    .article-content > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}

/* Dark mode support */
body.mud-theme-dark .article-content .kb-grid-item {
    background-color: #2d2d2d;
    color: #e0e0e0;
}

body.mud-theme-dark .article-content .kb-grid-aside {
    background-color: #252525;
}

/* Dark mode for OLD inline-style content */
body.mud-theme-dark .article-content > div[style*="display: grid"] > div[style*="background-color"] {
    background-color: #2d2d2d !important;
    color: #e0e0e0 !important;
}




/* Tag input styling */
.tag-input-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    min-height: 50px;
    background-color: #fafafa;
}

.tag-input-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    background-color: #1976d2;
    color: white;
    border-radius: 14px;
    font-size: 0.875rem;
}

.tag-input-chip button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.tag-input-chip button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 0.25rem;
}

.tag-suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f5f5f5;
}

.tag-suggestion-item:last-child {
    border-bottom: none;
}

.tag-suggestion-item:hover {
    background-color: #f5f5f5;
}

.tag-suggestion-count {
    color: #757575;
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

/* Tag cloud sizing based on popularity */
.tag-size-xs {
    font-size: 0.75rem;
    opacity: 0.7;
}

.tag-size-sm {
    font-size: 0.875rem;
    opacity: 0.8;
}

.tag-size-md {
    font-size: 1rem;
    opacity: 0.9;
}

.tag-size-lg {
    font-size: 1.125rem;
    opacity: 1;
}

.tag-size-xl {
    font-size: 1.25rem;
    opacity: 1;
    font-weight: 600;
}

/* Mobile responsive tags */
@media (max-width: 600px) {
    .tag-cloud {
        gap: 0.4rem;
    }

    .tag-chip {
        font-size: 0.8125rem;
        padding: 0.35rem 0.65rem;
    }

    .tag-chip-large {
        font-size: 0.9375rem;
        padding: 0.5rem 0.85rem;
    }
}
