/* ==========================================================================
   Khảo Sát Phong Cách - CSS giao diện người dùng
   ========================================================================== */

/* Chuẩn hoá box-sizing trong phạm vi plugin để tránh tràn ngang trên mobile */
.sps-survey-container,
.sps-survey-container *,
.sps-popup-overlay,
.sps-popup-overlay * {
    box-sizing: border-box;
}

.sps-survey-container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
}

.sps-logo {
    text-align: center;
    font-size: 24px;
    font-weight: 300;
    color: #333;
    margin-bottom: 50px;
    letter-spacing: 2px;
}

.sps-logo::before {
    content: "◻ ";
    font-size: 28px;
}

.sps-header {
    text-align: center;
    margin-bottom: 40px;
}

.sps-header h1 {
    font-size: 32px;
    font-weight: 300;
    color: #333;
    margin-bottom: 10px;
}

.sps-header p {
    font-size: 16px;
    color: #666;
}

.sps-comparison-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin-bottom: 40px;
    min-height: 400px;
}

.sps-style-option {
    flex: 1;
    max-width: 450px;
    min-width: 0;
    cursor: pointer;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-radius: 8px;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.sps-style-option img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    display: block;
    border-radius: 8px;
}

.sps-style-option.selected {
    box-shadow: 0 0 0 4px #d4af37;
}

.sps-style-description {
    margin-top: 15px;
    text-align: center;
    font-size: 14px;
    color: #666;
    min-height: 40px;
}

.sps-or-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-shrink: 0;
}

.sps-or-circle {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #999;
    font-weight: 500;
}

.sps-neither-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 14px;
    text-decoration: underline;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

/* --- Thanh tiến trình --------------------------------------------------- */

.sps-progress-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 40px 0;
}

.sps-progress-dot {
    width: 56px;         /* 50px + 2 viền 3px, giữ đúng kích thước như bản cũ */
    height: 56px;
    flex: 0 0 auto;      /* Không cho flex bóp méo chấm thành hình bầu dục */
    border-radius: 50%;
    border: 3px solid #ddd;
    background: white;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.sps-progress-dot.completed {
    border-color: #d4af37;
}

.sps-progress-dot.active {
    border-color: #d4af37;
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.2);
}

.sps-progress-dot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sps-progress-dot.completed img {
    opacity: 1;
}

/* --- Popup -------------------------------------------------------------- */

.sps-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    animation: fadeIn 0.3s ease;
}

.sps-popup-overlay.show {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.sps-popup-content {
    background: white;
    border-radius: 10px;
    padding: 40px;
    width: 100%;
    max-width: 900px;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sps-popup-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 30px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    z-index: 2;
}

.sps-popup-header {
    text-align: center;
    margin-bottom: 30px;
}

.sps-popup-header h2 {
    font-size: 28px;
    font-weight: 300;
    color: #333;
    margin-bottom: 10px;
}

.sps-popup-header p {
    color: #666;
    font-size: 16px;
}

.sps-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.sps-result-item {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.sps-result-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.sps-result-info {
    padding: 15px;
    background: #f9f9f9;
}

.sps-result-info h3 {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.sps-result-info p {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

.sps-no-selection {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* --- Nội dung kết quả --------------------------------------------------- */

.sps-results-text {
    padding: 10px 0;
}

.sps-style-item {
    margin-bottom: 20px;
    line-height: 1.7;
    color: #555;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.sps-style-name {
    font-weight: 700;
    color: #333;
}

.sps-style-desc {
    color: #666;
}

/* --- Thông báo đã gửi email --------------------------------------------- */

.sps-email-notice {
    margin-top: 25px;
    text-align: center;
    padding: 15px;
    background: #e8f5e9;
    border-radius: 8px;
    border: 1px solid #c8e6c9;
}

.sps-email-notice p {
    margin: 0;
    color: #2e7d32;
    font-size: 14px;
    font-weight: 500;
}

/* --- Popup nhập email --------------------------------------------------- */

.sps-email-popup {
    max-width: 600px;
    text-align: center;
}

.sps-email-popup-header h2 {
    font-size: 32px;
    font-weight: 300;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.3;
}

.sps-email-subtitle {
    color: #888;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 30px;
}

.sps-email-form-container {
    margin-top: 30px;
}

.sps-email-instruction {
    color: #333;
    font-size: 14px;
    margin-bottom: 20px;
    font-weight: 500;
}

.sps-email-input {
    width: 100%;
    padding: 18px 20px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;   /* >=16px để iOS không tự phóng to trang khi focus */
    margin-bottom: 20px;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.sps-email-input:focus {
    outline: none;
    border-color: #d4af37;
}

.sps-email-input::placeholder {
    color: #aaa;
}

.sps-email-submit-btn {
    width: 100%;
    padding: 18px;
    background: #d4af37;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: background 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.sps-email-submit-btn:active {
    transform: scale(0.98);
}

/* --- Hiệu ứng hover: chỉ áp dụng cho thiết bị có chuột --------------------
   Trên màn cảm ứng, :hover bị dính lại sau khi chạm, khiến hình bị nâng lệch
   và chấm tiến trình bị phóng to sai.                                       */

@media (hover: hover) and (pointer: fine) {
    .sps-style-option:hover {
        transform: translateY(-5px);
        box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    }

    .sps-neither-btn:hover {
        color: #666;
    }

    .sps-progress-dot:hover {
        transform: scale(1.15);
    }

    .sps-popup-close:hover {
        color: #333;
    }

    .sps-email-submit-btn:hover {
        background: #c09d2f;
    }
}

/* --- Máy tính bảng (<= 768px) ------------------------------------------- */

@media (max-width: 768px) {
    .sps-survey-container {
        padding: 24px 16px;
        border-radius: 8px;
    }

    .sps-logo {
        font-size: 20px;
        margin-bottom: 28px;
    }

    .sps-header {
        margin-bottom: 28px;
    }

    .sps-header h1 {
        font-size: 24px;
        line-height: 1.3;
    }

    .sps-header p {
        font-size: 15px;
        line-height: 1.5;
    }

    .sps-comparison-container {
        flex-direction: column;
        min-height: 0;
        gap: 20px;
        margin-bottom: 24px;
    }

    .sps-style-option {
        width: 100%;
        max-width: 100%;
        flex: 0 0 auto;
    }

    .sps-style-option img {
        height: 240px;
    }

    .sps-style-description {
        margin-top: 10px;
        min-height: 0;
    }

    /* Vòng tròn HOẶC và nút bỏ qua nằm ngang cho đỡ chiếm chiều cao */
    .sps-or-divider {
        flex-direction: row;
        justify-content: center;
        width: 100%;
        gap: 16px;
    }

    .sps-or-circle {
        width: 48px;
        height: 48px;
        font-size: 14px;
    }

    .sps-neither-btn {
        font-size: 15px;
        padding: 10px 12px;   /* vùng chạm đủ lớn */
    }

    .sps-progress-container {
        gap: 10px;
        margin: 24px 0 8px;
    }

    .sps-progress-dot {
        width: 38px;
        height: 38px;
        border-width: 2px;
    }

    .sps-progress-dot.active {
        box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
    }

    .sps-results-grid {
        grid-template-columns: 1fr;
    }

    .sps-popup-overlay {
        padding: 12px;
        align-items: flex-start;
    }

    .sps-popup-content {
        padding: 48px 20px 28px;   /* chừa chỗ phía trên cho nút đóng */
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
    }

    .sps-popup-close {
        top: 8px;
        right: 8px;
        width: 44px;
        height: 44px;
        font-size: 28px;
    }

    .sps-popup-header {
        margin-bottom: 20px;
    }

    .sps-popup-header h2 {
        font-size: 22px;
    }

    .sps-popup-header p {
        font-size: 14px;
        line-height: 1.5;
    }

    .sps-email-popup-header h2 {
        font-size: 22px;
        margin-bottom: 14px;
    }

    .sps-email-subtitle {
        font-size: 14px;
        margin-bottom: 20px;
    }

    /* Xuống dòng theo chiều rộng màn hình thay vì theo thẻ br cố định */
    .sps-email-subtitle br {
        display: none;
    }

    .sps-email-form-container {
        margin-top: 20px;
    }

    .sps-email-input,
    .sps-email-submit-btn {
        padding: 15px 16px;
    }

    .sps-style-item {
        margin-bottom: 16px;
        font-size: 15px;
    }
}

/* --- Điện thoại (<= 480px) ---------------------------------------------- */

@media (max-width: 480px) {
    .sps-survey-container {
        padding: 20px 12px;
    }

    .sps-header h1 {
        font-size: 21px;
    }

    .sps-header p {
        font-size: 14px;
    }

    .sps-style-option img {
        height: 200px;
    }

    .sps-or-circle {
        width: 44px;
        height: 44px;
        font-size: 13px;
    }

    /* 10 chấm x 28px + 9 khoảng cách 6px = 334px, vừa 1 hàng trên máy 360px+ */
    .sps-progress-container {
        gap: 6px;
    }

    .sps-progress-dot {
        width: 28px;
        height: 28px;
    }

    .sps-popup-content {
        padding: 46px 16px 24px;
    }

    .sps-popup-header h2,
    .sps-email-popup-header h2 {
        font-size: 20px;
    }

    .sps-no-selection {
        padding: 24px 12px;
    }
}
