/* ==========================================================
   WMI Feedback Widget
   BEM: wmifb__*
   Based on designer reference (Designer-Feedback-Widget.css)
   ========================================================== */
:root {
    --wmifb-primary: #1e40af;
    --wmifb-bg: #ffffff;
    --wmifb-text: #1f2937;
    --wmifb-text-muted: #6b7280;
    --wmifb-border: #e5e7eb;
    --wmifb-danger: #b91c1c;
    --wmifb-success: #15803d;
    --wmifb-radius: 8px;
}

/* ── Tab ──────────────────────────────────────────────── */
.wmifb__tab {
    position: fixed;
    right: 0;
    top: 50%;
    margin-top: -60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 30px;
    padding: 14px 6px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #fff;
    background: var(--wmifb-primary);
    border: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    opacity: 0.75;
    z-index: 9998;
    writing-mode: vertical-lr;
    text-orientation: mixed;
    overflow: hidden;
    transition: opacity 0.25s, width 0.25s;
}
.wmifb__tab:hover { opacity: 1; width: 40px; }
.wmifb__tab svg,
.wmifb__tab span {
    flex-shrink: 0;
}
.wmifb__tab:focus-visible { outline: 2px solid #fff; outline-offset: -2px; opacity: 1; }
.wmifb__tab svg { width: 16px; height: 16px; flex-shrink: 0; }
.wmifb--open .wmifb__tab { display: none; }

/* ── Panel ────────────────────────────────────────────── */
.wmifb__panel {
    position: fixed;
    right: -340px;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
    max-height: 80vh;
    background: var(--wmifb-bg);
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    border-radius: 12px 0 0 12px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    overflow-y: auto;
}
.wmifb--open .wmifb__panel { right: 0; }

/* ── Header ───────────────────────────────────────────── */
.wmifb__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--wmifb-border);
    flex-shrink: 0;
}
.wmifb__title { font-size: 0.9rem; font-weight: 600; color: var(--wmifb-text); margin: 0; }
.wmifb__close {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border: none; background: transparent;
    border-radius: 6px; cursor: pointer; color: var(--wmifb-text-muted);
    transition: background 0.12s, color 0.12s;
}
.wmifb__close:hover { background: #f3f4f6; color: var(--wmifb-text); }

/* ── Form ─────────────────────────────────────────────── */
.wmifb__form { padding: 10px 14px 14px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.wmifb__subtitle { font-size: 0.78rem; color: var(--wmifb-text-muted); margin: 0; }

/* Type selection */
.wmifb__types { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.wmifb__type {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 8px; border: 1px solid var(--wmifb-border);
    border-radius: 6px; cursor: pointer;
    font-size: 0.75rem; color: var(--wmifb-text);
    transition: border-color 0.15s, background 0.15s;
}
.wmifb__type:hover { background: #f9fafb; }
.wmifb__type input { position: absolute; opacity: 0; width: 0; height: 0; }
.wmifb__type:has(input:checked) { border-color: var(--wmifb-primary); background: #eff6ff; }
.wmifb__type-badge {
    width: 20px; height: 20px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700; flex-shrink: 0;
}
.wmifb__type--bug .wmifb__type-badge { background: #fee2e2; color: #b91c1c; }
.wmifb__type--idea .wmifb__type-badge { background: #fef3c7; color: #d97706; }
.wmifb__type--question .wmifb__type-badge { background: #dbeafe; color: #2563eb; }
.wmifb__type--praise .wmifb__type-badge { background: #dcfce7; color: #15803d; }

/* Sender fields (anonymous) */
.wmifb__sender { display: flex; flex-direction: column; gap: 8px; }
.wmifb__input {
    width: 100%; padding: 7px 10px; font-family: inherit; font-size: 0.8rem;
    border: 1px solid var(--wmifb-border); border-radius: var(--wmifb-radius);
    background: #fff; color: var(--wmifb-text); box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.wmifb__input:focus { border-color: var(--wmifb-primary); box-shadow: 0 0 0 3px rgba(30,64,175,0.1); outline: none; }
.wmifb__input::placeholder { color: var(--wmifb-text-muted); }

/* Textarea */
.wmifb__textarea {
    width: 100%; padding: 8px 10px; font-family: inherit; font-size: 0.8rem;
    line-height: 1.4; color: var(--wmifb-text);
    border: 1px solid var(--wmifb-border); border-radius: 6px;
    resize: vertical; min-height: 50px; box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.wmifb__textarea:focus { border-color: var(--wmifb-primary); box-shadow: 0 0 0 3px rgba(30,64,175,0.1); outline: none; }
.wmifb__textarea::placeholder { color: var(--wmifb-text-muted); }

/* Page context indicator */
.wmifb__page-context {
    display: flex; align-items: center; gap: 4px;
    font-size: 0.7rem; color: var(--wmifb-text-muted);
    padding: 4px 8px; background: #f9fafb; border-radius: 4px;
}
.wmifb__page-context svg { flex-shrink: 0; opacity: 0.6; }

/* Actions */
.wmifb__actions { display: flex; gap: 6px; }
.wmifb__btn {
    flex: 1; padding: 8px 12px; font-family: inherit; font-size: 0.78rem;
    font-weight: 600; border-radius: var(--wmifb-radius); cursor: pointer;
    border: none; transition: background 0.12s, box-shadow 0.12s;
}
.wmifb__btn--submit {
    background: var(--wmifb-primary); color: #fff;
}
.wmifb__btn--submit:hover { filter: brightness(0.9); }
.wmifb__btn--submit:disabled { background: #93c5fd; cursor: not-allowed; }
.wmifb__btn--cancel { background: #f3f4f6; color: var(--wmifb-text); }
.wmifb__btn--cancel:hover { background: #e5e7eb; }

/* Error message */
.wmifb__error {
    color: var(--wmifb-danger); font-size: 0.8rem; text-align: center; margin: 0;
}

/* ── Success state ────────────────────────────────────── */
.wmifb__success { text-align: center; padding: 48px 20px; }
.wmifb__success-icon {
    width: 56px; height: 56px; margin: 0 auto 16px;
    background: #dcfce7; color: var(--wmifb-success);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
}
.wmifb__success-text { font-size: 0.9rem; color: var(--wmifb-text); font-weight: 500; }

/* ── Overlay ──────────────────────────────────────────── */
.wmifb__overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.3); z-index: 9998;
}
.wmifb--open .wmifb__overlay { display: none; } /* Desktop: no overlay */

/* ── Mobile (< 768px) ────────────────────────────────── */
@media (max-width: 767px) {
    .wmifb__tab {
        top: auto; bottom: 0; right: 16px;
        transform: none; border-radius: 6px 6px 0 0;
    }
    .wmifb__panel {
        right: 0; left: 0; top: auto; bottom: 0;
        width: 100%; max-height: 85vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    }
    .wmifb--open .wmifb__panel { transform: translateY(0); }
    .wmifb--open .wmifb__overlay { display: block; }
    .wmifb__types { grid-template-columns: 1fr 1fr; }
}

/* ── Accessibility ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .wmifb__panel, .wmifb__tab { transition: none; }
}
