/* หน้าแสดงประวัติการบันทึกค่าปรับจราจร */
.cartax-container {
    font-family: 'Prompt', 'Kanit', sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 15px 12px;
    background-color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    height: auto;
    max-height: 300px; /* กำหนดความสูงสูงสุดของ widget */
    display: flex;
    flex-direction: column;
}

/* ส่วนหัว */
.cartax-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.cartax-title {
    color: #0a3677;
    margin: 0;
    font-weight: 700;
    font-size: 20px;
    padding-bottom: 0;
    position: relative;
    display: inline-block;
}

.cartax-title:after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 60px;
    height: 3px;
    background: linear-gradient(to right, #0a3677, #f57c00);
    border-radius: 3px;
}

/* ปุ่มเล็ก */
.cartax-btn-small {
    background: linear-gradient(135deg, #134e94 0%, #0a3677 100%);
    color: white !important;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(10, 54, 119, 0.2);
    display: flex;
    align-items: center;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.cartax-btn-small:hover {
    background: linear-gradient(135deg, #0a3677 0%, #072a5c 100%);
    box-shadow: 0 2px 5px rgba(10, 54, 119, 0.3);
    transform: translateY(-1px);
}

/* ตาราง */
.cartax-table-wrapper {
    position: relative;
    height: 230px; /* กำหนดความสูงตายตัวสำหรับตาราง */
    max-height: 230px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #aaa transparent;
    margin-bottom: 0;
    border-radius: 8px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
}

/* จัดการ scrollbar ให้สวยงาม */
.cartax-table-wrapper::-webkit-scrollbar {
    width: 6px;
}

.cartax-table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.cartax-table-wrapper::-webkit-scrollbar-thumb {
    background-color: #aaa;
    border-radius: 3px;
}

.cartax-table-wrapper::-webkit-scrollbar-thumb:hover {
    background-color: #888;
}

.cartax-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background-color: #fff;
    table-layout: fixed; /* ใช้ fixed layout เพื่อควบคุมความกว้างคอลัมน์ */
}

/* ตรึง header ของตาราง */
.cartax-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.cartax-table th {
    background: linear-gradient(135deg, #134e94 0%, #0a3677 100%);
    color: white;
    text-align: left;
    padding: 8px 10px;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    position: relative;
}

.cartax-table th:first-child {
    border-top-left-radius: 8px;
}

.cartax-table th:last-child {
    border-top-right-radius: 8px;
}

.cartax-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #edf2f7;
    font-size: 14px;
    transition: all 0.2s ease;
    vertical-align: middle;
}

/* แก้ไขการตัดข้อความยาว - ให้แสดงข้อความเต็ม */
.cartax-table td.number-column {
    width: 20%; /* เพิ่มความกว้างให้คอลัมน์เลขที่ปรับ */
    white-space: normal; /* อนุญาตให้ข้อความขึ้นบรรทัดใหม่ได้ */
    word-break: break-word; /* ตัดคำเมื่อจำเป็น */
}

.cartax-table td.detail-column {
    width: 35%;
    white-space: normal;
    word-break: break-word;
}

.cartax-table td.money-column {
    width: 20%;
    text-align: right;
    white-space: nowrap;
}

.cartax-table td.date-column {
    width: 25%;
    text-align: center;
    white-space: nowrap;
}

.cartax-table tr:hover td {
    background-color: #f8fafc;
}

.cartax-table tr:last-child td {
    border-bottom: none;
}

.cartax-table tr:last-child td:first-child {
    border-bottom-left-radius: 8px;
}

.cartax-table tr:last-child td:last-child {
    border-bottom-right-radius: 8px;
}

/* สไตล์สำหรับรายการที่มีค่าปรับแตกต่างกัน */
.cartax-table .high-fine {
    background-color: #ffebee;
    border-left: 3px solid #d32f2f;
}

.cartax-table .medium-fine {
    background-color: #ffe0b2;
    border-left: 3px solid #f57c00;
}

.cartax-table .low-fine {
    background-color: #fff3e0;
    border-left: 3px solid #ff9800;
}

/* สไตล์สำหรับตารางในโหมดโหลด */
.cartax-loading {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 15px 0;
    font-size: 13px;
}

/* เพิ่มสไตล์สำหรับการแสดงจำนวนเงิน */
.cartax-table .money-column {
    font-weight: 600;
    color: #0a3677;
}

/* เพิ่มสไตล์สำหรับการแสดงข้อหา */
.cartax-table .detail-column {
    font-style: italic;
    color: #444;
}

/* เพิ่มสไตล์สำหรับการแสดงวันที่ */
.cartax-table .date-column {
    color: #444;
}

/* Loading spinner */
.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(10, 54, 119, 0.2);
    border-radius: 50%;
    border-top-color: #0a3677;
    display: inline-block;
    margin-right: 8px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* สไตล์สำหรับ Infinite Scroll */
.cartax-table .end-of-data {
    text-align: center;
    padding: 10px 0;
    color: #999;
    font-style: italic;
    border-top: 1px dashed #ddd;
    background-color: #f9f9f9;
}

/* เพิ่มเอฟเฟกต์เมื่อโหลดข้อมูลใหม่ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.cartax-table tr.new-data {
    animation: fadeIn 0.5s ease forwards;
}

/* Modal */
.cartax-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    overflow: auto;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.cartax-modal.active {
    display: flex;
    animation: modalBackdropFadeIn 0.3s ease;
}

@keyframes modalBackdropFadeIn {
    from { background-color: rgba(0, 0, 0, 0); backdrop-filter: blur(0); }
    to { background-color: rgba(0, 0, 0, 0.7); backdrop-filter: blur(3px); }
}

.cartax-modal-content {
    background-color: #fff;
    width: 90%;
    max-width: 500px;
    border-radius: 10px;
    padding: 25px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    animation: modalFadeIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.cartax-modal-close {
    position: absolute;
    top: 12px;
    right: 15px;
    font-size: 22px;
    color: #999;
    cursor: pointer;
    transition: all 0.2s;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.cartax-modal-close:hover {
    color: #f57c00;
    background-color: #fff3e0;
    transform: rotate(90deg);
}

.cartax-modal h3 {
    color: #0a3677;
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    position: relative;
    padding-bottom: 10px;
}

.cartax-modal h3:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 3px;
    background: linear-gradient(to right, #0a3677, #f57c00);
    border-radius: 3px;
}

/* ฟอร์ม */
.cartax-form-group {
    margin-bottom: 18px;
}

.cartax-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.cartax-form-group input,
.cartax-form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s;
    background-color: #f9f9f9;
}

.cartax-form-group input:focus,
.cartax-form-group select:focus {
    border-color: #0a3677;
    outline: none;
    box-shadow: 0 0 0 3px rgba(10, 54, 119, 0.1);
    background-color: #fff;
}

.cartax-form-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 25px;
    gap: 12px;
}

.cartax-submit-btn {
    background: linear-gradient(135deg, #134e94 0%, #0a3677 100%);
    color: white !important;
    border: none;
    border-radius: 6px;
    padding: 10px 15px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
    box-shadow: 0 2px 5px rgba(10, 54, 119, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.cartax-submit-btn:hover {
    background: linear-gradient(135deg, #0a3677 0%, #072a5c 100%);
    box-shadow: 0 4px 8px rgba(10, 54, 119, 0.3);
    transform: translateY(-2px);
}

.cartax-cancel-btn {
    background: linear-gradient(135deg, #f57c00 0%, #e65100 100%);
    color: white !important;
    border: none;
    border-radius: 6px;
    padding: 10px 15px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
    box-shadow: 0 2px 5px rgba(230, 81, 0, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.cartax-cancel-btn:hover {
    background: linear-gradient(135deg, #e65100 0%, #bf360c 100%);
    box-shadow: 0 4px 8px rgba(230, 81, 0, 0.3);
    transform: translateY(-2px);
}

/* Responsive */
@media screen and (max-width: 576px) {
    .cartax-container {
        padding: 10px 8px;
        border-radius: 8px;
    }
    
    .cartax-title {
        font-size: 18px;
    }
    
    .cartax-btn-small {
        font-size: 12px;
        padding: 5px 10px;
    }
    
    .cartax-table th,
    .cartax-table td {
        padding: 8px 6px;
        font-size: 13px;
    }
    
    .cartax-form-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .cartax-submit-btn,
    .cartax-cancel-btn {
        width: 100%;
    }
    
    .cartax-modal-content {
        padding: 20px 15px;
    }
}

/* การแจ้งเตือน */
#carmt-police-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.cartax-notification {
    display: flex;
    align-items: center;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 10px;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 350px;
}

.cartax-notification.show {
    transform: translateX(0);
}

.cartax-notification.success {
    border-left: 4px solid #4CAF50;
}

.cartax-notification.error {
    border-left: 4px solid #F44336;
}

.notification-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-weight: bold;
}

.success .notification-icon {
    background-color: #4CAF50;
    color: white;
}

.error .notification-icon {
    background-color: #F44336;
    color: white;
}

.notification-message {
    font-size: 14px;
    color: #333;
}

@media screen and (max-width: 576px) {
    #carmt-police-notification {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    
    .cartax-notification {
        max-width: none;
    }
}