/* ============================================================
   shared.css — Shared styles for math, ads, comments, ratings
   Imported by blog-post.html, quiz-post.html, question-set-post.html
   ============================================================ */

/* ── Content Typography Overrides ───────────────────────────── */
.post-content, .quiz-content, .qs-description, .preview-pane {
    font-family: 'Poppins', sans-serif !important;
}
.post-content p, .post-content h1, .post-content h2, .post-content h3, .post-content h4, .post-content li, .post-content td,
.quiz-content p, .quiz-content h1, .quiz-content h2, .quiz-content h3, .quiz-content h4, .quiz-content li, .quiz-content td,
.qs-description p, .qs-description li,
.preview-pane p, .preview-pane h1, .preview-pane h2, .preview-pane h3, .preview-pane li {
    font-family: 'Poppins', sans-serif;
}

/* ── KaTeX Math Rendering Overrides ─────────────────────────── */
.katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px 0;
    margin: 20px 0;
}

.katex {
    font-size: 1.1em;
}

/* Math in quiz options – prevent overflow */
.quiz-option .katex {
    font-size: 1em;
}

/* Math in content areas should be responsive */
.post-content .katex-display,
.quiz-content .katex-display,
.qs-description .katex-display {
    max-width: 100%;
    overflow-x: auto;
}

/* Inline math highlight on hover */
.katex:hover {
    background: rgba(244, 149, 26, 0.08);
    border-radius: 3px;
}

/* ── Ad Slots ────────────────────────────────────────────────── */
.ad-slot {
    background: #f8fafc;
    border: 1.5px dashed #cbd5e1;
    border-radius: 10px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s;
}

.ad-slot:hover {
    border-color: #94a3b8;
}

.ad-slot .ad-label {
    display: block;
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(148,163,184,0.15);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

/* Banner ad (728×90 equivalent) */
.ad-slot-banner {
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 24px 0;
    padding: 10px;
}

.ad-slot-banner img,
.ad-slot-banner a {
    display: block;
    width: 100%;
    max-width: 728px;
    margin: 0 auto;
}

/* Sidebar ad (300×250 equivalent) */
.ad-slot-sidebar {
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    margin-bottom: 24px;
}

/* Inline ad between content */
.ad-slot-inline {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    margin: 30px 0;
}

/* Actual ad image link */
.ad-slot a {
    display: block;
    width: 100%;
    height: 100%;
}

.ad-slot img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    margin: auto;
}

/* AdSense placeholder styling */
.ad-slot ins {
    display: block;
}

/* ── Comment Section ──────────────────────────────────────────── */
.comments-section {
    background: #f8fafc;
    border-radius: 16px;
    padding: 32px;
    margin-top: 40px;
}

.comments-section h3 {
    color: var(--primary, #1a2a4a);
    font-size: 1.3rem;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Comment form */
.comment-form {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 32px;
}

.comment-form h4 {
    color: var(--primary, #1a2a4a);
    margin-bottom: 8px;
    font-size: 1rem;
}

.comment-privacy-notice {
    background: #e0f2fe;
    border-left: 4px solid #0284c7;
    border-radius: 0 8px 8px 0;
    padding: 12px 16px;
    font-size: 0.83rem;
    color: #075985;
    margin-bottom: 18px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.comment-privacy-notice i {
    flex-shrink: 0;
    margin-top: 2px;
    color: #0284c7;
}

.rating-stars-input {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    align-items: center;
}

.rating-stars-input span {
    font-size: 0.85rem;
    color: #6c757d;
    margin-right: 4px;
}

.star-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.6rem;
    color: #d1d5db;
    transition: color 0.15s, transform 0.1s;
    padding: 0;
    line-height: 1;
}

.star-btn.active,
.star-btn:hover {
    color: #f59e0b;
    transform: scale(1.15);
}

.comment-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

.comment-form-grid .form-group:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #374151;
}

.form-group input,
.form-group textarea {
    padding: 10px 13px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    background: #fafafa;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: #f4951a;
    background: white;
}

.form-group textarea {
    resize: vertical;
    min-height: 90px;
}

.comment-contact-note {
    font-size: 0.78rem;
    color: #9ca3af;
    margin-top: -8px;
    margin-bottom: 14px;
}

.btn-submit-comment {
    padding: 11px 24px;
    background: linear-gradient(135deg, #f4951a, #e07d0a);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-submit-comment:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-submit-comment:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.comment-success {
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    color: #15803d;
    border-radius: 10px;
    padding: 14px 18px;
    font-size: 0.9rem;
    font-weight: 500;
    display: none;
    align-items: flex-start;
    gap: 10px;
    margin-top: 12px;
}

.comment-success.show {
    display: flex;
}

/* Comment list */
.comments-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comment-item {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.comment-author {
    display: flex;
    align-items: center;
    gap: 10px;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f4951a, #1a2a4a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.comment-author-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: #1a2a4a;
}

.comment-date {
    font-size: 0.75rem;
    color: #9ca3af;
}

.comment-rating-display {
    display: flex;
    gap: 2px;
}

.comment-rating-display .star {
    color: #f59e0b;
    font-size: 0.75rem;
}

.comment-rating-display .star.empty {
    color: #d1d5db;
}

.comment-body {
    color: #374151;
    font-size: 0.9rem;
    line-height: 1.7;
}

.comments-empty {
    text-align: center;
    padding: 30px;
    color: #9ca3af;
    font-size: 0.9rem;
}

/* ── Rating Summary Display ───────────────────────────────────── */
.rating-summary {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    margin-bottom: 20px;
}

.rating-big-number {
    font-size: 2.5rem;
    font-weight: 800;
    color: #f59e0b;
    line-height: 1;
}

.rating-stars-display {
    display: flex;
    gap: 3px;
    margin-bottom: 4px;
}

.rating-stars-display .star {
    color: #f59e0b;
    font-size: 1rem;
}

.rating-stars-display .star.half {
    color: #fbbf24;
}

.rating-stars-display .star.empty {
    color: #e5e7eb;
}

.rating-count {
    font-size: 0.8rem;
    color: #9ca3af;
}

/* ── Related Content Section ──────────────────────────────────── */
.related-section {
    margin-top: 48px;
    padding-top: 36px;
    border-top: 2px solid #f1f5f9;
}

.related-section h3 {
    color: var(--primary, #1a2a4a);
    font-size: 1.2rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.related-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.07);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.related-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.related-card-img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    background: linear-gradient(135deg, #1a2a4a, #f4951a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.8rem;
}

.related-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.related-card-body {
    padding: 14px;
    flex: 1;
}

.related-card-type {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #f4951a;
    margin-bottom: 5px;
}

.related-card-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #1a2a4a;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Content Filter Bar ───────────────────────────────────────── */
.content-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 28px;
    padding: 16px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.filter-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.filter-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.filter-chip {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1.5px solid #e5e7eb;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    background: none;
    color: #6c757d;
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-chip:hover {
    border-color: #f4951a;
    color: #f4951a;
}

.filter-chip.active {
    background: #1a2a4a;
    color: white;
    border-color: #1a2a4a;
}

.filter-chip.quiz.active {
    background: #7c3aed;
    border-color: #7c3aed;
}

.filter-chip.qs.active {
    background: #0284c7;
    border-color: #0284c7;
}

/* ── Difficulty Badges ────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-easy { background: #dcfce7; color: #15803d; }
.badge-medium { background: #fef3c7; color: #92400e; }
.badge-hard { background: #fee2e2; color: #991b1b; }
.badge-quiz { background: #ede9fe; color: #5b21b6; }
.badge-blog { background: #dbeafe; color: #1e40af; }
.badge-qs { background: #e0f2fe; color: #075985; }
.badge-pending { background: #ffedd5; color: #9a3412; }
.badge-published { background: #dcfce7; color: #15803d; }

/* ── Page Hero (reusable) ────────────────────────────────────── */
.content-hero {
    padding: 56px 0 40px;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.content-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.content-hero h1 {
    color: white;
    margin-bottom: 12px;
    position: relative;
}

.content-hero p {
    color: rgba(255,255,255,0.85);
    font-size: 1.05rem;
    max-width: 580px;
    margin: 0 auto 20px;
    position: relative;
}

.hero-blog { background: linear-gradient(135deg, #1a2a4a 0%, #2d4a7a 100%); }
.hero-quiz { background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 100%); }
.hero-qs   { background: linear-gradient(135deg, #0c4a6e 0%, #0284c7 100%); }

/* ── Toast Notification ──────────────────────────────────────── */
.toast-notification {
    position: fixed;
    bottom: 28px;
    right: 28px;
    padding: 14px 22px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 340px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

.toast-notification.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-notification.success { background: #16a34a; color: white; }
.toast-notification.error   { background: #dc2626; color: white; }
.toast-notification.info    { background: #0284c7; color: white; }

/* ── Mobile Responsiveness ────────────────────────────────────── */
@media (max-width: 768px) {
    .comment-form-grid {
        grid-template-columns: 1fr;
    }

    .related-grid {
        grid-template-columns: 1fr 1fr;
    }

    .content-filters {
        padding: 12px 14px;
    }

    .filter-chips {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .filter-chips::-webkit-scrollbar { display: none; }

    .comments-section {
        padding: 20px 16px;
    }

    .rating-summary {
        padding: 12px 14px;
    }
}

@media (max-width: 480px) {
    .related-grid {
        grid-template-columns: 1fr;
    }

    .ad-slot-banner {
        min-height: 60px;
    }

    .toast-notification {
        right: 14px;
        left: 14px;
        max-width: none;
    }
}

/* -- Dynamic Multi-Select Filter Panel ---------------------------- */
.filter-panel { background: white; border-radius: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); padding: 20px 22px; margin-bottom: 28px; }
.filter-panel-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.filter-panel-title { font-size: .9rem; font-weight: 700; color: #1a2a4a; display: flex; align-items: center; gap: 7px; flex: 1; }
.filter-panel-title i { color: #f4951a; }
.filter-clear-btn { background: #fee2e2; color: #dc2626; border: none; border-radius: 8px; padding: 5px 12px; font-size: .78rem; font-weight: 700; cursor: pointer; align-items: center; gap: 5px; transition: background .2s; }
.filter-clear-btn:hover { background: #dc2626; color: white; }
.filter-toggle-btn { width: 32px; height: 32px; background: #f1f5f9; border: none; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #6c757d; font-size: .8rem; transition: background .2s; }
.filter-toggle-btn:hover { background: #e2e8f0; }
.filter-groups { display: flex; flex-direction: column; gap: 14px; overflow: hidden; max-height: 3000px; transition: max-height .35s ease; }
.filter-groups.collapsed { max-height: 0; }
.filter-group { display: flex; flex-direction: column; gap: 8px; }
.filter-group-label { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: #9ca3af; display: flex; align-items: center; gap: 6px; padding-bottom: 4px; border-bottom: 1px solid #f1f5f9; }
.filter-group-label i { color: #f4951a; width: 14px; text-align: center; }
.filter-chips-wrap { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-chip-multi { padding: 5px 13px; border-radius: 20px; border: 1.5px solid #e5e7eb; font-size: .8rem; font-weight: 600; cursor: pointer; background: white; color: #6c757d; transition: all .18s; white-space: nowrap; }
.filter-chip-multi:hover { border-color: #1a2a4a; color: #1a2a4a; background: #f8fafc; }
.filter-chip-multi.active { background: #1a2a4a; color: white; border-color: #1a2a4a; box-shadow: 0 2px 6px rgba(26,42,74,.25); }
.filter-selected-summary { margin-top: 12px; padding: 6px 12px; background: #fef3c7; border-radius: 8px; font-size: .78rem; font-weight: 600; color: #92400e; }
.listing-controls { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.listing-main { min-width: 0; }
.adsense-container { width: 100%; overflow: hidden; text-align: center; }
.adsense-container ins { display: block !important; margin: 0 auto; }
@media (max-width: 960px) { .listing-controls { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .filter-panel { padding: 14px; } .filter-chip-multi { font-size: .75rem; padding: 4px 10px; } }

/* -- Floating Sharing Button for Mobile --------------------------- */
.sharing-fab {
    position: fixed;
    bottom: 95px; /* Above standard WhatsApp button position */
    right: 20px;
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #1a2a4a 0%, #2d4a7a 100%);
    color: white;
    border-radius: 50%;
    display: none; /* Shown via JS on mobile */
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 4px 15px rgba(26, 42, 74, 0.4);
    cursor: pointer;
    z-index: 999;
    border: none;
    transition: transform 0.2s, box-shadow 0.2s, background 0.3s;
}

.sharing-fab:active {
    transform: scale(0.9);
}

.sharing-fab:hover {
    background: linear-gradient(135deg, #2d4a7a 0%, #1a2a4a 100%);
}

@media (max-width: 768px) {
    .sharing-fab {
        display: flex;
    }
}
