:root {
    --primary-color: #008a00;
    --primary-hover: #006800;
    --slider-track-bg: #e0e0e0;
    --border-color: #ccc;
    --text-color: #333;
    --background-color: #ffffff;
    --wrapper-bg: #f9f9f9;
}

#cpm-calculator-wrapper {
    width: 100%; /* Cho phép mở rộng 100% theo cột chứa nó */
    max-width: 100%; /* Gỡ bỏ giới hạn 800px cũ */
    box-sizing: border-box; /* Ngăn padding làm tràn viền */
    margin: 15px auto;
    padding: 25px; 
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background-color: var(--wrapper-bg);
    color: var(--text-color);
}

/* Điều chỉnh lại Font Size & Margin Header */
.cpm-calculator-header h3 { margin-top: 0; font-size: 22px; font-weight: 700; color: #111; margin-bottom: 8px;}
.cpm-calculator-header p { margin-bottom: 15px; color: #555; font-size: 14px; }

.cpm-calculator-body { 
    display: flex; 
    flex-direction: column; 
    gap: 20px; /* Giảm gap giữa phần nhập và bảng kết quả */
}

.cpm-calculator-form { flex: 1; }
.cpm-calculator-results { flex: 1; display: flex; flex-direction: column; }

.cpm-form-row { margin-bottom: 15px; /* Giảm khoảng cách giữa các hàng nhập */ }
.cpm-form-row > label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: #444; }

.cpm-amount-display { font-size: 28px; /* Thu nhỏ text số tiền hiển thị */ font-weight: bold; color: var(--primary-color); margin-bottom: 10px; }
.cpm-range-labels { display: flex; justify-content: space-between; font-size: 13px; color: #888; margin-top: 6px; font-weight: 500;}

input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; }
input[type=range]:focus { outline: none; }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 6px; cursor: pointer; background: var(--slider-track-bg); border-radius: 5px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 20px; width: 20px; border-radius: 50%; background: var(--primary-color); cursor: pointer; margin-top: -7px; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: transform 0.1s;}
input[type=range]::-webkit-slider-thumb:active { transform: scale(1.1); }

.cpm-service-options, .cpm-term-options { display: flex; flex-wrap: wrap; gap: 8px; /* Khoảng cách giữa các nút sát lại */ }
.cpm-service-btn, .cpm-term-btn { 
    padding: 8px 16px; /* Làm nút nhỏ gọn lại */
    border: 1px solid var(--border-color); 
    background-color: var(--background-color); 
    border-radius: 6px; 
    cursor: pointer; 
    font-size: 14px; 
    font-weight: 600; 
    transition: all 0.2s ease; 
    color: #555;
}
.cpm-service-btn:hover, .cpm-term-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }
.cpm-service-btn.active, .cpm-term-btn.active { background-color: var(--primary-color); color: #fff; border-color: var(--primary-color); }

.cpm-terms-row { display: flex; align-items: flex-start; font-size: 13px; line-height: 1.4; background: #fff; padding: 12px; border-radius: 6px; border: 1px solid #eee; }
#cpm-agree-terms { margin-top: 3px; margin-right: 10px; transform: scale(1.1); cursor: pointer;}
.cpm-terms-row a { color: var(--primary-color); text-decoration: underline; font-weight: 500;}

.cpm-cta-button { display: block; width: 100%; padding: 12px; background-color: var(--primary-color); color: #fff; text-align: center; font-size: 16px; font-weight: bold; border-radius: 6px; border: none; cursor: pointer; transition: background-color 0.2s; text-transform: uppercase;}
.cpm-cta-button:hover { background-color: var(--primary-hover); }
.cpm-cta-button.disabled { background-color: #b0b0b0; cursor: not-allowed; pointer-events: none; }

/* Bảng Tóm Tắt & Kết quả */
.cpm-summary-box { background: #e8f5e9; border: 1px solid #c8e6c9; border-radius: 6px; padding: 15px; margin-bottom: 15px; text-align: center; }
.cpm-summary-box p { margin: 0 0 5px 0; color: #2e7d32; font-weight: 600; font-size: 14px; }
.cpm-summary-box h2 { margin: 0; color: var(--primary-color); font-size: 24px; font-weight: 800; }

.cpm-calculator-results h4 { font-size: 16px; margin-bottom: 10px; color: #333; }
.cpm-table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 6px; border: 1px solid #eee;}
#cpm-results-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; min-width: 450px;}
#cpm-results-table th, #cpm-results-table td { border-bottom: 1px solid #eee; padding: 8px 10px; text-align: right; }
#cpm-results-table th { background-color: #f8f9fa; text-align: right; font-weight: 600; color: #444; }
#cpm-results-table tr:last-child td { border-bottom: none; }

/* MODAL POPUP */
.cpm-modal { display: none; position: fixed; z-index: 9999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.6); backdrop-filter: blur(4px);}
.cpm-modal-content { background-color: #fefefe; margin: 10% auto; padding: 25px; border-radius: 8px; width: 90%; max-width: 380px; position: relative; box-shadow: 0 10px 30px rgba(0,0,0,0.2); text-align: center; }
.cpm-modal-close { color: #aaa; float: right; font-size: 26px; font-weight: bold; cursor: pointer; position: absolute; right: 15px; top: 10px;}
.cpm-modal-close:hover { color: #333; }
.cpm-modal-content h3 { margin-top:0; text-align:center; color: var(--primary-color); font-size: 20px;}
.cpm-modal-content p { text-align: center; color: #555; margin-bottom: 15px; font-size: 14px;}
.cpm-modal-form-group { margin-bottom: 12px; }
.cpm-modal-form-group input { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; box-sizing: border-box; text-align: left; }
.cpm-modal-form-group input:focus { outline: none; border-color: var(--primary-color); }

/* Animation Rung Lắc cho Nút Zalo */
@keyframes cpm-shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.cpm-zalo-btn {
    display: inline-block;
    background-color: #008dff;
    color: #ffffff !important;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    font-size: 15px;
    margin-top: 15px;
    box-shadow: 0 4px 10px rgba(0, 141, 255, 0.4);
    animation: cpm-shake 2s infinite; /* Hiệu ứng rung lắc liên tục */
    transition: background-color 0.3s;
}
.cpm-zalo-btn:hover {
    background-color: #0073d1;
    animation: none; /* Dừng rung khi rê chuột vào */
}

/* Các Class Cấu hình Vị Trí Cho Nút Nổi (Sticky Button) */
#cpm-sticky-btn {
    position: fixed;
    background-color: var(--primary-color);
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    z-index: 99999;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s ease, background-color 0.2s;
}
#cpm-sticky-btn:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05);
}

.cpm-sticky-pos-bottom-right { bottom: 25px; right: 25px; }
.cpm-sticky-pos-bottom-left { bottom: 25px; left: 25px; }
.cpm-sticky-pos-middle-right { top: 50%; right: 20px; transform: translateY(-50%); }
.cpm-sticky-pos-middle-left { top: 50%; left: 20px; transform: translateY(-50%); }

/* Animation Rung Chuông cho Icon Máy tính ở Nút Nổi */
@keyframes cpm-ringing {
    0% { transform: rotate(0); }
    10% { transform: rotate(15deg); }
    20% { transform: rotate(-15deg); }
    30% { transform: rotate(10deg); }
    40% { transform: rotate(-10deg); }
    50% { transform: rotate(5deg); }
    60% { transform: rotate(-5deg); }
    70% { transform: rotate(0); }
    100% { transform: rotate(0); }
}

.cpm-ring-animation {
    animation: cpm-ringing 2s infinite ease-in-out;
    transform-origin: center top;
}

@media (max-width: 768px) {
    #cpm-calculator-wrapper { padding: 15px; margin: 10px auto; }
    .cpm-calculator-body { gap: 15px;}
    .cpm-amount-display { font-size: 24px; }
    
    /* Thu gọn nút nổi trên mobile */
    #cpm-sticky-btn { padding: 10px 20px; font-size: 13px; }
    .cpm-sticky-pos-bottom-right { bottom: 15px; right: 15px; }
    .cpm-sticky-pos-bottom-left { bottom: 15px; left: 15px; }
    .cpm-sticky-pos-middle-right { right: 10px; }
    .cpm-sticky-pos-middle-left { left: 10px; }
}