/* ==========================================================================
   FV Feedback Widget - Styles
   Scoped to #fv-feedback-widget to avoid conflicts
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties (scoped)
   -------------------------------------------------------------------------- */
#fv-feedback-widget {
    --fvf-primary: #2563eb;
    --fvf-primary-hover: #1d4ed8;
    --fvf-primary-light: #eff6ff;
    --fvf-success: #16a34a;
    --fvf-success-light: #f0fdf4;
    --fvf-error: #dc2626;
    --fvf-error-light: #fef2f2;
    --fvf-warning: #f59e0b;
    --fvf-text: #1f2937;
    --fvf-text-secondary: #4b5563;
    --fvf-muted: #6b7280;
    --fvf-border: #e5e7eb;
    --fvf-border-focus: #93c5fd;
    --fvf-bg: #ffffff;
    --fvf-bg-hover: #f9fafb;
    --fvf-bg-active: #f3f4f6;
    --fvf-radius: 6px;
    --fvf-radius-lg: 12px;
    --fvf-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --fvf-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.1);
    --fvf-shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.2);
    --fvf-transition: 0.2s ease;
    --fvf-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* --------------------------------------------------------------------------
   Floating Trigger Button
   -------------------------------------------------------------------------- */
#fv-feedback-widget .fvf-trigger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--fvf-primary);
    color: #fff;
    cursor: pointer;
    box-shadow: var(--fvf-shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--fvf-transition), box-shadow var(--fvf-transition), background var(--fvf-transition);
    padding: 0;
    outline: none;
    font-family: var(--fvf-font);
}

#fv-feedback-widget .fvf-trigger:hover {
    transform: scale(1.08);
    box-shadow: var(--fvf-shadow-xl);
    background: var(--fvf-primary-hover);
}

#fv-feedback-widget .fvf-trigger:focus-visible {
    outline: 2px solid var(--fvf-primary);
    outline-offset: 2px;
}

#fv-feedback-widget .fvf-trigger:active {
    transform: scale(0.96);
}

#fv-feedback-widget .fvf-trigger svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --------------------------------------------------------------------------
   Overlay
   -------------------------------------------------------------------------- */
#fv-feedback-widget .fvf-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

#fv-feedback-widget .fvf-overlay.fvf-open {
    opacity: 1;
    visibility: visible;
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
#fv-feedback-widget .fvf-modal {
    background: var(--fvf-bg);
    border-radius: var(--fvf-radius-lg);
    box-shadow: var(--fvf-shadow-xl);
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    transform: translateY(20px) scale(0.97);
    transition: transform 0.25s ease;
    font-family: var(--fvf-font);
    color: var(--fvf-text);
    font-size: 14px;
    line-height: 1.5;
}

#fv-feedback-widget .fvf-overlay.fvf-open .fvf-modal {
    transform: translateY(0) scale(1);
}

/* Modal scrollbar styling */
#fv-feedback-widget .fvf-modal::-webkit-scrollbar {
    width: 6px;
}

#fv-feedback-widget .fvf-modal::-webkit-scrollbar-thumb {
    background: var(--fvf-border);
    border-radius: 3px;
}

/* --------------------------------------------------------------------------
   Modal Header
   -------------------------------------------------------------------------- */
#fv-feedback-widget .fvf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--fvf-border);
}

#fv-feedback-widget .fvf-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

#fv-feedback-widget .fvf-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: var(--fvf-muted);
    cursor: pointer;
    border-radius: var(--fvf-radius);
    padding: 0;
    flex-shrink: 0;
    transition: color var(--fvf-transition), background var(--fvf-transition);
}

#fv-feedback-widget .fvf-back-btn:hover {
    color: var(--fvf-text);
    background: var(--fvf-bg-hover);
}

#fv-feedback-widget .fvf-back-btn.fvf-visible {
    display: flex;
}

#fv-feedback-widget .fvf-back-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#fv-feedback-widget .fvf-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--fvf-text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#fv-feedback-widget .fvf-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: var(--fvf-muted);
    cursor: pointer;
    border-radius: var(--fvf-radius);
    padding: 0;
    flex-shrink: 0;
    transition: color var(--fvf-transition), background var(--fvf-transition);
}

#fv-feedback-widget .fvf-close-btn:hover {
    color: var(--fvf-text);
    background: var(--fvf-bg-hover);
}

#fv-feedback-widget .fvf-close-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --------------------------------------------------------------------------
   Modal Body
   -------------------------------------------------------------------------- */
#fv-feedback-widget .fvf-body {
    padding: 20px;
}

/* --------------------------------------------------------------------------
   Step 1: Type Selection Cards
   -------------------------------------------------------------------------- */
#fv-feedback-widget .fvf-type-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

#fv-feedback-widget .fvf-type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    border: 1px solid var(--fvf-border);
    border-radius: var(--fvf-radius-lg);
    background: var(--fvf-bg);
    cursor: pointer;
    transition: border-color var(--fvf-transition), background var(--fvf-transition), box-shadow var(--fvf-transition);
    text-align: center;
    font-family: var(--fvf-font);
    font-size: 13px;
    color: var(--fvf-text-secondary);
    font-weight: 500;
    line-height: 1.3;
}

#fv-feedback-widget .fvf-type-card:hover {
    border-color: var(--fvf-primary);
    background: var(--fvf-primary-light);
    box-shadow: 0 0 0 1px var(--fvf-primary);
}

#fv-feedback-widget .fvf-type-card:focus-visible {
    outline: 2px solid var(--fvf-primary);
    outline-offset: 2px;
}

#fv-feedback-widget .fvf-type-card svg {
    width: 28px;
    height: 28px;
    stroke: var(--fvf-primary);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* Last card (odd) spans full width */
#fv-feedback-widget .fvf-type-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

/* --------------------------------------------------------------------------
   Step 2: Smart Form
   -------------------------------------------------------------------------- */
#fv-feedback-widget .fvf-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#fv-feedback-widget .fvf-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#fv-feedback-widget .fvf-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--fvf-text);
}

#fv-feedback-widget .fvf-label .fvf-required {
    color: var(--fvf-error);
    margin-left: 2px;
}

#fv-feedback-widget .fvf-input,
#fv-feedback-widget .fvf-textarea,
#fv-feedback-widget .fvf-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--fvf-border);
    border-radius: var(--fvf-radius);
    background: var(--fvf-bg);
    color: var(--fvf-text);
    font-family: var(--fvf-font);
    font-size: 14px;
    line-height: 1.5;
    transition: border-color var(--fvf-transition), box-shadow var(--fvf-transition);
    outline: none;
    box-sizing: border-box;
}

#fv-feedback-widget .fvf-input::placeholder,
#fv-feedback-widget .fvf-textarea::placeholder {
    color: var(--fvf-muted);
}

#fv-feedback-widget .fvf-input:focus,
#fv-feedback-widget .fvf-textarea:focus,
#fv-feedback-widget .fvf-select:focus {
    border-color: var(--fvf-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

#fv-feedback-widget .fvf-input.fvf-error,
#fv-feedback-widget .fvf-textarea.fvf-error {
    border-color: var(--fvf-error);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

#fv-feedback-widget .fvf-error-text {
    font-size: 12px;
    color: var(--fvf-error);
    margin-top: 2px;
}

#fv-feedback-widget .fvf-textarea {
    resize: vertical;
    min-height: 80px;
}

#fv-feedback-widget .fvf-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   NPS Rating Row
   -------------------------------------------------------------------------- */
#fv-feedback-widget .fvf-nps-row {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

#fv-feedback-widget .fvf-nps-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 4px;
}

#fv-feedback-widget .fvf-nps-labels span {
    font-size: 11px;
    color: var(--fvf-muted);
}

#fv-feedback-widget .fvf-nps-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--fvf-border);
    background: var(--fvf-bg);
    color: var(--fvf-text-secondary);
    font-family: var(--fvf-font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--fvf-transition);
    padding: 0;
    flex-shrink: 0;
}

#fv-feedback-widget .fvf-nps-btn:hover {
    border-color: var(--fvf-muted);
    background: var(--fvf-bg-hover);
}

/* NPS color states when selected */
#fv-feedback-widget .fvf-nps-btn.fvf-selected.fvf-nps-detractor {
    background: var(--fvf-error);
    border-color: var(--fvf-error);
    color: #fff;
}

#fv-feedback-widget .fvf-nps-btn.fvf-selected.fvf-nps-passive {
    background: var(--fvf-warning);
    border-color: var(--fvf-warning);
    color: #fff;
}

#fv-feedback-widget .fvf-nps-btn.fvf-selected.fvf-nps-promoter {
    background: var(--fvf-success);
    border-color: var(--fvf-success);
    color: #fff;
}

/* --------------------------------------------------------------------------
   Screenshot Attachment Section
   -------------------------------------------------------------------------- */
#fv-feedback-widget .fvf-screenshot-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: none;
    background: none;
    color: var(--fvf-primary);
    font-family: var(--fvf-font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--fvf-transition);
}

#fv-feedback-widget .fvf-screenshot-toggle:hover {
    color: var(--fvf-primary-hover);
}

#fv-feedback-widget .fvf-screenshot-toggle svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform var(--fvf-transition);
}

#fv-feedback-widget .fvf-screenshot-toggle.fvf-expanded svg {
    transform: rotate(90deg);
}

#fv-feedback-widget .fvf-screenshot-section {
    display: none;
    margin-top: 8px;
}

#fv-feedback-widget .fvf-screenshot-section.fvf-visible {
    display: block;
}

#fv-feedback-widget .fvf-dropzone {
    position: relative;
    border: 2px dashed var(--fvf-border);
    border-radius: var(--fvf-radius);
    height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--fvf-muted);
    font-size: 13px;
    cursor: pointer;
    transition: border-color var(--fvf-transition), background var(--fvf-transition);
}

#fv-feedback-widget .fvf-dropzone:hover,
#fv-feedback-widget .fvf-dropzone.fvf-dragover {
    border-color: var(--fvf-primary);
    background: var(--fvf-primary-light);
}

#fv-feedback-widget .fvf-dropzone svg {
    width: 24px;
    height: 24px;
    stroke: var(--fvf-muted);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#fv-feedback-widget .fvf-dropzone-link {
    color: var(--fvf-primary);
    font-weight: 500;
}

#fv-feedback-widget .fvf-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Screenshot Preview */
#fv-feedback-widget .fvf-preview {
    display: none;
    position: relative;
    border: 1px solid var(--fvf-border);
    border-radius: var(--fvf-radius);
    overflow: hidden;
    background: var(--fvf-bg-hover);
}

#fv-feedback-widget .fvf-preview.fvf-visible {
    display: block;
}

#fv-feedback-widget .fvf-preview img {
    display: block;
    width: 100%;
    max-height: 160px;
    object-fit: contain;
    background: var(--fvf-bg-hover);
}

#fv-feedback-widget .fvf-preview-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background var(--fvf-transition);
}

#fv-feedback-widget .fvf-preview-remove:hover {
    background: rgba(0, 0, 0, 0.8);
}

#fv-feedback-widget .fvf-preview-remove svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --------------------------------------------------------------------------
   Modal Footer / Actions
   -------------------------------------------------------------------------- */
#fv-feedback-widget .fvf-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--fvf-border);
}

#fv-feedback-widget .fvf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--fvf-radius);
    font-family: var(--fvf-font);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    transition: all var(--fvf-transition);
    border: 1px solid transparent;
    white-space: nowrap;
}

#fv-feedback-widget .fvf-btn:focus-visible {
    outline: 2px solid var(--fvf-primary);
    outline-offset: 2px;
}

#fv-feedback-widget .fvf-btn-primary {
    background: var(--fvf-primary);
    color: #fff;
    border-color: var(--fvf-primary);
}

#fv-feedback-widget .fvf-btn-primary:hover {
    background: var(--fvf-primary-hover);
    border-color: var(--fvf-primary-hover);
}

#fv-feedback-widget .fvf-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#fv-feedback-widget .fvf-btn-secondary {
    background: var(--fvf-bg);
    color: var(--fvf-text-secondary);
    border-color: var(--fvf-border);
}

#fv-feedback-widget .fvf-btn-secondary:hover {
    background: var(--fvf-bg-hover);
    border-color: var(--fvf-muted);
}

/* Spinner inside button */
#fv-feedback-widget .fvf-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: fvf-spin 0.6s linear infinite;
}

@keyframes fvf-spin {
    to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Success State
   -------------------------------------------------------------------------- */
#fv-feedback-widget .fvf-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    gap: 12px;
}

#fv-feedback-widget .fvf-success-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--fvf-success-light);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fvf-scale-in 0.4s ease;
}

#fv-feedback-widget .fvf-success-icon svg {
    width: 28px;
    height: 28px;
    stroke: var(--fvf-success);
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    animation: fvf-checkmark 0.5s ease 0.2s forwards;
}

@keyframes fvf-scale-in {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes fvf-checkmark {
    to { stroke-dashoffset: 0; }
}

#fv-feedback-widget .fvf-success-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--fvf-text);
    margin: 0;
}

#fv-feedback-widget .fvf-success-text {
    font-size: 14px;
    color: var(--fvf-muted);
    margin: 0;
}

/* --------------------------------------------------------------------------
   Error Message (inline)
   -------------------------------------------------------------------------- */
#fv-feedback-widget .fvf-error-banner {
    display: none;
    padding: 10px 14px;
    background: var(--fvf-error-light);
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: var(--fvf-radius);
    color: var(--fvf-error);
    font-size: 13px;
    line-height: 1.4;
}

#fv-feedback-widget .fvf-error-banner.fvf-visible {
    display: block;
}

/* --------------------------------------------------------------------------
   Toast Notification
   -------------------------------------------------------------------------- */
#fv-feedback-widget .fvf-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 10001;
    background: #1f2937;
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-family: var(--fvf-font);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--fvf-shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    white-space: nowrap;
    pointer-events: none;
}

#fv-feedback-widget .fvf-toast.fvf-toast-show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* --------------------------------------------------------------------------
   Responsive: Small screens (< 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    #fv-feedback-widget .fvf-modal {
        max-width: 100%;
        border-radius: var(--fvf-radius-lg) var(--fvf-radius-lg) 0 0;
        max-height: 85vh;
    }

    #fv-feedback-widget .fvf-overlay {
        align-items: flex-end;
        padding: 0;
    }

    #fv-feedback-widget .fvf-overlay.fvf-open .fvf-modal {
        transform: translateY(0);
    }

    #fv-feedback-widget .fvf-modal {
        transform: translateY(100%);
    }

    #fv-feedback-widget .fvf-nps-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

@media (max-width: 360px) {
    #fv-feedback-widget .fvf-type-grid {
        grid-template-columns: 1fr;
    }

    #fv-feedback-widget .fvf-body {
        padding: 16px;
    }

    #fv-feedback-widget .fvf-header {
        padding: 12px 16px;
    }

    #fv-feedback-widget .fvf-footer {
        padding: 12px 16px;
    }
}
