/**
 * Survey Frontend Styles - WordPress Plugin Version
 * Version: 1.0.0
 * Based on original design with CSS variables for customization
 */

/* --- CSS Variables for Dynamic Colors --- */
:root {
    --survey-primary-color: #356DF1;
    --survey-background-color: #2d3748;
}

/* --- Base Widget Container --- */
#page-survey-widget {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    width: 350px !important;
    background-color: var(--survey-background-color) !important;
    color: #f7fafc !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2) !important;
    z-index: 99999 !important;
    overflow: hidden !important;
    transition: opacity 0.3s ease, transform 0.3s ease !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

#page-survey-widget.is-hidden {
    opacity: 0 !important;
    transform: translateY(20px) !important;
    pointer-events: none !important;
}

/* --- Style Resets for Theme Compatibility --- */
#page-survey-widget * {
    box-sizing: border-box !important;
    font-family: inherit !important;
}

#page-survey-widget h3 {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #f7fafc !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: none !important;
}

#page-survey-widget .survey-header p {
    font-size: 13px !important;
    font-weight: 400 !important;
    color: #a0aec0 !important;
    margin: 4px 0 0 0 !important;
}

#page-survey-widget .survey-content p {
    font-size: 14px !important;
    font-weight: 400 !important;
    color: #e2e8f0 !important;
    margin: 0 0 16px 0 !important;
    padding: 0 !important;
}

#page-survey-widget button {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer !important;
}

/* --- Stage Management --- */
#page-survey-widget .survey-stage { 
    display: none; /* Hide all stages by default */
    padding: 20px !important;
    animation: fadeIn 0.4s ease-in-out !important;
}

#page-survey-widget .survey-stage.active { 
    display: block !important; /* Show only the active stage */
}

/* --- Header --- */
#page-survey-widget .survey-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 16px !important;
}

#page-survey-widget .survey-close {
    color: #a0aec0 !important;
    font-size: 24px !important;
    line-height: 1 !important;
}
#page-survey-widget .survey-close:hover {
    color: #ffffff !important;
}

/* --- Rating Stage --- */
#page-survey-widget .rating-buttons {
    display: flex !important;
    justify-content: space-between !important;
    margin-bottom: 8px !important;
}

#page-survey-widget .rating-btn {
    width: 40px !important;
    height: 40px !important;
    border: 2px solid #4a5568 !important;
    background: #374151 !important;
    color: #f3f4f6 !important;
    border-radius: 8px !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    transition: all 0.2s ease !important;
}

#page-survey-widget .rating-btn:hover {
    background: #4a5568 !important;
    transform: translateY(-2px) !important;
}

#page-survey-widget .rating-labels {
    display: flex !important;
    justify-content: space-between !important;
    font-size: 12px !important;
    color: #a0aec0 !important;
}

/* --- Feedback Stage --- */
#page-survey-widget #feedback-text {
    width: 100% !important;
    min-height: 100px !important;
    padding: 12px !important;
    border: 1px solid #d1d5db !important;
    border-radius: 8px !important;
    background: #f0f2f5 !important;
    color: #1a202c !important;
    font-size: 14px !important;
    resize: vertical !important;
}

#page-survey-widget #feedback-text:focus {
    outline: none !important;
    border-color: var(--survey-primary-color) !important;
    box-shadow: 0 0 0 2px rgba(53, 109, 241, 0.3) !important;
}

#page-survey-widget .char-count {
    text-align: right !important;
    font-size: 12px !important;
    color: #a0aec0 !important;
    margin-top: 4px !important;
    margin-bottom: 12px !important;
}

#page-survey-widget .submit-btn {
    width: 100% !important;
    padding: 12px !important;
    background-color: var(--survey-primary-color) !important;
    color: white !important;
    border-radius: 8px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    position: relative !important;
    transition: background-color 0.2s ease !important;
}

#page-survey-widget .submit-btn:hover {
    background-color: color-mix(in srgb, var(--survey-primary-color) 85%, black) !important;
}

#page-survey-widget .submit-btn.loading {
    background-color: color-mix(in srgb, var(--survey-primary-color) 85%, black) !important;
    cursor: wait !important;
}

#page-survey-widget .submit-btn.loading::after {
    content: '' !important;
    position: absolute !important;
    width: 20px !important;
    height: 20px !important;
    top: 50% !important;
    left: 50% !important;
    margin: -10px 0 0 -10px !important;
    border: 3px solid rgba(255, 255, 255, 0.3) !important;
    border-top-color: white !important;
    border-radius: 50% !important;
    animation: spin 0.8s linear infinite !important;
}

/* --- Thank You Stage --- */
#page-survey-widget #survey-thank-you .survey-content {
    text-align: center !important;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* --- Responsive --- */
@media (max-width: 400px) {
    #page-survey-widget {
        width: auto !important;
        left: 10px !important;
        right: 10px !important;
        bottom: 10px !important;
    }
    #page-survey-widget .rating-btn {
        width: 34px !important;
        height: 34px !important;
        font-size: 14px !important;
    }
}
