/* ============================================================
   borrow.css — หน้ายืม-คืนอุปกรณ์
   ============================================================ */

/* Borrow Cart List */
.borrow-cart-box {
    background: #f8fafc;
    border: 1px dashed var(--primary-color);
    border-radius: 10px;
    padding: 10px;
    margin-top: 8px;
}

.borrow-cart-list {
    list-style: none;
    margin-top: 6px;
}

.borrow-cart-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    padding: 4px 0;
    border-bottom: 1px solid #e2e8f0;
}

.borrow-cart-list li:last-child {
    border-bottom: none;
}

.btn-remove-cart {
    background: #fee2e2;
    color: var(--danger-strong);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 16px;
}

/* Proof Preview */
.proof-preview-box {
    margin-top: 8px;
    width: 100%;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px dashed var(--border-color);
}

.proof-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.borrow-card {
    background: var(--card-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 22px; /* ขยาย Padding ของ Card การยืมให้ใหญ่ขึ้น */
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    transition: border-color 0.15s;
}

.borrow-card.overdue {
    border-color: var(--danger-strong);
    border-left: 12px solid var(--danger-strong);
    background: #fef2f2;
}

.borrow-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border-color);
}

.borrow-borrower {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.borrow-total-badge {
    background: #1d4ed8;
    color: white;
    font-size: 14px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 14px;
}

.borrow-items-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.borrow-item-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.borrow-thumb {
    position: relative;
    width: 60px;  /* ขยายขนาด Thumbnail รูปรายการยืม */
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: pointer;
    background: #f8fafc;
    flex-shrink: 0;
}

.borrow-thumb.proof {
    border-color: var(--primary-color);
    width: 80px;
    height: 80px;
}

.borrow-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 11px;
    text-align: center;
    padding: 1px 0;
}

.borrow-details {
    flex: 1;
    min-width: 0;
}

.borrow-item-name {
    font-size: 15px;
    color: var(--text-main);
    font-weight: 700;
}

.borrow-item-spec {
    font-size: 13px;
    color: var(--primary-color);
    font-weight: 600;
}

.borrow-qty-badge {
    background: #eff6ff;
    color: #1e40af;
    font-size: 14px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 10px;
    border: 1px solid #bfdbfe;
    white-space: nowrap;
}

.borrow-proof-section {
    margin-top: 4px;
}

.borrow-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 13.5px;
    color: var(--text-muted);
}

.borrow-dates span strong {
    color: var(--text-main);
}

.borrow-dates .overdue-text strong {
    color: var(--danger-strong);
}

/* ข้อความบอกว่าเหลือกี่วัน / ครบวันนี้ */
.due-note {
    font-weight: 700;
    color: var(--text-muted);
}

.due-note.soon {
    color: var(--warning-strong);
}

.due-note.late {
    color: var(--danger-strong);
}

.borrow-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 15px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 12px;
    width: fit-content;
}

.borrow-status-badge.status-borrowed {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.borrow-status-badge.status-overdue {
    background: var(--danger-strong);
    color: #ffffff;
    border: 1px solid #991b1b;
}

.borrow-status-badge.status-returned {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.borrow-card-bottom {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid #f1f5f9;
}

.btn-return {
    background: var(--success-strong);
    color: white;
    border: none;
    padding: 12px 20px;
    min-height: 48px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-return:hover {
    opacity: 0.9;
}

/* ============================================================
   [NEW] Partial Return / Extend Due Date
   ============================================================ */

/* ป้ายจำนวนกรณีคืนบางส่วน */
.borrow-qty-badge.partial {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

.borrow-qty-badge.done {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

/* ปุ่มขยายเวลา (สไตล์เดียวกับ .btn-return) */
.btn-extend {
    background: var(--warning-strong);
    color: white;
    border: none;
    padding: 12px 20px;
    min-height: 48px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-extend:hover {
    opacity: 0.9;
}

/* Modal แบบกว้าง + เนื้อหาชิดซ้าย (ใช้กับ modal คืนอุปกรณ์ / ขยายเวลา) */
.modal-card.modal-card-wide {
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-card .modal-form {
    text-align: left;
    margin-bottom: 16px;
}

.modal-card .modal-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.modal-card .modal-form .form-group {
    margin-bottom: 12px;
}

.modal-current-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

/* รายการอุปกรณ์ใน Modal คืนของ */
.return-item-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    text-align: left;
}

.return-item-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 10px;
}

.return-item-info {
    flex: 1;
    min-width: 0;
}

.return-item-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.return-item-sub {
    font-size: 13px;
    color: var(--text-muted);
}

.return-item-input {
    width: 72px;
    padding: 8px 6px;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
}

.return-item-done {
    font-size: 12px;
    font-weight: 700;
    color: #065f46;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 10px;
    padding: 3px 10px;
    white-space: nowrap;
}

.btn-fill-all {
    background: transparent;
    border: 1.5px dashed var(--success-strong);
    color: var(--success-strong);
    font-size: 14px;
    font-weight: 700;
    min-height: 44px;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 14px;
}

.btn-fill-all:hover {
    background: #ecfdf5;
}

/* ประวัติการคืน / ขยายเวลาในการ์ด */
.borrow-history {
    font-size: 13px;
    color: var(--text-muted);
}

.borrow-history summary {
    cursor: pointer;
    font-weight: 600;
    width: fit-content;
}

.borrow-history ul {
    list-style: none;
    margin-top: 6px;
    padding-left: 4px;
}

.borrow-history li {
    padding: 3px 0;
    border-bottom: 1px dashed #e2e8f0;
}

.borrow-history li:last-child {
    border-bottom: none;
}

.extend-count-badge {
    color: #92400e;
}

/* ============================================================
   [NEW] กล่องค้นหา + เลือก + ลบชื่อผู้ยืม ในที่เดียว (Borrower combo)
   ============================================================ */

.borrower-combo {
    position: relative;
}

.borrower-dropdown-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    margin-top: 4px;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    max-height: 220px;
    overflow-y: auto;
}

.borrower-dropdown-list.open {
    display: block;
}

.borrower-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    min-height: 48px;
    font-size: 15px;
    color: var(--text-main);
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
}

.borrower-dropdown-item:last-child {
    border-bottom: none;
}

/* แถว "+ เพิ่มชื่อใหม่..." ท้ายรายการ (ใช้ในคอมโบผู้เบิก/ผู้ยืม) */
.borrower-dropdown-item.borrower-dropdown-add {
    color: var(--primary-color);
    font-weight: 700;
    background: #f8fafc;
}

.borrower-dropdown-item.borrower-dropdown-add:hover {
    background: #eff6ff;
}

.borrower-dropdown-item:hover {
    background: #eff6ff;
}

.borrower-dropdown-empty {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.dropdown-stock-badge {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.dropdown-stock-badge.warning {
    color: #b45309;
}

.dropdown-stock-badge.danger {
    color: #b91c1c;
}

/* ============================================================
   [NEW] ปุ่ม "ดูรูปหลักฐาน" (รูปจริงโหลดตอนกดดู ไม่ฝังในการ์ดแล้ว)
   ============================================================ */
.btn-proof {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 16px;
    background: #eff6ff;
    border: 1.5px solid var(--primary-color);
    border-radius: 10px;
    color: var(--primary-hover);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.btn-proof:hover {
    background: #dbeafe;
}
