/* ==========================================================================
   MASTER ARTICLE LIBRARY - MARKETPLACE STYLES
   Button rules use !important so the marketplace component styling always
   wins over theme / page-builder (e.g. Elementor) button styles, regardless
   of stylesheet load order.
   ========================================================================== */

/* --- Reset & Base --- */
.ql-article-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 0;
    margin: 0;
    width: 100%;
}

.ql-article-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.ql-article-card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* --- Card Image --- */
.ql-card-image {
    position: relative;
    width: 100%;
    height: 200px;
    background: #f3f4f6;
    overflow: hidden;
    flex-shrink: 0;
}

.ql-card-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ql-card-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 14px;
    background: #f9fafb;
}

.ql-card-category {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(15, 23, 42, 0.85);
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: 4px;
    backdrop-filter: blur(4px);
}

/* --- Card Body --- */
.ql-card-body {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.ql-card-title {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.4;
    color: #111827;
}

.ql-card-excerpt {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #6b7280;
    flex-grow: 1;
}

/* --- Card Footer --- */
.ql-card-footer {
    padding: 16px 20px;
    border-top: 1px solid #f3f4f6;
    display: flex;
    gap: 10px;
    align-items: center;
    background: #fafafa;
}

.ql-btn-preview {
    padding: 8px 16px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #374151 !important;
    background: #ffffff !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
}

.ql-btn-preview:hover {
    background: #f9fafb !important;
    border-color: #9ca3af !important;
    color: #111827 !important;
}

.ql-btn-edit {
    padding: 8px 16px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #0f172a !important;
    background: #ffffff !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    text-decoration: none !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
}

.ql-btn-edit.ql-show {
    display: inline-flex !important;
}

.ql-btn-edit:hover {
    background: #f0fdf4 !important;
    border-color: #4ade80 !important;
    color: #15803d !important;
}

.ql-article-card.is-claimed-card .ql-btn-edit,
.ql-article-card.is-claimed-card .ql-btn-preview {
    pointer-events: auto !important;
    opacity: 1 !important;
}

.ql-btn-select {
    flex: 1 !important;
    padding: 8px 16px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #ffffff !important;
    background: #2563eb !important;
    border: none !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
}

.ql-btn-select:hover:not(:disabled) {
    background: #1d4ed8 !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3) !important;
}

.ql-btn-select:disabled {
    background: #9ca3af !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

.ql-btn-text {
    display: inline-block !important;
}

.ql-btn-spinner {
    display: none !important;
}

/* --- Claimed / Selected States --- */
.ql-btn-select.is-claimed {
    background: #059669 !important;
    cursor: default !important;
}

.ql-btn-select.is-selected {
    background: #059669 !important;
}

.ql-btn-select.is-claimed:hover {
    background: #059669 !important;
}

/* --- Claimed Article Cards (already published to user's site) --- */
.ql-article-card.is-claimed-card {
    opacity: 0.45;
    pointer-events: none;
    cursor: not-allowed;
}

.ql-article-card.is-claimed-card:hover {
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ql-article-card.is-claimed-card .ql-btn-select {
    background: #9ca3af !important;
    cursor: not-allowed !important;
}

/* --- Marketplace Header --- */
.ql-marketplace-header {
    margin-bottom: 32px;
}

.ql-header-titles h2 {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 800;
    color: #0f172a;
}

.ql-header-titles p {
    margin: 0;
    font-size: 15px;
    color: #64748b;
    line-height: 1.5;
}

.ql-bulk-bar {
    margin-top: 20px;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 14px 20px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

/* Formidable's editor may inject <br> tags into the Before/After HTML;
   remove them so they can't break the flex layout. */
.ql-bulk-bar br,
.ql-bulk-date br {
    display: none;
}

.ql-bulk-count {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 7px 15px;
    white-space: nowrap;
    flex-shrink: 0;
}

.ql-bulk-date {
    display: none;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.ql-bulk-date-label {
    font-size: 14px;
    font-weight: 600;
    color: #334155;
}

.ql-publish-date-input {
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ql-publish-date-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.ql-btn-bulk {
    padding: 10px 22px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #ffffff !important;
    background: #0f172a !important;
    border: none !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    flex-shrink: 0;
    white-space: nowrap;
}

.ql-btn-bulk:hover:not(:disabled) {
    background: #1e293b !important;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25) !important;
}

.ql-btn-bulk:disabled {
    background: #cbd5e1 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

/* --- Hidden Article Preview (in DOM but not rendered) --- */
.ql-article-full {
    display: none !important;
}

/* --- Preview Modal --- */
.ql-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.ql-modal-content {
    background: #ffffff;
    border-radius: 12px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    position: relative;
}

.ql-modal-close {
    position: sticky;
    top: 30px;
    float: right;
    z-index: 10;
    width: 40px;
    height: 40px;
    background: var(--site-primary-color);
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 22px;
    color: #FFF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    margin: 16px 16px 0 0;
}

.ql-modal-close:hover {
    background: #f9fafb;
    color: #111827;
    border-color: #9ca3af;
}

.ql-preview-header {
    padding: 24px 32px 0;
}

.ql-preview-header h2 {
    margin: 0 0 6px 0;
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
}

.ql-preview-meta {
    display: inline-block;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 20px;
}

.ql-preview-featured {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    display: block;
    margin-bottom: 0;
}

.ql-preview-body {
    padding: 28px 32px 32px;
    font-size: 15px;
    line-height: 1.8;
    color: #374151;
}

.ql-preview-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 16px 0;
}

.ql-preview-body h1,
.ql-preview-body h2,
.ql-preview-body h3,
.ql-preview-body h4,
.ql-preview-body h5,
.ql-preview-body h6 {
    color: #0f172a;
    margin-top: 24px;
    margin-bottom: 12px;
}

.ql-preview-body p {
    margin-bottom: 16px;
}

.ql-preview-body a {
    color: #2563eb;
    text-decoration: underline;
}

.ql-preview-body blockquote {
    border-left: 4px solid #e5e7eb;
    padding-left: 16px;
    margin-left: 0;
    color: #6b7280;
    font-style: italic;
}

.ql-preview-body ul,
.ql-preview-body ol {
    margin-left: 24px;
    margin-bottom: 16px;
}

.ql-preview-body code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.ql-preview-body pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .ql-article-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .ql-marketplace-header {
        margin-bottom: 20px;
    }

    .ql-header-titles h2 {
        font-size: 22px;
    }

    .ql-bulk-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        flex-wrap: wrap;
    }

    .ql-bulk-count {
        align-self: flex-start;
    }

    .ql-bulk-date {
        flex: 1;
        min-width: 0;
        flex-wrap: wrap;
    }

    .ql-btn-bulk {
        width: 100% !important;
    }

    .ql-modal-overlay {
        padding: 20px 12px;
        align-items: flex-start;
    }

    .ql-preview-header {
        padding: 20px 20px 0;
    }

    .ql-preview-body {
        padding: 20px 20px 24px;
    }
}

/* --- Pagination --- */
.frm_pagination_cont ul.frm_pagination {
    justify-content: center;
}

.page-item a {
    text-decoration: none;
}

/* --- Message / Confirm Modal (replaces window.alert / window.confirm) --- */
.ql-msg-overlay {
    z-index: 100000;
}

.ql-msg-content {
    max-width: 460px;
    padding: 0;
}

.ql-msg-header {
    padding: 18px 24px;
    font-size: 17px;
    font-weight: 700;
    color: #0f172a;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.ql-msg-body {
    padding: 22px 24px;
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
    white-space: pre-wrap;
    word-break: break-word;
}

.ql-msg-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.ql-msg-btn {
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.ql-msg-ok,
.ql-msg-confirm {
    background: #2563eb !important;
    color: #ffffff !important;
    border-color: #2563eb !important;
}

.ql-msg-ok:hover,
.ql-msg-confirm:hover {
    background: #1d4ed8 !important;
    border-color: #1d4ed8 !important;
}

.ql-msg-cancel {
    background: #ffffff !important;
    color: #374151 !important;
    border-color: #d1d5db !important;
}

.ql-msg-cancel:hover {
    background: #f9fafb !important;
    border-color: #9ca3af !important;
}

/* --- Publish Date Modal --- */
.ql-publish-body {
    padding: 22px 24px;
}

.ql-publish-note {
    font-size: 14px;
    line-height: 1.5;
    color: #475569;
    margin: 0 0 18px 0;
}

.ql-publish-note strong {
    color: #0f172a;
}

.ql-publish-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.ql-publish-date-label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.ql-publish-body .ql-publish-date-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ql-publish-body .ql-publish-date-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.ql-msg-confirm:disabled {
    background: #cbd5e1 !important;
    border-color: #cbd5e1 !important;
    cursor: not-allowed !important;
}
