/**
 * Annazer Public Typography & Content Styling System
 * Ensures premium readability, modern spacing, and dynamic light/dark mode compatibility
 * for all rich content edited in PublicSiteCMS.
 */

.public-content-rendered,
.ql-editor-content {
    font-family: var(--Cairo-font, 'Cairo', system-ui, sans-serif);
    font-size: 1.05rem;
    line-height: 1.88;
    color: var(--text-color, #1f2937);
    word-break: break-word;
}

[data-theme="dark"] .public-content-rendered,
[data-theme="dark"] .ql-editor-content {
    color: #e2e8f0;
}

/* Headings Hierarchy */
.public-content-rendered h1,
.ql-editor-content h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-top: 2.2rem;
    margin-bottom: 1.2rem;
    line-height: 1.35;
    color: var(--title-color, #0f172a);
}

.public-content-rendered h2,
.ql-editor-content h2 {
    font-size: 1.65rem;
    font-weight: 750;
    margin-top: 2rem;
    margin-bottom: 1rem;
    line-height: 1.4;
    color: var(--primary-color, #2563eb);
    position: relative;
    padding-bottom: 0.45rem;
}

.public-content-rendered h2::after,
.ql-editor-content h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color, #2563eb), transparent);
    border-radius: 3px;
}

[dir="ltr"] .public-content-rendered h2::after,
[dir="ltr"] .ql-editor-content h2::after {
    right: auto;
    left: 0;
}

.public-content-rendered h3,
.ql-editor-content h3 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-top: 1.7rem;
    margin-bottom: 0.85rem;
    color: var(--title-color, #1e293b);
}

.public-content-rendered h4,
.ql-editor-content h4 {
    font-size: 1.18rem;
    font-weight: 650;
    margin-top: 1.4rem;
    margin-bottom: 0.75rem;
}

[data-theme="dark"] .public-content-rendered h1,
[data-theme="dark"] .public-content-rendered h3,
[data-theme="dark"] .public-content-rendered h4,
[data-theme="dark"] .ql-editor-content h1,
[data-theme="dark"] .ql-editor-content h3,
[data-theme="dark"] .ql-editor-content h4 {
    color: #f8fafc;
}

[data-theme="dark"] .public-content-rendered h2,
[data-theme="dark"] .ql-editor-content h2 {
    color: #60a5fa;
}

/* Paragraphs & Text Flow */
.public-content-rendered p,
.ql-editor-content p {
    margin-bottom: 1.25rem;
    line-height: 1.9;
}

.public-content-rendered p:last-child,
.ql-editor-content p:last-child {
    margin-bottom: 0;
}

/* Bold & Emphasis */
.public-content-rendered strong,
.public-content-rendered b,
.ql-editor-content strong,
.ql-editor-content b {
    font-weight: 700;
    color: inherit;
}

/* Blockquotes & Callouts */
.public-content-rendered blockquote,
.ql-editor-content blockquote {
    margin: 1.75rem 0;
    padding: 1.25rem 1.65rem;
    border-right: 4px solid var(--primary-color, #3b82f6);
    border-left: none;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 12px;
    font-size: 1.08rem;
    font-weight: 500;
    line-height: 1.8;
    color: var(--text-color, #334155);
    position: relative;
}

[dir="ltr"] .public-content-rendered blockquote,
[dir="ltr"] .ql-editor-content blockquote {
    border-left: 4px solid var(--primary-color, #3b82f6);
    border-right: none;
}

[data-theme="dark"] .public-content-rendered blockquote,
[data-theme="dark"] .ql-editor-content blockquote {
    background: rgba(59, 130, 246, 0.12);
    color: #e2e8f0;
}

/* Lists styling */
.public-content-rendered ul,
.public-content-rendered ol,
.ql-editor-content ul,
.ql-editor-content ol {
    margin: 1.25rem 0;
    padding-right: 1.75rem;
    padding-left: 0;
}

[dir="ltr"] .public-content-rendered ul,
[dir="ltr"] .public-content-rendered ol,
[dir="ltr"] .ql-editor-content ul,
[dir="ltr"] .ql-editor-content ol {
    padding-left: 1.75rem;
    padding-right: 0;
}

.public-content-rendered li,
.ql-editor-content li {
    margin-bottom: 0.65rem;
    line-height: 1.8;
}

/* Links */
.public-content-rendered a,
.ql-editor-content a {
    color: var(--primary-color, #2563eb);
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 600;
    transition: color 0.2s ease;
}

.public-content-rendered a:hover,
.ql-editor-content a:hover {
    color: var(--primary-hover, #1d4ed8);
}

[data-theme="dark"] .public-content-rendered a,
[data-theme="dark"] .ql-editor-content a {
    color: #60a5fa;
}

[data-theme="dark"] .public-content-rendered a:hover,
[data-theme="dark"] .ql-editor-content a:hover {
    color: #93c5fd;
}

/* Media, Images, and Figures */
.public-content-rendered img,
.ql-editor-content img {
    max-width: 100%;
    height: auto;
    border-radius: 14px;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
    margin: 1.5rem auto;
    display: block;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

[data-theme="dark"] .public-content-rendered img,
[data-theme="dark"] .ql-editor-content img {
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Tables in Content */
.public-content-rendered table,
.ql-editor-content table {
    width: 100%;
    margin: 1.75rem 0;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background-color: var(--card-bg, #ffffff);
}

[data-theme="dark"] .public-content-rendered table,
[data-theme="dark"] .ql-editor-content table {
    border-color: rgba(255, 255, 255, 0.1);
    background-color: rgba(30, 41, 59, 0.5);
}

.public-content-rendered th,
.ql-editor-content th {
    background-color: rgba(59, 130, 246, 0.08);
    color: var(--text-color, #0f172a);
    font-weight: 700;
    padding: 12px 18px;
    text-align: right;
    border-bottom: 2px solid rgba(0, 0, 0, 0.06);
}

[dir="ltr"] .public-content-rendered th,
[dir="ltr"] .ql-editor-content th {
    text-align: left;
}

[data-theme="dark"] .public-content-rendered th,
[data-theme="dark"] .ql-editor-content th {
    background-color: rgba(59, 130, 246, 0.15);
    color: #f1f5f9;
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.public-content-rendered td,
.ql-editor-content td {
    padding: 12px 18px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .public-content-rendered td,
[data-theme="dark"] .ql-editor-content td {
    border-top-color: rgba(255, 255, 255, 0.06);
}

.public-content-rendered tr:nth-child(even) td,
.ql-editor-content tr:nth-child(even) td {
    background-color: rgba(0, 0, 0, 0.015);
}

[data-theme="dark"] .public-content-rendered tr:nth-child(even) td,
[data-theme="dark"] .ql-editor-content tr:nth-child(even) td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Quill formatting classes support */
.ql-container.ql-snow {
    font-size: 1rem;
    font-family: inherit;
    min-height: 220px;
    background: #ffffff;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}
.ql-toolbar.ql-snow {
    background: #f8fafc;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}
.ql-editor {
    min-height: 200px;
    font-size: 1rem;
    line-height: 1.7;
}
.ql-align-center {
    text-align: center !important;
}

.ql-align-right {
    text-align: right !important;
}

.ql-align-left {
    text-align: left !important;
}

.ql-align-justify {
    text-align: justify !important;
}

.ql-direction-rtl {
    direction: rtl !important;
    text-align: right;
}

.ql-size-small {
    font-size: 0.85rem !important;
}

.ql-size-large {
    font-size: 1.35rem !important;
}

.ql-size-huge {
    font-size: 1.75rem !important;
}

/* Callout utility styles for cards embedded in content */
.content-callout {
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.content-callout-info {
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: #0369a1;
}

[data-theme="dark"] .content-callout-info {
    color: #7dd3fc;
}

.content-callout-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #15803d;
}

[data-theme="dark"] .content-callout-success {
    color: #86efac;
}

.content-callout-warning {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.3);
    color: #a16207;
}

[data-theme="dark"] .content-callout-warning {
    color: #fde047;
}

/* Print Styles */
@media print {
    .public-content-rendered,
    .ql-editor-content {
        color: #000000 !important;
        background: transparent !important;
        font-size: 12pt !important;
        line-height: 1.6 !important;
    }
    
    .public-content-rendered a,
    .ql-editor-content a {
        text-decoration: underline !important;
        color: #000000 !important;
    }
}
