/* Car Maintenance Update Styles */

/* Main container */
.carmt-container {
    font-family: 'Kanit', sans-serif;
    color: #333;
    margin: 20px 0;
}

/* Form container */
.carmt-form-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 30px;
}

.carmt-form-header {
    background-color: #0056b3;
    color: white;
    padding: 15px 20px;
}

.carmt-form-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 500;
}

.carmt-form-body {
    padding: 20px;
}

/* Form styling */
.carmt-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.carmt-form-group {
    flex: 1;
    min-width: 200px;
}

.carmt-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.carmt-form-group input,
.carmt-form-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 15px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.carmt-form-group input:focus,
.carmt-form-group select:focus {
    border-color: #0056b3;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.25);
}

.carmt-form-group input[readonly] {
    background-color: #f9f9f9;
    cursor: not-allowed;
    border-color: #ddd;
}

/* Table styles */
.carmt-filter-section {
    margin: 20px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.carmt-filter-section label {
    margin-right: 5px;
    font-weight: 500;
    color: #0056b3;
}

.carmt-filter-section input {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.carmt-filter-section button {
    background-color: #0056b3;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.carmt-filter-section button:hover {
    background-color: #003d82;
}

#reset_filter {
    background-color: #666;
}

#reset_filter:hover {
    background-color: #444;
}

.carmt-table-container {
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
}

.carmt-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.carmt-table th,
.carmt-table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
}

.carmt-table th {
    background-color: #0056b3;
    color: white;
    font-weight: 500;
    white-space: nowrap;
}

.carmt-table tbody tr:nth-child(even) {
    background-color: #f2f2f2;
}

.carmt-table tbody tr:hover {
    background-color: #e0e0e0;
}

.total-label {
    text-align: right;
    font-weight: bold;
}

#total-cost {
    font-weight: bold;
    color: #0056b3;
}

/* Add button */
.carmt-add-row-container {
    margin: 20px 0;
}

.carmt-add-button {
    background-color: #f57c00;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.carmt-add-button:hover {
    background-color: #e65100;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.carmt-add-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
}

/* Icon for add button */
.carmt-add-button::before {
    content: "+";
    margin-right: 8px;
    font-size: 18px;
    font-weight: bold;
}

/* New row styles */
.carmt-new-row {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s;
}

.carmt-new-row:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #bbb;
}

.carmt-new-row .carmt-form-group {
    flex: 1;
    min-width: 120px;
}

/* Button group */
.carmt-button-group {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
}

.carmt-save-button {
    background-color: #0056b3;
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    font-weight: 500;
}

.carmt-save-button:hover {
    background-color: #003d82;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.carmt-save-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
}

.carmt-save-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* สไตล์สำหรับ input mask */
.date-mask {
    font-family: 'Kanit', sans-serif;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 15px;
    width: 100%;
    box-sizing: border-box;
    background-color: #fff;
    transition: border-color 0.3s, box-shadow 0.3s;
    letter-spacing: 1px;
    text-align: center;
}

.date-mask:focus {
    border-color: #0056b3;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.25);
}

.date-mask::placeholder {
    color: #aaa;
    letter-spacing: 2px;
}

/* สไตล์เพิ่มเติมสำหรับฟิลด์วันที่ */
.carmt-form-group label[for="new_mt_date"],
.carmt-filter-section label[for="filter_start_date"],
.carmt-filter-section label[for="filter_end_date"] {
    font-weight: 500;
    color: #0056b3;
}

/* Section headers */
.carmt-container h3 {
    color: #0056b3;
    border-bottom: 2px solid #f57c00;
    padding-bottom: 8px;
    margin-top: 30px;
    margin-bottom: 15px;
    font-weight: 500;
    position: relative;
}

.carmt-container h3::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 50px;
    height: 2px;
    background-color: #0056b3;
}

/* สไตล์สำหรับ Autocomplete */
.ui-autocomplete {
    max-width: 400px;
    width: 400px !important;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #ddd;
    font-family: 'Kanit', sans-serif;
    z-index: 9999;
    padding: 5px 0;
    max-height: 300px;
    overflow-y: auto;
}

.ui-autocomplete .ui-menu-item {
    padding: 0;
    border: none;
    margin: 0;
}

.ui-autocomplete .ui-menu-item-wrapper {
    padding: 0;
    border: none;
    margin: 0;
}

.ui-autocomplete .ui-autocomplete-item {
    padding: 10px 15px;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s;
}

.ui-autocomplete .ui-menu-item:last-child .ui-autocomplete-item {
    border-bottom: none;
}

.ui-autocomplete .ui-autocomplete-item:hover {
    background-color: #f5f5f5;
}

.ui-autocomplete .ui-state-active,
.ui-autocomplete .ui-state-focus {
    margin: 0 !important;
    border: none !important;
    background: #e8f0fe !important;
}

.ui-autocomplete .ui-autocomplete-term {
    font-size: 1em;
    font-weight: 500;
    color: #333;
}

.ui-autocomplete .ui-autocomplete-desc {
    font-size: 0.8em;
    color: #9e9e9e;
    margin-top: 3px;
}

.ui-helper-hidden-accessible {
    display: none;
}

.ui-autocomplete-loading {
    background: url('data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==') right center no-repeat;
}

/* สไตล์สำหรับคำอธิบายในตาราง */
.car-mt-description {
    font-size: 0.8em;
    color: #9e9e9e;
    margin-top: 3px;
    font-style: italic;
}

/* กำหนดให้ input กว้างพอสำหรับการพิมพ์ */
.mtdt-autocomplete {
    width: 100%;
}

/* ปรับแต่งการแจ้งเตือน */
#carmt-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.carmt-notification {
    display: flex;
    align-items: center;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    margin-bottom: 10px;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 350px;
    font-family: 'Kanit', sans-serif;
}

.carmt-notification.show {
    transform: translateX(0);
}

.carmt-notification.success {
    border-left: 4px solid #4CAF50;
}

.carmt-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;
}

/* สไตล์สำหรับการโหลด */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 86, 179, 0.2);
    border-radius: 50%;
    border-top-color: #0056b3;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.carmt-loading {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

/* สร้างแถบสีสำหรับเน้นบางกลุ่ม */
.carmt-table tbody tr.highlight {
    background-color: #e8f4fd;
}

/* เพิ่มเอฟเฟคสำหรับปุ่มเมื่อกด */
.carmt-filter-section button:active,
.carmt-add-button:active,
.carmt-save-button:active {
    transform: translateY(1px);
}

/* สไตล์เพิ่มเติมสำหรับรายการในตาราง */
.carmt-table td:nth-child(2) {  /* วันที่ซ่อม */
    font-weight: 500;
    color: #0056b3;
}

.carmt-table td:nth-child(6) {  /* ค่าใช้จ่าย */
    font-weight: 500;
    color: #f57c00;
    text-align: right;
}

/* เอฟเฟคเมื่อเพิ่มแถวใหม่ */
@keyframes highlight-new-row {
    from { background-color: #fffde7; }
    to { background-color: #f9f9f9; }
}

.carmt-new-row-highlight {
    animation: highlight-new-row 1s ease-out;
}

/* สไตล์สำหรับไอคอน "i" ในตาราง */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: #0056b3;
    color: white;
    font-size: 10px;
    font-weight: bold;
    margin-left: 6px;
    cursor: help;
    text-align: center;
    font-style: normal;
    vertical-align: text-top;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.info-icon:hover {
    background-color: #003d82;
    transform: scale(1.1);
}

/* สไตล์สำหรับไอคอน "i" ชั่วคราวในฟอร์ม */
.temp-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: #f57c00;
    color: white;
    font-size: 10px;
    font-weight: bold;
    margin-left: 6px;
    cursor: help;
    text-align: center;
    font-style: normal;
    vertical-align: middle;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    position: absolute;
    right: 25px;
    top: 50%;
    transform: translateY(-50%);
}

.temp-info-icon:hover {
    background-color: #e65100;
    transform: translateY(-50%) scale(1.1);
}

/* ปรับแต่ง position ของ input สำหรับรองรับไอคอน */
.carmt-form-group {
    position: relative;
}

/* สไตล์สำหรับ Tooltip (Tippy.js) */
.tippy-box[data-theme~='light'] {
    background-color: white;
    color: #333;
    border: 1px solid #ddd;
    font-family: 'Kanit', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    padding: 5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.tippy-box[data-theme~='light'][data-placement^='top'] > .tippy-arrow::before {
    border-top-color: white;
}

.tippy-box[data-theme~='light'][data-placement^='bottom'] > .tippy-arrow::before {
    border-bottom-color: white;
}

.tippy-box[data-theme~='light'][data-placement^='left'] > .tippy-arrow::before {
    border-left-color: white;
}

.tippy-box[data-theme~='light'][data-placement^='right'] > .tippy-arrow::before {
    border-right-color: white;
}

.tippy-content {
    text-align: left;
    padding: 8px 12px;
}

/* ปรับแต่งไอคอนให้เข้ากับตาราง */
.carmt-table td .info-icon {
    vertical-align: middle;
    line-height: 16px;
}

/* ส่วนของการตรวจสอบ Term และการแก้ไข */
.invalid-term {
    background-color: #FFE3E3;
    position: relative;
}

.invalid-term .maintenance-text {
    color: #D32F2F;
    font-weight: 500;
}

.edit-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #f57c00;
    color: white;
    font-size: 12px;
    font-weight: bold;
    margin-left: 8px;
    cursor: pointer;
    text-align: center;
    vertical-align: middle;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.edit-icon:hover {
    background-color: #e65100;
    transform: scale(1.1);
}

/* ฟอร์มแก้ไขรายการ */
#edit-maintenance-form {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    font-family: 'Kanit', sans-serif;
}

.edit-form-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.edit-form-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
}

.edit-form-content h4 {
    margin-top: 0;
    color: #0056b3;
    border-bottom: 2px solid #f57c00;
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-weight: 500;
}

.edit-form-row {
    margin-bottom: 20px;
}

.edit-form-group {
    margin-bottom: 15px;
}

.edit-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.edit-form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    transition: all 0.3s;
}

.edit-form-group input:focus {
    border-color: #0056b3;
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.25);
    outline: none;
}

.edit-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.edit-save-button {
    background-color: #0056b3;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.edit-save-button:hover {
    background-color: #003d82;
}

.edit-cancel-button {
    background-color: #f44336;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.edit-cancel-button:hover {
    background-color: #d32f2f;
}

/* ส่วนของ Pagination ที่ปรับปรุงแล้ว */
.carmt-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    font-family: 'Kanit', sans-serif;
    flex-wrap: wrap;
    gap: 10px;
}

.pagination-button {
    background-color: #0056b3;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    min-width: 100px;
}

.pagination-button:hover:not(:disabled) {
    background-color: #003d82;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.pagination-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.page-numbers-container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    margin: 0 10px;
}

.page-number-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #f0f0f0;
    color: #333;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-number-button:hover {
    background-color: #0056b3;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.page-number-button.active {
    background-color: #0056b3;
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

#page-info {
    margin: 0 10px;
    font-size: 14px;
    color: #555;
    white-space: nowrap;
}

/* Container สำหรับแถวใหม่ */
#new-maintenance-rows {
    margin: 20px 0;
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
    .carmt-form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .carmt-new-row {
        flex-direction: column;
        gap: 10px;
    }

    .carmt-button-group {
        flex-direction: column;
    }

    .ui-autocomplete {
        max-width: 90%;
        width: 90% !important;
    }
    
    .carmt-filter-section {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .carmt-filter-section input, 
    .carmt-filter-section button {
        width: 100%;
        margin-bottom: 8px;
    }

    #carmt-notification {
        width: 90%;
        left: 5%;
        right: 5%;
    }
    
    .carmt-notification {
        max-width: 100%;
    }
    
    .info-icon, .temp-info-icon {
        width: 14px;
        height: 14px;
        font-size: 9px;
    }
    
    .tippy-box[data-theme~='light'] {
        max-width: 250px !important;
    }
    
    .temp-info-icon {
        right: 15px;
    }
    
    .edit-form-content {
        width: 95%;
        padding: 15px;
    }
    
    .edit-form-actions {
        flex-direction: column;
    }
    
    .edit-save-button,
    .edit-cancel-button {
        width: 100%;
        margin-bottom: 10px;
    }
    
    /* ปรับแต่ง pagination สำหรับมือถือ */
    .carmt-pagination {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .page-numbers-container {
        margin: 10px 0;
        justify-content: center;
    }
    
    .pagination-button {
        width: 100%;
        max-width: 200px;
    }
}

/* การ์ดโหลดขอมูล */
.carmt-table-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    font-size: 16px;
    color: #0056b3;
    border-radius: 8px;
}


/* สไตล์สำหรับไอคอนแก้ไขค่าใช้จ่าย */
.edit-cost-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #f57c00;
    color: white;
    font-size: 12px;
    margin-left: 8px;
    cursor: pointer;
    text-align: center;
    vertical-align: middle;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.edit-cost-icon:hover {
    background-color: #e65100;
    transform: scale(1.1);
}

/* ปรับหน้าตาของเซลล์ค่าใช้จ่าย */
.maintenance-cost {
    position: relative;
}

/* เอฟเฟกต์เมื่อมีการอัพเดตค่าใช้จ่าย */
@keyframes highlight-cell {
    0% { background-color: #fffde7; }
    50% { background-color: #fff9c4; }
    100% { background-color: transparent; }
}

.cell-highlight {
    animation: highlight-cell 2s ease;
}

/* เพิ่มโฟกัสให้กับ input ในฟอร์มแก้ไข */
#edit-cost-amount:focus {
    border-color: #0056b3;
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.25);
    outline: none;
}