/**
 * Ze Voice - NPS Darty/Qualtrics Style
 * This CSS transforms WPForms to display NPS scale like Darty/Qualtrics
 * Supports WPForms native Net Promoter Score field (table-based) and radio fields
 *
 * @package Ze_Voice
 * @version 1.9.9
 */

/* ============================================
   CSS Custom Properties for NPS Colors
   ============================================ */
.zevoice-nps-field,
.wpforms-field-net_promoter_score {
    --zevoice-nps-0: #e74c3c;
    --zevoice-nps-1: #e74c3c;
    --zevoice-nps-2: #e74c3c;
    --zevoice-nps-3: #e67e22;
    --zevoice-nps-4: #f39c12;
    --zevoice-nps-5: #f1c40f;
    --zevoice-nps-6: #f1c40f;
    --zevoice-nps-7: #d4ac0d;
    --zevoice-nps-8: #b7950b;
    --zevoice-nps-9: #27ae60;
    --zevoice-nps-10: #1e8449;
    --zevoice-primary: #3498db;
    --zevoice-btn-size: 52px;
    --zevoice-btn-gap: 10px;
    --zevoice-btn-font: 18px;
}

/* ============================================
   WPForms Net Promoter Score Field (Table-based)
   Structure: .wpforms-field-net_promoter_score table.modern tbody tr td
   ============================================ */

/* Container */
.wpforms-field-net_promoter_score {
    margin-bottom: 30px !important;
    text-align: left !important;
}

/* Question Label (LEGEND element) - MUST be visible with BLACK text */
/* Desktop: aligned left */
.wpforms-field-net_promoter_score legend.wpforms-field-label,
.wpforms-field-net_promoter_score fieldset > legend,
.wpforms-field-net_promoter_score .wpforms-field-label,
.wpforms-field-net_promoter_score > label.wpforms-field-label,
.wpforms-field.wpforms-field-net_promoter_score > label,
.wpforms-field[data-field-type="net_promoter_score"] legend,
.wpforms-field[data-field-type="net_promoter_score"] > fieldset > legend {
    font-size: 20px !important;
    font-weight: 600 !important;
    text-align: left !important;
    color: #333333 !important;
    -webkit-text-fill-color: #333333 !important;
    background: transparent !important;
    margin-bottom: 25px !important;
    line-height: 1.4 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    clip: auto !important;
    text-shadow: none !important;
}

/* Table Container - Full width on desktop */
.wpforms-field-net_promoter_score table,
.wpforms-field-net_promoter_score table.modern,
.wpforms-field-net_promoter_score table.wpforms-field-large {
    margin: 0 !important;
    border: none !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background: transparent !important;
    width: 100% !important;
    display: table !important;
}

.wpforms-field-net_promoter_score table tbody,
.wpforms-field-net_promoter_score table.modern tbody,
.wpforms-field-net_promoter_score table.wpforms-field-large tbody {
    background: transparent !important;
}

.wpforms-field-net_promoter_score table tbody tr,
.wpforms-field-net_promoter_score table.modern tbody tr,
.wpforms-field-net_promoter_score table.wpforms-field-large tbody tr {
    background: transparent !important;
    display: flex !important;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    width: 100% !important;
}

/* Individual Score Cells - Flex grow to fill space */
.wpforms-field-net_promoter_score table tbody tr td,
.wpforms-field-net_promoter_score table.modern tbody tr td,
.wpforms-field-net_promoter_score table.wpforms-field-large tbody tr td {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    position: relative !important;
    display: flex !important;
    flex: 1 1 0 !important;
    min-width: 0 !important;
}

/* Hide Radio Inputs */
.wpforms-field-net_promoter_score input.wpforms-net-promoter-score-option,
.wpforms-field-net_promoter_score input[type="radio"] {
    position: absolute !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    pointer-events: none !important;
}

/* Score Labels as Buttons - Fill their container width, square shape */
/* IMPORTANT: Only target labels INSIDE table cells (the score buttons), NOT the field label */
.wpforms-field-net_promoter_score table tbody tr td label,
.wpforms-field-net_promoter_score table.modern tbody tr td label,
.wpforms-field-net_promoter_score table.wpforms-field-large tbody tr td label {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    aspect-ratio: 1 / 1 !important;
    min-height: 45px !important;
    border-radius: 8px !important;
    color: #fff !important;
    font-size: clamp(14px, 2vw, 20px) !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    background-color: #ccc !important;
    flex-shrink: 0 !important;
}

/* Hover Effect */
.wpforms-field-net_promoter_score table tbody tr td label:hover,
.wpforms-field-net_promoter_score table.modern tbody tr td label:hover,
.wpforms-field-net_promoter_score table.wpforms-field-large tbody tr td label:hover {
    transform: translateY(-3px) scale(1.08) !important;
    box-shadow: 0 6px 15px rgba(0,0,0,0.2) !important;
}

/* Selected State */
.wpforms-field-net_promoter_score input[type="radio"]:checked + label {
    transform: scale(1.12) !important;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.15), 0 6px 20px rgba(0,0,0,0.25) !important;
    z-index: 1 !important;
    opacity: 1 !important;
    filter: none !important;
}

/* Fade non-selected buttons when a selection exists */
.wpforms-field-net_promoter_score.has-selection table tbody tr td label {
    opacity: 0.45 !important;
    filter: saturate(0.5) !important;
    transform: scale(1) !important;
}

.wpforms-field-net_promoter_score.has-selection input[type="radio"]:checked + label {
    opacity: 1 !important;
    filter: saturate(1) !important;
    transform: scale(1.12) !important;
}

/* Individual Score Colors - Using nth-child for table cells */
.wpforms-field-net_promoter_score table tbody tr td:nth-child(1) label { background-color: var(--zevoice-nps-0) !important; }
.wpforms-field-net_promoter_score table tbody tr td:nth-child(2) label { background-color: var(--zevoice-nps-1) !important; }
.wpforms-field-net_promoter_score table tbody tr td:nth-child(3) label { background-color: var(--zevoice-nps-2) !important; }
.wpforms-field-net_promoter_score table tbody tr td:nth-child(4) label { background-color: var(--zevoice-nps-3) !important; }
.wpforms-field-net_promoter_score table tbody tr td:nth-child(5) label { background-color: var(--zevoice-nps-4) !important; }
.wpforms-field-net_promoter_score table tbody tr td:nth-child(6) label { background-color: var(--zevoice-nps-5) !important; }
.wpforms-field-net_promoter_score table tbody tr td:nth-child(7) label { background-color: var(--zevoice-nps-6) !important; }
.wpforms-field-net_promoter_score table tbody tr td:nth-child(8) label { background-color: var(--zevoice-nps-7) !important; }
.wpforms-field-net_promoter_score table tbody tr td:nth-child(9) label { background-color: var(--zevoice-nps-8) !important; }
.wpforms-field-net_promoter_score table tbody tr td:nth-child(10) label { background-color: var(--zevoice-nps-9) !important; }
.wpforms-field-net_promoter_score table tbody tr td:nth-child(11) label { background-color: var(--zevoice-nps-10) !important; }

/* Min/Max Labels for NPS Field - Below the buttons, full width */
.wpforms-field-net_promoter_score .zevoice-nps-labels {
    display: flex !important;
    justify-content: space-between !important;
    width: 100% !important;
    max-width: none !important;
    margin: 15px 0 0 !important;
    padding: 0 !important;
}

.wpforms-field-net_promoter_score .zevoice-label-min,
.wpforms-field-net_promoter_score .zevoice-label-max {
    font-size: 13px !important;
    color: #666 !important;
    font-weight: 500 !important;
}

/* ============================================
   NPS Field Container (Legacy + Radio)
   ============================================ */

.zevoice-nps-field {
    margin-bottom: 30px !important;
    text-align: center !important;
}

.zevoice-nps-field .wpforms-field-label {
    font-size: 20px !important;
    font-weight: 600 !important;
    text-align: center !important;
    color: #333 !important;
    margin-bottom: 25px !important;
    line-height: 1.4 !important;
    display: block !important;
}

/* NPS Scale Container */
.zevoice-nps-scale {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
}

/* NPS Buttons Row - No wrap */
.zevoice-nps-buttons {
    display: flex;
    gap: var(--zevoice-btn-gap);
    justify-content: center;
    flex-wrap: nowrap;
}

/* Individual NPS Button */
.zevoice-nps-btn {
    width: var(--zevoice-btn-size);
    height: var(--zevoice-btn-size);
    min-width: var(--zevoice-btn-size);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: var(--zevoice-btn-font);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.zevoice-nps-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, rgba(0,0,0,0.1) 100%);
    opacity: 0;
    transition: opacity 0.2s;
}

.zevoice-nps-btn:hover {
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 6px 15px rgba(0,0,0,0.2);
}

.zevoice-nps-btn:hover::before {
    opacity: 1;
}

.zevoice-nps-btn:active {
    transform: translateY(-1px) scale(1.02);
}

.zevoice-nps-btn.selected {
    transform: scale(1.12);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.15), 0 6px 20px rgba(0,0,0,0.25);
    z-index: 1;
    opacity: 1 !important;
    filter: none !important;
}

.zevoice-nps-btn.selected::after {
    content: '✓';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    color: inherit;
}

/* Fade non-selected buttons when a selection exists */
.zevoice-nps-scale.has-selection .zevoice-nps-btn {
    opacity: 0.45;
    filter: saturate(0.5);
    transform: scale(1);
}

.zevoice-nps-scale.has-selection .zevoice-nps-btn.selected {
    opacity: 1;
    filter: saturate(1);
    transform: scale(1.12);
}

/* NPS Labels */
.zevoice-nps-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 540px;
    margin-top: 15px;
    padding: 0 5px;
}

.zevoice-label-min,
.zevoice-label-max {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.zevoice-label-min {
    text-align: left;
}

.zevoice-label-max {
    text-align: right;
}

/* ============================================
   Radio Button Style (for WPForms radio fields)
   ============================================ */

.zevoice-nps-field .wpforms-field-radio ul {
    display: flex !important;
    gap: var(--zevoice-btn-gap) !important;
    justify-content: center !important;
    flex-wrap: nowrap !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 20px 0 !important;
}

.zevoice-nps-field .wpforms-field-radio li {
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
}

.zevoice-nps-field .wpforms-field-radio li.zevoice-nps-option {
    position: relative;
}

.zevoice-nps-field .wpforms-field-radio li.zevoice-nps-option input[type="radio"] {
    position: absolute !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
}

.zevoice-nps-field .wpforms-field-radio li.zevoice-nps-option label {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: var(--zevoice-btn-size) !important;
    height: var(--zevoice-btn-size) !important;
    min-width: var(--zevoice-btn-size) !important;
    background-color: var(--nps-color, #ccc) !important;
    border-radius: 8px !important;
    color: #fff !important;
    font-size: var(--zevoice-btn-font) !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
}

.zevoice-nps-field .wpforms-field-radio li.zevoice-nps-option label:hover {
    transform: translateY(-3px) scale(1.08) !important;
    box-shadow: 0 6px 15px rgba(0,0,0,0.2) !important;
}

.zevoice-nps-field .wpforms-field-radio li.zevoice-nps-option input[type="radio"]:checked + label {
    transform: scale(1.12) !important;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.15), 0 6px 20px rgba(0,0,0,0.25) !important;
    z-index: 1 !important;
    opacity: 1 !important;
    filter: none !important;
}

/* Fade non-selected radio buttons when a selection exists */
.zevoice-nps-field.has-selection .wpforms-field-radio li.zevoice-nps-option label {
    opacity: 0.45 !important;
    filter: saturate(0.5) !important;
    transform: scale(1) !important;
}

.zevoice-nps-field.has-selection .wpforms-field-radio li.zevoice-nps-option input[type="radio"]:checked + label {
    opacity: 1 !important;
    filter: saturate(1) !important;
    transform: scale(1.12) !important;
}

/* Individual Score Colors for Radio */
.zevoice-nps-field .wpforms-field-radio li:nth-child(1) { --nps-color: var(--zevoice-nps-0); }
.zevoice-nps-field .wpforms-field-radio li:nth-child(2) { --nps-color: var(--zevoice-nps-1); }
.zevoice-nps-field .wpforms-field-radio li:nth-child(3) { --nps-color: var(--zevoice-nps-2); }
.zevoice-nps-field .wpforms-field-radio li:nth-child(4) { --nps-color: var(--zevoice-nps-3); }
.zevoice-nps-field .wpforms-field-radio li:nth-child(5) { --nps-color: var(--zevoice-nps-4); }
.zevoice-nps-field .wpforms-field-radio li:nth-child(6) { --nps-color: var(--zevoice-nps-5); }
.zevoice-nps-field .wpforms-field-radio li:nth-child(7) { --nps-color: var(--zevoice-nps-6); }
.zevoice-nps-field .wpforms-field-radio li:nth-child(8) { --nps-color: var(--zevoice-nps-7); }
.zevoice-nps-field .wpforms-field-radio li:nth-child(9) { --nps-color: var(--zevoice-nps-8); }
.zevoice-nps-field .wpforms-field-radio li:nth-child(10) { --nps-color: var(--zevoice-nps-9); }
.zevoice-nps-field .wpforms-field-radio li:nth-child(11) { --nps-color: var(--zevoice-nps-10); }

/* Number Field Hidden */
.zevoice-nps-field input[type="number"] {
    display: none !important;
}

/* ============================================
   Comment Field Styling
   ============================================ */

.zevoice-survey-wrapper .wpforms-field-textarea {
    margin-top: 30px;
}

.zevoice-survey-wrapper .wpforms-field-textarea .wpforms-field-label {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    color: #333;
    margin-bottom: 15px;
}

.zevoice-survey-wrapper .wpforms-field-textarea textarea {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    font-size: 16px;
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.2s;
}

.zevoice-survey-wrapper .wpforms-field-textarea textarea:focus {
    border-color: var(--zevoice-primary);
    outline: none;
}

/* ============================================
   Submit Button Styling
   ============================================ */

.zevoice-survey-wrapper .wpforms-submit-container {
    text-align: center;
    margin-top: 30px;
}

.zevoice-survey-wrapper .wpforms-submit {
    background: var(--zevoice-primary) !important;
    border: none !important;
    padding: 15px 50px !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    border-radius: 50px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15) !important;
}

.zevoice-survey-wrapper .wpforms-submit:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2) !important;
}

/* Hide Default WPForms Elements */
.zevoice-nps-field .wpforms-field-description,
.wpforms-field-net_promoter_score .wpforms-field-description {
    text-align: center;
    margin-top: 10px;
    font-size: 14px;
    color: #888;
}

/* ============================================
   Animation
   ============================================ */

@keyframes zevoice-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.zevoice-nps-btn.selected {
    animation: zevoice-pulse 0.5s ease;
}

/* ============================================
   Responsive - Mobile: centered, dynamic sizing
   Desktop: full width, space-between
   ============================================ */

/* Tablets */
@media (max-width: 768px) {
    .zevoice-nps-field,
    .wpforms-field-net_promoter_score {
        --zevoice-btn-size: 40px;
        --zevoice-btn-gap: 6px;
        --zevoice-btn-font: 15px;
    }

    .zevoice-nps-field .wpforms-field-label,
    .wpforms-field-net_promoter_score .wpforms-field-label,
    .wpforms-field-net_promoter_score legend.wpforms-field-label {
        font-size: 18px !important;
    }

    .zevoice-nps-labels,
    .wpforms-field-net_promoter_score .zevoice-nps-labels {
        font-size: 12px !important;
    }
}

/* Mobile phones - Centered layout, fixed small sizes */
@media (max-width: 520px) {
    /* Center the container on mobile */
    .wpforms-field-net_promoter_score {
        text-align: center !important;
        overflow: visible !important;
    }

    /* Center the question label on mobile */
    .wpforms-field-net_promoter_score legend.wpforms-field-label,
    .wpforms-field-net_promoter_score .wpforms-field-label {
        text-align: center !important;
    }

    .zevoice-nps-field,
    .wpforms-field-net_promoter_score {
        --zevoice-btn-gap: 2px;
        --zevoice-btn-font: 11px;
    }

    /* Table auto width, centered on mobile */
    .wpforms-field-net_promoter_score table,
    .wpforms-field-net_promoter_score table.modern {
        width: auto !important;
        margin: 0 auto !important;
        display: table !important;
    }

    /* Row with minimal gap */
    .wpforms-field-net_promoter_score table tbody tr {
        justify-content: center !important;
        gap: 2px !important;
    }

    /* Cells with fixed small size - NO flex-grow */
    .wpforms-field-net_promoter_score table tbody tr td {
        flex: 0 0 auto !important;
        min-width: auto !important;
        max-width: none !important;
    }

    /* Buttons with fixed small size for mobile - 28px fits 11 buttons + gaps in 320px */
    .wpforms-field-net_promoter_score table tbody tr td label {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        max-width: 28px !important;
        max-height: 28px !important;
        aspect-ratio: unset !important;
        border-radius: 5px !important;
        font-size: 11px !important;
    }

    .zevoice-nps-btn,
    .zevoice-nps-field .wpforms-field-radio li.zevoice-nps-option label {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        border-radius: 5px !important;
    }

    .zevoice-nps-field .wpforms-field-label,
    .wpforms-field-net_promoter_score .wpforms-field-label,
    .wpforms-field-net_promoter_score legend.wpforms-field-label {
        font-size: 16px !important;
        margin-bottom: 15px !important;
    }

    .zevoice-nps-labels,
    .wpforms-field-net_promoter_score .zevoice-nps-labels {
        font-size: 10px !important;
        max-width: 100% !important;
        padding: 0 5px !important;
        margin: 15px auto 0 !important;
    }

    .zevoice-label-min,
    .zevoice-label-max {
        max-width: 45% !important;
    }
}

/* Very small phones (320px) - even smaller buttons */
@media (max-width: 380px) {
    .zevoice-nps-field,
    .wpforms-field-net_promoter_score {
        --zevoice-btn-gap: 1px;
        --zevoice-btn-font: 9px;
    }

    .wpforms-field-net_promoter_score table tbody tr {
        gap: 1px !important;
    }

    /* 25px buttons: 11*25 + 10*1 = 285px < 320px - padding */
    .wpforms-field-net_promoter_score table tbody tr td label,
    .zevoice-nps-btn,
    .zevoice-nps-field .wpforms-field-radio li.zevoice-nps-option label {
        width: 25px !important;
        height: 25px !important;
        min-width: 25px !important;
        min-height: 25px !important;
        max-width: 25px !important;
        max-height: 25px !important;
        border-radius: 4px !important;
        font-size: 9px !important;
    }

    .zevoice-nps-labels,
    .wpforms-field-net_promoter_score .zevoice-nps-labels {
        font-size: 9px !important;
    }
}

/* ============================================
   Dark Mode Support
   ============================================ */

@media (prefers-color-scheme: dark) {
    .zevoice-survey-content {
        background: #1a1a2e;
        color: #eee;
    }

    .zevoice-nps-field .wpforms-field-label,
    .wpforms-field-net_promoter_score .wpforms-field-label {
        color: #fff !important;
    }

    .zevoice-label-min,
    .zevoice-label-max {
        color: #aaa;
    }

    .zevoice-survey-wrapper .wpforms-field-textarea textarea {
        background: #16213e;
        border-color: #0f3460;
        color: #eee;
    }

    .zevoice-nps-field .wpforms-field-description,
    .wpforms-field-net_promoter_score .wpforms-field-description {
        color: #888;
    }
}

/* ============================================
   Thank You Message
   ============================================ */

.zevoice-thank-you {
    text-align: center;
    padding: 60px 40px;
}

.zevoice-thank-you-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.zevoice-thank-you h2 {
    font-size: 32px;
    color: #27ae60;
    margin: 0 0 15px;
}

.zevoice-thank-you p {
    font-size: 18px;
    color: #666;
    margin: 0;
}
