/* ==========================================================================
   Quote Feature — frontend styles.
   Reuses CSS variables from theme. NEVER hardcode colors (Rule 5 CLAUDE.md).
   ========================================================================== */

/* -----------------------------------------
 * Tab body / shell
 * ----------------------------------------- */
.mq-tab-body {
    padding: 20px 0;
}

.mq-tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mq-tab-intro {
    margin: 0;
    font-size: 14px;
    color: #bfbfbf;
}

.mq-sort-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mq-sort-label {
    font-size: 13px;
    color: #bfbfbf;
    margin: 0;
}

.mq-sort-select {
    background: #1a1a1a;
    color: #f5f5f5;
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.mq-loading {
    padding: 40px 0;
    text-align: center;
    color: #888;
    font-size: 14px;
}

.mq-empty-state {
    padding: 60px 20px;
    text-align: center;
    color: #888;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
}

/* -----------------------------------------
 * "My Pending Quotes" section
 * ----------------------------------------- */
.mq-pending-section {
    margin-bottom: 24px;
}

.mq-section-title {
    font-size: 15px;
    font-weight: 600;
    color: #f5f5f5;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mq-section-icon {
    font-size: 16px;
}

.mq-pending-card {
    background: color-mix(in srgb, var(--madara-main-color, #eb3349) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--madara-main-color, #eb3349) 30%, transparent);
    border-radius: 6px;
    padding: 14px 16px;
    margin-bottom: 10px;
}

.mq-quote-text-pending {
    margin: 0;
    padding: 8px 14px;
    font-style: italic;
    color: #e8e8e8;
    border-left: 3px solid var(--madara-main-color, #eb3349);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0 4px 4px 0;
    font-size: 14px;
    line-height: 1.55;
}

/* v2.5.56: ONE shared border = the .mq-group-card outline. The blockquote
   is borderless + background-less; sections inside the card are split by
   thin theme-color divider lines. Authoritative copy is the inline CSS in
   reading-chapter-styles.php (rule 13). */
.mq-quote-text {
    margin: 0;
    padding: 2px 0 0 0;
    font-style: italic;
    color: #e8e8e8;
    background: transparent;
    font-size: 14px;
    line-height: 1.55;
}

.mq-chapter-label {
    margin: 0;
    padding: 6px 0 0 0;
    font-size: 12px;
    color: #888;
}

.mq-chapter-label a {
    color: var(--madara-main-color, #eb3349);
    text-decoration: none;
}

.mq-chapter-label a:hover {
    text-decoration: underline;
}

.mq-pending-badge {
    margin-top: 8px;
}

.mq-badge {
    display: inline-block;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.mq-badge-pending {
    background: color-mix(in srgb, var(--madara-main-color, #eb3349) 25%, transparent);
    color: color-mix(in srgb, var(--madara-main-color, #eb3349) 70%, #fff);
    border: 1px solid color-mix(in srgb, var(--madara-main-color, #eb3349) 40%, transparent);
}

.mq-pending-commentary {
    margin-top: 10px;
    font-size: 13px;
    color: #d0d0d0;
    line-height: 1.5;
}

.mq-pending-commentary-label {
    font-weight: 600;
    color: #999;
    margin-right: 4px;
}

.mq-pending-divider {
    margin: 18px 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

/* -----------------------------------------
 * Group card — horizontal slider (rule 38: same visual language as
 * #mr-reviews-list). Each card is a fixed-width slide, user swipes
 * horizontally to see the next quote. Replies are collapsed by default
 * (.mq-replies-panel[hidden]) so card height stays uniform.
 * ----------------------------------------- */
.mq-groups-list {
    display: flex;
    flex-direction: row;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 12px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}
.mq-groups-list::-webkit-scrollbar { height: 4px; }
.mq-groups-list::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
}
.mq-groups-list::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--madara-main-color, #eb3349) 40%, transparent);
    border-radius: 2px;
}

.mq-group-card {
    background: rgba(255, 255, 255, 0.02);
    /* v2.5.57: border matches the comment-compose box (theme 25%). */
    border: 1px solid color-mix(in srgb, var(--madara-main-color, #eb3349) 25%, transparent);
    border-radius: 8px;
    padding: 14px 16px;
    min-width: 300px;
    max-width: 340px;
    flex-shrink: 0;
    scroll-snap-align: start;
    box-sizing: border-box;
}
.mq-group-card:only-child {
    min-width: 100%;
    max-width: 100%;
}
@media (max-width: 600px) {
    .mq-group-card {
        min-width: 260px;
        max-width: 300px;
    }
    .mq-group-card:only-child {
        min-width: 100%;
        max-width: 100%;
    }
}

/* Replies panel — hidden by default; expanded on .mq-replies-toggle click */
.mq-replies-panel[hidden] { display: none !important; }
.mq-replies-panel:not([hidden]) { padding: 0; }
/* v2.5.57: third section inside the card. Divider above it is an inset
   ::before line (see reading-chapter-styles.php) — not edge-to-edge. */
.mq-replies-toggle {
    position: relative;
    background: transparent;
    border: none;
    color: color-mix(in srgb, var(--madara-main-color, #eb3349) 80%, #fff);
    font-size: 13px;
    cursor: pointer;
    padding: 14px 0 0 0;
    margin: 14px 0 0 0;
    display: flex;
    width: 100%;
    align-items: center;
    gap: 6px;
}
.mq-group-meta::before,
.mq-replies-toggle::before {
    content: "";
    position: absolute;
    top: 0;
    left: 10px;
    right: 10px;
    height: 1px;
    background: color-mix(in srgb, var(--madara-main-color, #eb3349) 35%, transparent);
}
.mq-replies-toggle-icon {
    display: inline-block;
    transition: transform 0.15s ease;
}
.mq-replies-toggle[aria-expanded="true"] .mq-replies-toggle-icon {
    transform: rotate(90deg);
}

/* Scroll hint — hiển thị "Swipe →" khi có nhiều hơn 1 slide.
   Ẩn tự động khi user đã scroll (qua .has-scrolled class set bằng JS). */
.mq-groups-slider-wrap { position: relative; }
.mq-scroll-hint {
    display: none;
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    background: color-mix(in srgb, var(--madara-main-color, #eb3349) 75%, #000);
    color: #fff;
    padding: 6px 10px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    pointer-events: none;
    z-index: 2;
    animation: mq-hint-pulse 1.6s ease-in-out infinite;
}
.mq-groups-slider-wrap.has-multi:not(.has-scrolled) .mq-scroll-hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
@keyframes mq-hint-pulse {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    50%      { transform: translateY(-50%) translateX(4px); }
}

.mq-group-meta {
    position: relative;
    margin: 14px 0 0 0;
    padding: 14px 0 0 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mq-group-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: color-mix(in srgb, var(--madara-main-color, #eb3349) 70%, #fff);
    font-weight: 600;
}

.mq-group-count-num {
    color: var(--madara-main-color, #eb3349);
    font-weight: 700;
}

.mq-group-count-icon {
    font-size: 14px;
}

.mq-group-commentaries {
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* -----------------------------------------
 * Commentary item (inside group)
 * ----------------------------------------- */
.mq-commentary {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.mq-commentary-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: block;
}

.mq-commentary-body {
    flex: 1;
    min-width: 0;
}

.mq-commentary-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 3px;
}

.mq-commentary-author {
    font-size: 13px;
    font-weight: 600;
    color: #f5f5f5;
}

.mq-commentary-date {
    font-size: 11px;
    color: #888;
}

.mq-commentary-text {
    font-size: 13px;
    color: #d0d0d0;
    line-height: 1.55;
    word-wrap: break-word;
}

.mq-commentary-votes {
    margin-top: 6px;
    display: flex;
    gap: 10px;
}

.mq-vote-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #999;
    padding: 3px 10px;
    font-size: 12px;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.mq-vote-btn:hover {
    border-color: color-mix(in srgb, var(--madara-main-color, #eb3349) 50%, transparent);
    color: #f5f5f5;
}

.mq-vote-btn.voted {
    background: color-mix(in srgb, var(--madara-main-color, #eb3349) 15%, transparent);
    border-color: color-mix(in srgb, var(--madara-main-color, #eb3349) 60%, transparent);
    color: color-mix(in srgb, var(--madara-main-color, #eb3349) 80%, #fff);
}

.mq-vote-btn .icon {
    font-size: 13px;
}

.mq-vote-count {
    font-weight: 600;
    min-width: 10px;
    text-align: center;
}

/* -----------------------------------------
 * Floating "Quote this" popup
 * ----------------------------------------- */
/* v1.5.38 — RESTORED về position:absolute (cách work cho 1 word + 1 đoạn
   trên mobile từ v1.5.24 trở về trước). */
.mq-selection-popup {
    position: absolute;
    z-index: 9998;
    background: var(--madara-main-color, #eb3349);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transform: translateX(-50%);
}

.mq-selection-popup.visible {
    display: inline-flex;
}

.mq-selection-popup:hover {
    filter: brightness(1.1);
}

.mq-selection-popup::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--madara-main-color, #eb3349);
}

.mq-selection-popup-icon {
    font-size: 14px;
}

/* -----------------------------------------
 * Submit modal
 * ----------------------------------------- */
.mq-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 15px 15px;
    overflow-y: auto;
}

.mq-modal-overlay.visible {
    display: flex;
}

.mq-modal {
    background: #141414;
    color: #f5f5f5;
    border-radius: 8px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.mq-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mq-modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #f5f5f5;
}

.mq-modal-close {
    background: transparent;
    border: 0;
    color: #999;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.mq-modal-close:hover {
    color: #f5f5f5;
}

.mq-modal-body {
    padding: 16px 18px;
}

.mq-modal-label {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 6px;
    font-weight: 600;
}

.mq-modal-required {
    color: var(--madara-main-color, #eb3349);
    margin-left: 2px;
}

.mq-modal-passage {
    margin: 0 0 16px;
    padding: 10px 14px;
    font-style: italic;
    font-size: 14px;
    color: #e8e8e8;
    border-left: 3px solid var(--madara-main-color, #eb3349);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0 4px 4px 0;
    max-height: 140px;
    overflow-y: auto;
    line-height: 1.55;
}

.mq-modal-thoughts {
    width: 100%;
    min-height: 100px;
    background: #0d0d0d;
    color: #f5f5f5;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    font-family: inherit;
}

.mq-modal-thoughts:focus {
    outline: none;
    border-color: var(--madara-main-color, #eb3349);
}

.mq-modal-counter {
    font-size: 12px;
    color: #888;
    margin-top: 6px;
}

.mq-modal-counter.error {
    color: #e74c3c;
}

.mq-modal-error {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(231, 76, 60, 0.12);
    border: 1px solid rgba(231, 76, 60, 0.35);
    color: #e74c3c;
    border-radius: 4px;
    font-size: 13px;
    display: none;
}

.mq-modal-error.visible {
    display: block;
}

.mq-modal-footer {
    padding: 12px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.mq-modal-btn {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.mq-modal-btn-cancel {
    background: transparent;
    color: #bfbfbf;
    border-color: rgba(255, 255, 255, 0.15);
}

.mq-modal-btn-cancel:hover {
    color: #f5f5f5;
    border-color: rgba(255, 255, 255, 0.3);
}

.mq-modal-btn-submit {
    background: var(--madara-main-color, #eb3349);
    color: #fff;
    border-color: var(--madara-main-color, #eb3349);
}

.mq-modal-btn-submit:hover:not(:disabled) {
    filter: brightness(1.1);
}

.mq-modal-btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* -----------------------------------------
 * Toast (success message after submit)
 * ----------------------------------------- */
.mq-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--madara-main-color, #eb3349);
    color: #fff;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 100001;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.mq-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* -----------------------------------------
 * Mobile fallback: "Quote this paragraph" button injected into inline-comment panel
 * ----------------------------------------- */
/* v1.4.71: đồng bộ visual language với .cmt-spoiler-mark — cùng padding,
   border-radius, font-size, line-height để 2 nút đứng cạnh nhau trong
   .cmt-spoiler-ctrl nhìn đồng nhất (rule 38). */
.mq-inline-quote-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 12px;
    line-height: 1.2;
    background: transparent;
    color: color-mix(in srgb, var(--madara-main-color, #eb3349) 70%, #fff);
    border: 1px solid color-mix(in srgb, var(--madara-main-color, #eb3349) 35%, transparent);
    border-radius: 4px;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}

.mq-inline-quote-trigger:hover {
    background: color-mix(in srgb, var(--madara-main-color, #eb3349) 12%, transparent);
}

/* -----------------------------------------
 * v1.5.41 — Lightning badge ("NEW feature") + one-time guide popup
 * ----------------------------------------- */
/* Tia sét nhấp nháy trong nút inline + tiêu đề hộp hướng dẫn. */
.mq-bolt,
.mq-guide-bolt {
    display: inline-flex;
    align-items: center;
    color: var(--madara-main-color, #eb3349);
    animation: mq-bolt-blink 1.1s ease-in-out infinite;
}

.mq-bolt {
    font-size: 13px;
}

.mq-guide-bolt {
    font-size: 18px;
    margin-right: 2px;
}

@keyframes mq-bolt-blink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.35; transform: scale(0.82); }
}

/* Nút inline "Quote this" MỚI — viền + glow nhẹ pulse để thu hút mắt. */
.mq-inline-quote-trigger.mq-inline-quote-new {
    border-color: color-mix(in srgb, var(--madara-main-color, #eb3349) 55%, transparent);
    animation: mq-new-pulse 1.8s ease-in-out infinite;
}

@keyframes mq-new-pulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--madara-main-color, #eb3349) 35%, transparent); }
    50%      { box-shadow: 0 0 6px 1px color-mix(in srgb, var(--madara-main-color, #eb3349) 45%, transparent); }
}

/* Tôn trọng người dùng tắt animation (accessibility). */
@media (prefers-reduced-motion: reduce) {
    .mq-bolt,
    .mq-guide-bolt,
    .mq-inline-quote-trigger.mq-inline-quote-new {
        animation: none;
    }
}

/* Nội dung text trong hộp hướng dẫn — đồng bộ với .mq-modal-passage
   (rule 38): cùng tông chữ, line-height dễ đọc. Dùng selector + wildcard
   để thắng rule màu chữ bare-element của theme (rule 11). */
.mq-guide-text,
.mq-guide-text * {
    color: #e8e8e8 !important;
}
.mq-guide-text {
    font-size: 14px;
    line-height: 1.65;
}

/* -----------------------------------------
 * Responsive
 * ----------------------------------------- */
@media (max-width: 767px) {
    .mq-tab-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .mq-modal {
        max-width: 100%;
    }
    .mq-modal-body {
        padding: 14px;
    }
    .mq-group-card {
        padding: 12px 14px;
    }
}

/* Light mode override (reading page light mode) */
body.reading-light-mode .mq-quote-text,
body.reading-light-mode .mq-quote-text-pending {
    background: rgba(0, 0, 0, 0.04);
    color: #2a2a2a;
}
body.reading-light-mode .mq-commentary-text,
body.reading-light-mode .mq-pending-commentary {
    color: #3a3a3a;
}
body.reading-light-mode .mq-commentary-author,
body.reading-light-mode .mq-section-title {
    color: #1a1a1a;
}
