/*
 * MidstreamCalculator Feedback Widget
 * All classes namespaced with `mc-fb-` to avoid collisions with site CSS.
 * Active docs: feature-specs/feedback-widget-handoff.md (2026-05-18).
 */

/* ---------- Button (fixed bottom-right FAB) ---------- */
.mc-fb-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #6366f1;
    color: #ffffff;
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
    transition: box-shadow 150ms ease, transform 100ms ease, background 150ms ease;
}

.mc-fb-btn:hover {
    background: #4f46e5;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.mc-fb-btn:active {
    transform: translateY(1px);
}

.mc-fb-btn:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.5);
}

/* Mobile: collapse to icon-only */
@media (max-width: 640px) {
    .mc-fb-btn {
        bottom: 16px;
        right: 16px;
        padding: 10px 12px;
    }
    .mc-fb-btn-text {
        display: none;
    }
}

/* ---------- Overlay backdrop ---------- */
.mc-fb-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9998;
    opacity: 0;
    transition: opacity 150ms ease;
}

.mc-fb-overlay[hidden] {
    display: none;
}

.mc-fb-overlay.mc-fb-overlay-open {
    opacity: 1;
}

/* ---------- Panel (anchored above the FAB) ---------- */
.mc-fb-panel {
    position: fixed;
    bottom: 76px;
    right: 20px;
    width: 360px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 120px);
    background: #ffffff;
    color: #111827;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    padding: 20px;
    z-index: 9999;
    transform: translateY(16px);
    opacity: 0;
    transition: transform 200ms ease-out, opacity 150ms ease-out;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
}

.mc-fb-panel[hidden] {
    display: none;
}

.mc-fb-panel.mc-fb-panel-open {
    transform: translateY(0);
    opacity: 1;
}

@media (max-width: 640px) {
    .mc-fb-panel {
        bottom: 72px;
        right: 8px;
        left: 8px;
        width: auto;
        max-width: none;
        max-height: calc(100vh - 96px);
        padding: 16px;
    }
}

/* ---------- Panel header ---------- */
.mc-fb-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.mc-fb-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.mc-fb-close {
    background: transparent;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    transition: color 100ms ease, background 100ms ease;
}

.mc-fb-close:hover {
    color: #111827;
    background: #f3f4f6;
}

/* ---------- Panel body ---------- */
.mc-fb-panel-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.mc-fb-label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 2px;
}

.mc-fb-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    font-size: 14px;
    font-family: inherit;
    color: #111827;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    resize: vertical;
    min-height: 96px;
    transition: border-color 100ms ease, box-shadow 100ms ease;
}

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

.mc-fb-textarea:disabled {
    background: #f9fafb;
    color: #6b7280;
}

.mc-fb-charcount {
    font-size: 11px;
    color: #6b7280;
    text-align: right;
}

.mc-fb-error {
    font-size: 13px;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 6px 10px;
    margin-top: 4px;
}

.mc-fb-success {
    font-size: 13px;
    color: #166534;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 8px 10px;
    margin-top: 4px;
}

/* Honeypot — visually hidden, but reachable by bots */
.mc-fb-honeypot {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: auto;
}

/* ---------- Actions ---------- */
.mc-fb-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
}

.mc-fb-btn-primary,
.mc-fb-btn-secondary {
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 100ms ease, color 100ms ease, border-color 100ms ease;
}

.mc-fb-btn-primary {
    background: #6366f1;
    color: #ffffff;
    border: 1px solid #6366f1;
}

.mc-fb-btn-primary:hover:not(:disabled) {
    background: #4f46e5;
    border-color: #4f46e5;
}

.mc-fb-btn-primary:disabled {
    background: #c7d2fe;
    border-color: #c7d2fe;
    cursor: not-allowed;
}

.mc-fb-btn-secondary {
    background: transparent;
    color: #374151;
    border: 1px solid #d1d5db;
}

.mc-fb-btn-secondary:hover {
    background: #f3f4f6;
    color: #111827;
}

/* ---------- Dark mode ---------- */
@media (prefers-color-scheme: dark) {
    .mc-fb-panel {
        background: #1f2937;
        color: #f3f4f6;
    }
    .mc-fb-title { color: #f9fafb; }
    .mc-fb-close { color: #9ca3af; }
    .mc-fb-close:hover { color: #f3f4f6; background: #374151; }
    .mc-fb-label { color: #d1d5db; }
    .mc-fb-textarea {
        background: #111827;
        color: #f3f4f6;
        border-color: #374151;
    }
    .mc-fb-textarea:focus {
        border-color: #818cf8;
        box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.25);
    }
    .mc-fb-textarea:disabled { background: #0f172a; color: #9ca3af; }
    .mc-fb-charcount { color: #9ca3af; }
    .mc-fb-error { color: #fecaca; background: #7f1d1d; border-color: #991b1b; }
    .mc-fb-success { color: #bbf7d0; background: #14532d; border-color: #166534; }
    .mc-fb-actions { border-top-color: #374151; }
    .mc-fb-btn-secondary { color: #e5e7eb; border-color: #4b5563; }
    .mc-fb-btn-secondary:hover { background: #374151; color: #f9fafb; }
}

html[data-theme="dark"] .mc-fb-panel { background: #1f2937; color: #f3f4f6; }
html[data-theme="dark"] .mc-fb-title { color: #f9fafb; }
html[data-theme="dark"] .mc-fb-close { color: #9ca3af; }
html[data-theme="dark"] .mc-fb-close:hover { color: #f3f4f6; background: #374151; }
html[data-theme="dark"] .mc-fb-label { color: #d1d5db; }
html[data-theme="dark"] .mc-fb-textarea {
    background: #111827;
    color: #f3f4f6;
    border-color: #374151;
}
html[data-theme="dark"] .mc-fb-textarea:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.25);
}
html[data-theme="dark"] .mc-fb-textarea:disabled { background: #0f172a; color: #9ca3af; }
html[data-theme="dark"] .mc-fb-charcount { color: #9ca3af; }
html[data-theme="dark"] .mc-fb-error { color: #fecaca; background: #7f1d1d; border-color: #991b1b; }
html[data-theme="dark"] .mc-fb-success { color: #bbf7d0; background: #14532d; border-color: #166534; }
html[data-theme="dark"] .mc-fb-actions { border-top-color: #374151; }
html[data-theme="dark"] .mc-fb-btn-secondary { color: #e5e7eb; border-color: #4b5563; }
html[data-theme="dark"] .mc-fb-btn-secondary:hover { background: #374151; color: #f9fafb; }
