/* ===================================
   FEEDBACK WIDGET STYLES
   Floating widget + Post-test modal
   =================================== */

/* ===================================
   FLOATING FEEDBACK BUTTON
   =================================== */
.feedback-float-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 18px;
    background: linear-gradient(135deg, #2563EB, #1D4ED8);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    animation: feedbackPulse 2s ease-in-out infinite;
}

.feedback-float-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(37, 99, 235, 0.5);
    animation: none;
}

.feedback-float-btn i {
    color: white;
    font-size: 1rem;
}

.feedback-float-btn .feedback-label {
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

@keyframes feedbackPulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(37, 99, 235, 0.6); }
}

/* ===================================
   PAGE BLUR FOR MANDATORY FEEDBACK
   =================================== */
body.feedback-blur-active > *:not(.feedback-overlay):not(.feedback-modal):not(script):not(style) {
    filter: blur(8px);
    pointer-events: none;
    user-select: none;
}

body.feedback-blur-active .feedback-overlay,
body.feedback-blur-active .feedback-modal {
    filter: none !important;
    pointer-events: auto !important;
}

/* Shake animation for mandatory feedback */
@keyframes feedbackShake {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-50%, -50%) scale(1) translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translate(-50%, -50%) scale(1) translateX(5px); }
}

.feedback-modal.shake {
    animation: feedbackShake 0.5s ease;
}

/* ===================================
   FEEDBACK MODAL OVERLAY
   =================================== */
.feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9995;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.feedback-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===================================
   FEEDBACK MODAL
   =================================== */
.feedback-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: white;
    border-radius: 14px;
    width: 94%;
    max-width: 560px;
    max-height: none;
    overflow: visible;
    z-index: 9996;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.feedback-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.feedback-modal-header {
    background: linear-gradient(135deg, #2563EB, #1D4ED8);
    color: white;
    padding: 0.85rem 1.25rem;
    border-radius: 14px 14px 0 0;
    text-align: center;
    position: relative;
}

.feedback-modal-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.feedback-modal-header p {
    margin: 0.2rem 0 0;
    font-size: 0.8rem;
    opacity: 0.9;
}

.feedback-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.feedback-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.feedback-modal-body {
    padding: 1rem 1.25rem;
}

/* ===================================
   FEEDBACK TYPE SELECTOR
   =================================== */
.feedback-type-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.9rem;
}

.feedback-type-btn {
    padding: 0.4rem 0.5rem;
    border: 2px solid #E2E8F0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748B;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

.feedback-type-btn i {
    font-size: 0.95rem;
}

.feedback-type-btn:hover {
    border-color: #2563EB;
    color: #2563EB;
}

.feedback-type-btn.active {
    background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
    border-color: #2563EB;
    color: #2563EB;
}

/* ===================================
   EMOJI RATING
   =================================== */
.feedback-rating-section {
    margin-bottom: 0.9rem;
}

.feedback-rating-section label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.4rem;
}

.emoji-rating {
    display: flex;
    justify-content: space-between;
    gap: 0.35rem;
}

.emoji-btn {
    flex: 1;
    padding: 0.4rem 0.3rem;
    border: 2px solid #E2E8F0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.4rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.emoji-btn span {
    font-size: 0.55rem;
    color: #94A3B8;
    font-weight: 500;
}

.emoji-btn:hover {
    transform: scale(1.1);
    border-color: #2563EB;
}

.emoji-btn.selected {
    background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
    border-color: #2563EB;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

/* ===================================
   FEEDBACK TAGS
   =================================== */
.feedback-tags-section {
    margin-bottom: 0.9rem;
}

.feedback-tags-section label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.4rem;
}

.feedback-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.feedback-tag {
    padding: 0.3rem 0.7rem;
    border: 2px solid #E2E8F0;
    background: white;
    border-radius: 14px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 500;
    color: #64748B;
    transition: all 0.3s ease;
}

.feedback-tag:hover {
    border-color: #2563EB;
    color: #2563EB;
}

.feedback-tag.selected {
    background: #2563EB;
    border-color: #2563EB;
    color: white;
}

/* ===================================
   FEEDBACK COMMENT
   =================================== */
.feedback-comment-section {
    margin-bottom: 0.9rem;
}

.feedback-comment-section label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.4rem;
}

.feedback-textarea {
    width: 100%;
    min-height: 50px;
    padding: 0.6rem;
    border: 2px solid #E2E8F0;
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: inherit;
    resize: none;
    transition: all 0.3s ease;
}

.feedback-textarea:focus {
    outline: none;
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.feedback-textarea::placeholder {
    color: #94A3B8;
}

.char-counter {
    text-align: right;
    font-size: 0.75rem;
    color: #94A3B8;
    margin-top: 0.25rem;
}

/* ===================================
   FEEDBACK SUBMIT
   =================================== */
.feedback-actions-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.feedback-actions {
    display: flex;
    gap: 0.5rem;
}

.feedback-submit-btn {
    width: 100%;
    padding: 0.875rem 1.25rem;
    background: linear-gradient(135deg, #2563EB, #1D4ED8);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

.feedback-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.feedback-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Required note styling - above button */
.feedback-required-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 10px 14px;
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border-radius: 8px;
    font-size: 0.82rem;
    color: #92400E;
    font-weight: 500;
    border: 1px solid #F59E0B;
}

.feedback-required-note i {
    color: #D97706;
    font-size: 0.9rem;
}

.feedback-skip-btn {
    padding: 1rem 1.5rem;
    background: #F1F5F9;
    border: none;
    border-radius: 12px;
    color: #64748B;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.feedback-skip-btn:hover {
    background: #E2E8F0;
    color: #475569;
}

/* ===================================
   SUCCESS STATE
   =================================== */
.feedback-success {
    text-align: center;
    padding: 1.25rem;
}

.feedback-success-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #22C55E, #16A34A);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    animation: successPop 0.5s ease;
}

.feedback-success-icon i {
    color: white;
    font-size: 1.8rem;
}

@keyframes successPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.feedback-success h3 {
    color: #1E293B;
    font-size: 1.15rem;
    margin-bottom: 0.35rem;
}

.feedback-success p {
    color: #64748B;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.feedback-success .feedback-submit-btn {
    margin: 0 auto;
    display: block;
}

/* ===================================
   POST-TEST FEEDBACK (Short & Compact)
   =================================== */
.feedback-modal.post-test {
    max-width: 420px;
}

.feedback-modal.post-test .feedback-modal-header {
    background: linear-gradient(135deg, #8B5CF6, #7C3AED);
    padding: 0.75rem 1rem;
}

.feedback-modal.post-test .feedback-modal-header h3 i {
    animation: bounce 1s ease infinite;
}

.feedback-modal.post-test .feedback-modal-body {
    padding: 0.85rem 1rem;
}

/* Hide tags section in post-test (short feedback) */
.feedback-modal.post-test .feedback-tags-section {
    display: none;
}

/* Smaller textarea for post-test */
.feedback-modal.post-test .feedback-textarea {
    min-height: 40px;
}

/* Compact comment label for post-test */
.feedback-modal.post-test .feedback-comment-section {
    margin-bottom: 0.75rem;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* ===================================
   RESPONSIVE - TABLET (768px)
   =================================== */
@media (max-width: 768px) {
    .feedback-float-btn {
        bottom: 20px;
        right: 20px;
        padding: 10px 14px;
    }
    
    .feedback-float-btn .feedback-label {
        font-size: 0.85rem;
    }
    
    .feedback-float-btn .tooltip {
        display: none;
    }
    
    .feedback-modal {
        width: 94%;
        max-width: 520px;
    }
    
    .feedback-modal.post-test {
        max-width: 400px;
    }
}

/* ===================================
   RESPONSIVE - MOBILE (576px)
   =================================== */
@media (max-width: 576px) {
    .feedback-float-btn {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
        padding: 0;
        border-radius: 50%;
    }
    
    .feedback-float-btn .feedback-label {
        display: none;
    }
    
    .feedback-float-btn i {
        font-size: 1.2rem;
    }
    
    .feedback-modal {
        width: 95%;
        max-width: none;
        border-radius: 12px;
    }
    
    .feedback-modal.post-test {
        max-width: 360px;
    }
    
    .feedback-modal-header {
        padding: 0.7rem 1rem;
        border-radius: 12px 12px 0 0;
    }
    
    .feedback-modal-header h3 {
        font-size: 0.95rem;
    }
    
    .feedback-modal-header p {
        font-size: 0.75rem;
    }
    
    .feedback-modal-body {
        padding: 0.85rem;
    }
    
    /* Feedback type buttons - 2x2 grid on mobile */
    .feedback-type-selector {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.35rem;
        margin-bottom: 0.75rem;
    }
    
    .feedback-type-btn {
        padding: 0.4rem 0.35rem;
        font-size: 0.65rem;
        border-radius: 6px;
    }
    
    .feedback-type-btn i {
        font-size: 0.9rem;
    }
    
    /* Emoji buttons */
    .emoji-rating {
        gap: 0.25rem;
    }
    
    .emoji-btn {
        padding: 0.35rem 0.2rem;
        font-size: 1.25rem;
        border-radius: 6px;
    }
    
    .emoji-btn span {
        display: none;
    }
    
    .feedback-rating-section {
        margin-bottom: 0.75rem;
    }
    
    .feedback-rating-section label {
        font-size: 0.8rem;
        margin-bottom: 0.35rem;
    }
    
    /* Tags section */
    .feedback-tags-section {
        margin-bottom: 0.75rem;
    }
    
    .feedback-tags-section label,
    .feedback-comment-section label {
        font-size: 0.8rem;
        margin-bottom: 0.35rem;
    }
    
    .feedback-tags {
        gap: 0.25rem;
    }
    
    .feedback-tag {
        padding: 0.25rem 0.55rem;
        font-size: 0.65rem;
        border-radius: 12px;
    }
    
    /* Textarea */
    .feedback-comment-section {
        margin-bottom: 0.75rem;
    }
    
    .feedback-textarea {
        min-height: 45px;
        padding: 0.5rem;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
    
    .feedback-modal.post-test .feedback-textarea {
        min-height: 35px;
    }
    
    .char-counter {
        font-size: 0.65rem;
        margin-top: 0.15rem;
    }
    
    /* Actions */
    .feedback-actions-wrapper {
        gap: 0.5rem;
        margin-top: 0.4rem;
    }
    
    .feedback-actions {
        gap: 0.4rem;
    }
    
    .feedback-submit-btn {
        padding: 0.75rem;
        font-size: 0.9rem;
        border-radius: 8px;
    }
    
    .feedback-required-note {
        padding: 8px 12px;
        font-size: 0.75rem;
        gap: 6px;
        border-radius: 6px;
    }
    
    .feedback-required-note i {
        font-size: 0.8rem;
    }
    
    .feedback-skip-btn {
        padding: 0.55rem 0.8rem;
        font-size: 0.8rem;
    }
    
    /* Success state */
    .feedback-success {
        padding: 1rem;
    }
    
    .feedback-success-icon {
        width: 50px;
        height: 50px;
        margin-bottom: 0.75rem;
    }
    
    .feedback-success-icon i {
        font-size: 1.5rem;
    }
    
    .feedback-success h3 {
        font-size: 1rem;
    }
    
    .feedback-success p {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
    }
}

/* ===================================
   RESPONSIVE - SMALL MOBILE (380px)
   =================================== */
@media (max-width: 380px) {
    .feedback-float-btn {
        bottom: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
    }
    
    .feedback-float-btn i {
        font-size: 1rem;
    }
    
    .feedback-modal {
        width: 97%;
    }
    
    .feedback-modal.post-test {
        max-width: 320px;
    }
    
    .feedback-modal-header {
        padding: 0.6rem 0.85rem;
    }
    
    .feedback-modal-header h3 {
        font-size: 0.9rem;
        gap: 0.3rem;
    }
    
    .feedback-modal-header p {
        font-size: 0.7rem;
    }
    
    .feedback-modal-body {
        padding: 0.75rem;
    }
    
    .emoji-btn {
        font-size: 1.1rem;
        padding: 0.3rem 0.15rem;
    }
    
    .feedback-type-btn {
        padding: 0.35rem 0.3rem;
        font-size: 0.6rem;
    }
    
    .feedback-type-btn i {
        font-size: 0.85rem;
    }
    
    .feedback-tag {
        padding: 0.2rem 0.45rem;
        font-size: 0.6rem;
    }
    
    .feedback-submit-btn {
        padding: 0.55rem;
        font-size: 0.8rem;
    }
    
    .feedback-skip-btn {
        padding: 0.5rem 0.7rem;
        font-size: 0.75rem;
    }
    
    .feedback-skip-btn {
        padding: 0.6rem;
        font-size: 0.8rem;
    }
}

/* ===================================
   LANDSCAPE MODE ADJUSTMENTS
   =================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .feedback-modal {
        max-height: 95vh;
    }
    
    .feedback-modal-header {
        padding: 0.75rem 1rem;
    }
    
    .feedback-modal-header h3 {
        font-size: 1rem;
    }
    
    .feedback-modal-header p {
        display: none;
    }
    
    .feedback-modal-body {
        padding: 0.75rem 1rem;
    }
    
    .feedback-rating-section,
    .feedback-tags-section,
    .feedback-comment-section {
        margin-bottom: 0.75rem;
    }
    
    .emoji-btn {
        min-height: 44px;
        font-size: 1.3rem;
    }
    
    .feedback-textarea {
        min-height: 60px;
    }
    
    .feedback-success {
        padding: 1rem;
    }
    
    .feedback-success-icon {
        width: 50px;
        height: 50px;
        margin-bottom: 0.75rem;
    }
}

/* ===================================
   TOUCH DEVICE OPTIMIZATIONS
   =================================== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .feedback-float-btn {
        min-width: 48px;
        min-height: 48px;
    }
    
    .feedback-close-btn {
        width: 36px;
        height: 36px;
    }
    
    .emoji-btn {
        min-height: 54px;
    }
    
    .feedback-tag {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
    }
    
    .feedback-type-btn {
        min-height: 56px;
    }
    
    .feedback-submit-btn,
    .feedback-skip-btn {
        min-height: 48px;
    }
    
    /* Remove hover effects for touch */
    .feedback-float-btn:hover {
        transform: none;
        animation: feedbackPulse 2s ease-in-out infinite;
    }
    
    .emoji-btn:hover {
        transform: none;
    }
    
    .feedback-tag:hover {
        border-color: #E2E8F0;
        color: #64748B;
    }
    
    .feedback-tag.selected:hover {
        background: #2563EB;
        border-color: #2563EB;
        color: white;
    }
}

/* ===================================
   SAFE AREA INSETS (Notched phones)
   =================================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .feedback-float-btn {
        bottom: calc(16px + env(safe-area-inset-bottom));
        right: calc(16px + env(safe-area-inset-right));
    }
    
    .feedback-modal {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Hide floating button during test */
body.test-in-progress .feedback-float-btn {
    display: none;
}

/* Prevent body scroll when modal is open on mobile */
body.feedback-modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}
