/* =====================================================================
   Product Questions Plugin — Frontend Styles
   Designed to match the Baggins mastershop theme (Montserrat, neutral palette).
   ===================================================================== */

/* ── Variables ──────────────────────────────────────────────────────── */
:root {
    --pq-font:         'Montserrat', sans-serif;
    --pq-color-text:   #1a1a1a;
    --pq-color-muted:  #888;
    --pq-color-border: #e5e5e5;
    --pq-color-bg:     #f9f9f9;
    --pq-color-accent: #1a1a1a;        /* matches Baggins dark accent */
    --pq-color-answer: #f4f9f4;
    --pq-color-error:  #d93025;
    --pq-color-success:#2d7a2d;
    --pq-radius:       6px;
    --pq-transition:   0.2s ease;
}

/* ── Wrapper ────────────────────────────────────────────────────────── */
.pq-wrap {
    font-family: var(--pq-font);
    font-size: 14px;
    color: var(--pq-color-text);
    padding: 24px 0 8px;
}

/* ── Tab count badge (in tab label) ─────────────────────────────────── */
.pq-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--pq-color-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 10px;
    vertical-align: middle;
    margin-left: 4px;
}

/* ── Header ─────────────────────────────────────────────────────────── */
.pq-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.pq-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pq-total {
    background: var(--pq-color-accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
}

.pq-subtitle {
    font-size: 13px;
    color: var(--pq-color-muted);
    margin: 0;
}

/* ── Ask Button ─────────────────────────────────────────────────────── */
.pq-ask-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--pq-color-accent);
    color: #fff;
    border: none;
    border-radius: var(--pq-radius);
    padding: 11px 20px;
    font-family: var(--pq-font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity var(--pq-transition);
    flex-shrink: 0;
}
.pq-ask-btn:hover { opacity: 0.85; }
.pq-ask-btn__icon { font-size: 18px; font-weight: 400; line-height: 1; }

/* ── Form Wrapper ───────────────────────────────────────────────────── */
.pq-form-wrap {
    background: var(--pq-color-bg);
    border: 1px solid var(--pq-color-border);
    border-radius: var(--pq-radius);
    padding: 24px;
    margin-bottom: 28px;
}

.pq-form__title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 6px;
}

.pq-form__hint {
    font-size: 13px;
    color: var(--pq-color-muted);
    margin: 0 0 20px;
}

/* ── Form Layout ────────────────────────────────────────────────────── */
.pq-form__row { display: flex; gap: 16px; }
.pq-form__row--half > .pq-form__group { flex: 1 1 0; min-width: 0; }

.pq-form__group {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}

.pq-form__label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--pq-color-text);
}

.pq-required { color: var(--pq-color-error); }
.pq-optional { font-weight: 400; color: var(--pq-color-muted); font-size: 12px; }

.pq-form__input,
.pq-form__textarea {
    font-family: var(--pq-font);
    font-size: 14px;
    border: 1px solid var(--pq-color-border);
    border-radius: var(--pq-radius);
    padding: 10px 14px;
    background: #fff;
    transition: border-color var(--pq-transition), box-shadow var(--pq-transition);
    outline: none;
    width: 100%;
    box-sizing: border-box;
    color: var(--pq-color-text);
}
.pq-form__input:focus,
.pq-form__textarea:focus {
    border-color: var(--pq-color-accent);
    box-shadow: 0 0 0 3px rgba(26,26,26,0.08);
}
.pq-form__input.is-invalid,
.pq-form__textarea.is-invalid {
    border-color: var(--pq-color-error);
}
.pq-form__textarea {
    resize: vertical;
    min-height: 100px;
}

.pq-form__counter {
    font-size: 12px;
    color: var(--pq-color-muted);
    text-align: right;
    margin-top: 4px;
}

.pq-form__error {
    font-size: 12px;
    color: var(--pq-color-error);
    margin-top: 4px;
    display: none;
}
.pq-form__error.is-visible { display: block; }

/* ── Form Footer ────────────────────────────────────────────────────── */
.pq-form__footer {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.pq-form__submit {
    background: var(--pq-color-accent);
    color: #fff;
    border: none;
    border-radius: var(--pq-radius);
    padding: 11px 24px;
    font-family: var(--pq-font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--pq-transition);
}
.pq-form__submit:hover:not(:disabled) { opacity: 0.85; }
.pq-form__submit:disabled { opacity: 0.5; cursor: default; }

.pq-form__cancel {
    background: none;
    border: 1px solid var(--pq-color-border);
    border-radius: var(--pq-radius);
    padding: 10px 20px;
    font-family: var(--pq-font);
    font-size: 14px;
    cursor: pointer;
    color: var(--pq-color-muted);
    transition: border-color var(--pq-transition), color var(--pq-transition);
}
.pq-form__cancel:hover {
    border-color: #aaa;
    color: var(--pq-color-text);
}

.pq-form__global-error {
    font-size: 13px;
    color: var(--pq-color-error);
    display: none;
}

/* ── Success State ──────────────────────────────────────────────────── */
.pq-form__success {
    text-align: center;
    padding: 24px 16px;
}
.pq-form__success-icon {
    width: 48px;
    height: 48px;
    background: var(--pq-color-success);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    margin: 0 auto 12px;
}
.pq-form__success-text {
    font-size: 14px;
    color: var(--pq-color-text);
    margin: 0 0 16px;
    line-height: 1.6;
}
.pq-form__ask-again {
    background: none;
    border: 1px solid var(--pq-color-border);
    border-radius: var(--pq-radius);
    padding: 9px 18px;
    font-family: var(--pq-font);
    font-size: 13px;
    cursor: pointer;
    color: var(--pq-color-muted);
    transition: border-color var(--pq-transition);
}
.pq-form__ask-again:hover { border-color: #aaa; }

/* ── Questions List ─────────────────────────────────────────────────── */
.pq-list { display: flex; flex-direction: column; gap: 0; }

/* ── Single Question Item ───────────────────────────────────────────── */
.pq-item {
    border-bottom: 1px solid var(--pq-color-border);
    padding: 20px 0;
}
.pq-item:last-child { border-bottom: none; }

/* Question row */
.pq-item__question {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.pq-item__q-body {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
}

.pq-item__q-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: var(--pq-color-accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    margin-top: 2px;
}

.pq-item__q-content { flex: 1; }

.pq-item__q-text {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px;
    line-height: 1.5;
    color: var(--pq-color-text);
}

.pq-item__meta {
    font-size: 12px;
    color: var(--pq-color-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.pq-item__dot { opacity: 0.4; }

/* Helpful button */
.pq-item__helpful {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.pq-item__helpful-label {
    font-size: 12px;
    color: var(--pq-color-muted);
    white-space: nowrap;
}
.pq-item__helpful-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--pq-color-border);
    border-radius: 20px;
    padding: 5px 10px;
    font-family: var(--pq-font);
    font-size: 12px;
    color: var(--pq-color-muted);
    cursor: pointer;
    transition: border-color var(--pq-transition), color var(--pq-transition), background var(--pq-transition);
}
.pq-item__helpful-btn:hover:not(.is-voted) {
    border-color: var(--pq-color-accent);
    color: var(--pq-color-accent);
}
.pq-item__helpful-btn.is-voted {
    border-color: var(--pq-color-success);
    color: var(--pq-color-success);
    cursor: default;
}
.pq-item__helpful-btn.is-loading { opacity: 0.5; cursor: wait; }

/* Answer row */
.pq-item__answer {
    margin-top: 12px;
    margin-left: 40px;
    background: var(--pq-color-answer);
    border-left: 3px solid var(--pq-color-success);
    border-radius: 0 var(--pq-radius) var(--pq-radius) 0;
    padding: 12px 16px;
}

.pq-item__a-icon {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--pq-color-success);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.pq-item__a-text {
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 6px;
    color: var(--pq-color-text);
}

.pq-item__a-date {
    font-size: 11px;
    color: var(--pq-color-muted);
}

/* Pending answer */
.pq-item__pending {
    margin-top: 10px;
    margin-left: 40px;
    font-size: 12px;
    color: var(--pq-color-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Empty State ────────────────────────────────────────────────────── */
.pq-empty {
    text-align: center;
    padding: 40px 24px;
    border: 2px dashed var(--pq-color-border);
    border-radius: var(--pq-radius);
    margin-top: 8px;
}
.pq-empty__icon {
    font-size: 36px;
    color: var(--pq-color-border);
    margin-bottom: 12px;
    line-height: 1;
}
.pq-empty__text {
    font-size: 14px;
    color: var(--pq-color-muted);
    margin: 0;
}

/* ── Load More ──────────────────────────────────────────────────────── */
.pq-loadmore-wrap {
    text-align: center;
    padding: 20px 0 8px;
}
.pq-loadmore {
    background: none;
    border: 1px solid var(--pq-color-border);
    border-radius: 24px;
    padding: 11px 28px;
    font-family: var(--pq-font);
    font-size: 14px;
    cursor: pointer;
    color: var(--pq-color-text);
    transition: border-color var(--pq-transition), background var(--pq-transition);
}
.pq-loadmore:hover { border-color: var(--pq-color-accent); background: var(--pq-color-bg); }
.pq-loadmore.is-loading { opacity: 0.6; cursor: wait; }
.pq-loadmore__count { color: var(--pq-color-muted); font-size: 12px; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .pq-header { flex-direction: column; align-items: stretch; }
    .pq-ask-btn { justify-content: center; }
    .pq-form__row--half { flex-direction: column; gap: 0; }
    .pq-item__question { flex-wrap: wrap; }
    .pq-item__helpful { margin-top: 8px; }
    .pq-item__helpful-label { display: none; }
    .pq-item__answer,
    .pq-item__pending { margin-left: 0; }
}
