/**
 * CSS สำหรับฟังก์ชันลบประเภทเอกสาร
 * สีหลัก: น้ำเงิน (primary), ส้ม (secondary), ดำ (text)
 */
 :root {
    --primary-color: #1e3a8a;
    --primary-hover: #1e40af;
    --secondary-color: #f97316;
    --secondary-hover: #ea580c;
    --text-color: #111827;
    --light-gray: #f3f4f6;
    --border-color: #e5e7eb;
    --success-color: #10b981;
    --error-color: #ef4444;
}

/* Container สำหรับปุ่มและ Modal */
.remove-doctype-container {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-color);
}

/* ปุ่มหลัก */
.remove-doctype-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.remove-doctype-button:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Modal */
.remove-doctype-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.remove-doctype-modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 600px;
    position: relative;
    animation: modalFadeIn 0.3s;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalFadeIn {
    from {opacity: 0; transform: translateY(-20px);}
    to {opacity: 1; transform: translateY(0);}
}

/* ปุ่มปิด Modal */
.remove-doctype-close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.remove-doctype-close:hover {
    color: var(--text-color);
}

/* ส่วนหัว Modal */
.remove-doctype-modal-content h2 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 24px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

/* ส่วนค้นหา */
.remove-doctype-search-section {
    margin-bottom: 20px;
    position: relative;
}

#remove-doctype-search {
    width: 100%;
    padding: 12px 15px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

#remove-doctype-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

/* ผลการค้นหา */
.remove-doctype-results {
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: white;
}

.ui-autocomplete {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 0;
    list-style: none;
    z-index: 1001;
}

.ui-autocomplete .ui-menu-item {
    margin: 0;
    padding: 0;
}

.autocomplete-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.autocomplete-item:hover {
    background-color: var(--light-gray);
}

.autocomplete-item .item-title {
    font-weight: 500;
}

.autocomplete-item .item-doctype {
    color: #6b7280;
    font-size: 0.9em;
}

.no-results,
.error-results {
    padding: 15px;
    text-align: center;
    color: #6b7280;
}

.error-results {
    color: var(--error-color);
}

/* รายละเอียดเอกสาร */
.remove-doctype-details {
    background-color: var(--light-gray);
    border-radius: 6px;
    padding: 15px;
    margin-top: 20px;
}

.remove-doctype-details h3 {
    color: var(--primary-color);
    margin-top: 0;
    font-size: 18px;
    margin-bottom: 15px;
}

.remove-doctype-details p {
    margin: 8px 0;
    line-height: 1.5;
}

/* ปุ่มเคลียร์ค่า */
.clear-doctype-button {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 18px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s;
    margin-top: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.clear-doctype-button:hover {
    background-color: var(--secondary-hover);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.clear-doctype-button:disabled {
    background-color: #d1d5db;
    cursor: not-allowed;
    box-shadow: none;
}

/* ข้อความแจ้งเตือน */
.remove-doctype-message {
    margin-top: 15px;
}

.success-message {
    background-color: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success-color);
    color: var(--success-color);
    padding: 10px;
    border-radius: 4px;
}

.error-message {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 10px;
    border-radius: 4px;
}

/* ส่วนแสดงประวัติ */
.document-history {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed var(--border-color);
}

.document-history h4 {
    color: var(--primary-color);
    font-size: 16px;
    margin-top: 0;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.document-history h4:before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%231e3a8a'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    margin-right: 8px;
}

.history-content {
    max-height: 300px;
    overflow-y: auto;
    background-color: white;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.loading-history {
    padding: 15px;
    text-align: center;
    color: #6b7280;
    font-style: italic;
}

.no-history,
.error-history {
    padding: 15px;
    text-align: center;
}

.error-history {
    color: var(--error-color);
}

.history-list {
    padding: 0;
}

.history-item {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    line-height: 1.5;
    position: relative;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    background-color: var(--light-gray);
}

/* จัดรูปแบบรายการประวัติล่าสุด (หลังจากการอัพเดต) */
.history-item-new {
    background-color: rgba(249, 115, 22, 0.05);
    border-left: 3px solid var(--secondary-color);
    animation: highlightHistory 2s ease-in-out;
}

@keyframes highlightHistory {
    0% {
        background-color: rgba(249, 115, 22, 0.2);
    }
    100% {
        background-color: rgba(249, 115, 22, 0.05);
    }
}

/* ข้อความเมื่อไม่มีข้อมูล */
.no-history {
    color: #6b7280;
    font-style: italic;
}

/* Custom scrollbar สำหรับส่วนประวัติ */
.history-content::-webkit-scrollbar {
    width: 6px;
}

.history-content::-webkit-scrollbar-track {
    background: var(--light-gray);
    border-radius: 3px;
}

.history-content::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
}

.history-content::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

/* แบ่งข้อมูลในประวัติให้ดูง่ายขึ้น */
.history-item {
    position: relative;
    padding-left: 10px;
}

.history-item:before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 70%;
    background-color: #cbd5e1;
    border-radius: 2px;
}

/* Responsive */
@media (max-width: 768px) {
    .remove-doctype-modal-content {
        margin: 10% auto;
        padding: 20px;
        width: 95%;
    }
    
    #remove-doctype-search {
        padding: 10px;
    }
    
    .history-content {
        max-height: 200px;
    }
    
    .history-item {
        padding: 10px;
        font-size: 13px;
    }
}

/* ไฮไลท์ข้อความในประวัติ */
.history-item strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* ฟอร์แมตวันที่ในประวัติให้ชัดเจน */
.history-date {
    color: #64748b;
    font-size: 0.9em;
}

/* ระบุประเภทการแก้ไขในประวัติ */
.history-action {
    color: var(--secondary-color);
    font-weight: 500;
}