/* ============================================
   FEEDBACK MODAL (lazy-loaded, v22.10-feedback-fab)
   ============================================ */

.feedback-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: feedbackFadeIn 0.18s ease;
}

@keyframes feedbackFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.feedback-modal {
    background: var(--bg-secondary, #1a1d29);
    color: var(--text-primary, #e5e7eb);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.1));
    border-radius: 12px;
    padding: 24px;
    width: 95%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: feedbackSlideUp 0.22s ease;
}

@keyframes feedbackSlideUp {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

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

.feedback-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.feedback-modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary, #9ca3af);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s;
}

.feedback-modal-close:hover {
    color: var(--text-primary, #e5e7eb);
}

.feedback-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.feedback-modal-row {
    display: flex;
    gap: 12px;
}

.feedback-modal-row > .feedback-field {
    flex: 1;
    min-width: 0;
}

.feedback-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #cbd5e1);
}

.feedback-field input,
.feedback-field select,
.feedback-field textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.feedback-field textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

.feedback-field input:focus,
.feedback-field select:focus,
.feedback-field textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.feedback-field-hint {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted, #6b7280);
}

.feedback-context-preview {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
    line-height: 1.5;
    word-break: break-word;
}

.feedback-context-preview strong {
    color: var(--text-secondary, #cbd5e1);
    margin-right: 4px;
}

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

.feedback-modal-footer .feedback-btn-primary,
.feedback-modal-footer .feedback-btn-secondary {
    padding: 9px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.15s, opacity 0.15s;
}

.feedback-btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
}

.feedback-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #4f46e5, #4338ca);
}

.feedback-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.feedback-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #e5e7eb);
}

.feedback-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.14);
}

.feedback-modal-error {
    padding: 10px 12px;
    background: rgba(239, 68, 68, 0.10);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    color: #fca5a5;
    font-size: 13px;
}

.feedback-modal-success {
    padding: 10px 12px;
    background: rgba(34, 197, 94, 0.10);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 6px;
    color: #86efac;
    font-size: 13px;
}

/* ============================================
   FLOATING FAB (Feedback button bottom-right)
   ============================================ */

/* ============================================
   STICKY FEEDBACK SIDE TAB (right edge, vertical text)
   ============================================ */

/* Wrapper anchors the tab to the right edge near the bottom — close
   to the ANALYSIS & REPORT panel area in the simulator layout. Anchor
   by `bottom` (absolute distance from viewport bottom) rather than
   `top: 50%` (vertical center) so the tab keeps its relationship with
   the analytics panel across screen heights. Holds two siblings:
   the tab button + a dismiss-X (nested <button> would be invalid HTML). */
.feedback-fab-wrapper {
    position: fixed;
    right: 0;
    /* 130px clears the ANALYSIS & REPORT panel header which sits at
       the bottom of the right column (~80px tall). Earlier 90px
       partially overlapped the panel. */
    bottom: 130px;
    width: 32px;
    height: 130px;
    z-index: 998;  /* below modals (10000) and demo banner (999) */
}

.feedback-fab {
    width: 100%;
    height: 100%;
    /* Border-radius is set in PRE-rotation coordinates: top-right +
       bottom-right rounded (right edge). After `transform: rotate(180deg)`
       below, the visual result is the LEFT edge rounded (top-left +
       bottom-left in screen coordinates) — i.e. the side that faces the
       page content. Using `8px 0 0 8px` here would put the rounding on
       the page-edge side after rotation, where it gets clipped by the
       viewport boundary and isn't visible. */
    border-radius: 0 8px 8px 0;
    /* Indigo accent so the tab stands out on both light and dark themes —
       dim opacity makes it unobtrusive while staying readable. */
    background: #4f46e5;
    border: none;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Vertical text reading bottom-to-top (typical "side tab" affordance):
       writing-mode rotates the inline axis 90°; rotate(180deg) flips so
       the baseline is on the page edge, head reads upward. */
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 12px 0;
    opacity: 0.7;
    /* Combined transform: 180° rotation for bottom-to-top text PLUS a
       translateX that we animate on hover. Hover moves the tab INWARD
       (translateX(6px) — applied AFTER rotate(180deg) so the visual
       direction is toward the page center, not off-screen). Growing
       the width from 32→38 instead would extend the tab off the right
       edge of the viewport (wrapper is anchored at right:0), making
       the affordance invisible and risking horizontal overflow. */
    transform: rotate(180deg);
    transition: opacity 0.18s, transform 0.18s, background 0.15s;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.18);
    /* Hint to the AT layer that this is a button despite the rotation */
    -webkit-appearance: none;
    appearance: none;
}

.feedback-fab-wrapper:hover .feedback-fab,
.feedback-fab:focus-visible {
    opacity: 1;
    background: #4338ca;
    /* translateX(6px) AFTER rotate(180deg) = visual leftward shift
       (into the page), giving a visible slide-out without changing
       layout width. */
    transform: rotate(180deg) translateX(6px);
}

.feedback-fab:focus-visible {
    outline: 2px solid #fbbf24;
    outline-offset: -2px;
}

/* Tiny dismiss-X stuck to the top-left corner of the tab.
   Hover-capable devices: hidden until parent hover.
   Touch devices: always visible (see @media hover:none below). */
.feedback-fab-dismiss {
    position: absolute;
    top: 0;
    left: 0;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, background 0.15s;
}

.feedback-fab-wrapper:hover .feedback-fab-dismiss,
.feedback-fab-dismiss:focus-visible {
    opacity: 1;
    pointer-events: auto;
}

.feedback-fab-dismiss:hover {
    background: rgba(239, 68, 68, 0.85);
}

/* Touch / no-hover devices — keep dismiss visible since there's no
   hover state to reveal it. Slightly dimmed so it doesn't dominate. */
@media (hover: none) {
    .feedback-fab-dismiss {
        opacity: 0.85;
        pointer-events: auto;
    }
}

/* ============================================
   LIGHT THEME OVERRIDES
   ============================================ */
[data-theme="light"] .feedback-modal {
    background: #ffffff;
    color: #1f2937;
    border-color: #e5e7eb;
}

[data-theme="light"] .feedback-modal-header h3 {
    color: #1f2937;
}

[data-theme="light"] .feedback-field input,
[data-theme="light"] .feedback-field select,
[data-theme="light"] .feedback-field textarea {
    background: #f9fafb;
    color: #1f2937;
    border-color: #d1d5db;
}

[data-theme="light"] .feedback-context-preview {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #6b7280;
}

/* Side tab keeps the same indigo branding on light theme so it's
   immediately visible against any page background — was the
   white-on-white bug of the original FAB on the light theme. */
[data-theme="light"] .feedback-fab {
    background: #4f46e5;
    color: #ffffff;
    box-shadow: -2px 0 8px rgba(79, 70, 229, 0.25);
}

[data-theme="light"] .feedback-fab-wrapper:hover .feedback-fab,
[data-theme="light"] .feedback-fab:focus-visible {
    background: #4338ca;
}

[data-theme="light"] .feedback-modal-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

[data-theme="light"] .feedback-modal-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #15803d;
}

/* ============================================
   MOBILE — tab stays on the right edge but smaller
   ============================================ */
@media (max-width: 600px) {
    .feedback-modal {
        width: 100%;
        max-width: none;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .feedback-modal-row {
        flex-direction: column;
        gap: 14px;
    }

    .feedback-fab-wrapper {
        width: 28px;
        height: 110px;
        bottom: 100px;  /* lift mobile too so it clears any bottom panel */
    }

    .feedback-fab {
        font-size: 11px;
        letter-spacing: 1.2px;
    }
}
