/* ==========================================
// 5. ไฟล์จัดการความสวยงามและตอบสนองของหน้าจอแสดงผล (CSS)
// ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0');

:root {
  --primary-color: #8B0000;    
  --primary-hover: #700000;    
  --accent-color: #B22222;     
  --bg-color: #f1f5f9;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --border-color: #cbd5e1;
  --card-shadow: 0 4px 15px rgba(139, 0, 0, 0.05);
  --font-main: 'Sarabun', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-main); background-color: var(--bg-color); color: var(--text-dark); -webkit-font-smoothing: antialiased; }

/* Utilities สำหรับการจัดการทั่วไป */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-theme { color: var(--primary-color); }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--accent-color); }
.text-success { color: #16a34a; }
.fw-bold { font-weight: 700; }
.w-100 { width: 100%; }
.cursor-pointer { cursor: pointer; }
.small { font-size: 0.82rem; }
.fs-1 { font-size: 2.2rem; }
.fs-3 { font-size: 1.5rem; }
.fs-5 { font-size: 1.25rem; }
.block { display: block; }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }

.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.my-1 { margin-top: 0.25rem; margin-bottom: 0.25rem; }
.my-2 { margin-top: 0.5rem; margin-bottom: 0.5rem; }

/* โครงร่างกรอบนอกของเว็บแอปพลิเคชัน (Mobile-first app container) */
.app-container { max-width: 480px; margin: 0 auto; min-height: 100vh; background: #ffffff; box-shadow: 0 10px 25px rgba(0,0,0,0.05); position: relative; }
.app-navbar { background: var(--primary-color); color: #ffffff; padding: 1rem 1.25rem; position: sticky; top: 0; z-index: 100; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }

.brand-logo-circle { width:80px; height:80px; background:var(--primary-color); color:white; border-radius:50%; margin:0 auto 1.5rem auto; display:flex; align-items:center; justify-content:center; box-shadow: 0 4px 10px rgba(139, 0, 0, 0.2); }
.nav-logout-icon { opacity: 0.8; transition: transform 0.2s; }
.nav-logout-icon:hover { opacity: 1; transform: scale(1.1); }

/* กล่องการ์ดเนื้อหา */
.card-theme { background: #ffffff; border: 1px solid var(--border-color); border-radius: 12px; padding: 1rem; box-shadow: var(--card-shadow); margin-bottom: 1rem; }
.card-highlight { background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%); color: #ffffff; padding: 1rem 1.25rem; border-radius: 12px; margin-bottom: 1rem; box-shadow: 0 4px 15px rgba(139,0,0,0.15); }
.result-box { background: #fff5f5; border: 1px solid #fecaca; padding: 1rem; border-radius: 12px; text-align: center; }

.border-left-highlight { border-left: 5px solid var(--primary-color) !important; }

/* องค์ประกอบกล่องรับข้อมูลแบบฟอร์ม */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.35rem; font-size: 0.88rem; color: #475569; font-weight: 500; }
.form-control, .form-select { width: 100%; padding: 0.65rem 0.75rem; border: 1px solid var(--border-color); border-radius: 8px; font-family: inherit; font-size: 0.92rem; outline: none; transition: border-color 0.2s; background-color: #f8fafc; }
.form-control:focus, .form-select:focus { border-color: var(--primary-color); background-color: #ffffff; box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.08); }

/* ปุ่มต่าง ๆ */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.7rem 1.2rem; border: none; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 0.95rem; font-weight: 500; transition: all 0.2s; gap: 4px; }
.btn-primary { background: var(--primary-color); color: #ffffff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-light { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.btn-light:hover { background: #e2e8f0; }
.btn-dark { background: #0f172a; color: #ffffff; }
.btn-dark:hover { background: #1e293b; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; border-radius: 6px; }

/* ป้ายกำกับ (Badges) */
.badge { padding: 0.3rem 0.6rem; border-radius: 6px; font-size: 0.72rem; font-weight: 700; background: #f1f5f9; color: #334155; }
.badge-white { background: rgba(255,255,255,0.2); color: #ffffff; border: 1px solid rgba(255,255,255,0.3); }

/* กล่องเตือนกระตุ้นความสนใจ */
.alert { padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.85rem; margin-bottom: 1rem; }
.alert-info { background-color: #f0f9ff; border: 1px solid #bae6fd; color: #0369a1; }
.alert-success { background-color: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }

/* รูปแบบหน้าต่างโมดอลทับหลังจอ (Modals) */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); display: flex; justify-content: center; align-items: center; z-index: 1000; backdrop-filter: blur(4px); }
.modal-content { background: #ffffff; width: 92%; max-width: 500px; border-radius: 14px; overflow: hidden; max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.15); animation: zoomIn 0.25s ease-out; }
.modal-header { padding: 1.1rem 1.5rem; background: var(--primary-color); color: white; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.25rem 1.5rem; overflow-y: auto; }
.btn-close { background: transparent; border: none; color: white; cursor: pointer; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; }

/* แถบการเลือกแบบแท็บ (Tab Controls) */
.tabs { display: flex; background: #f1f5f9; border-radius: 50px; padding: 0.25rem; margin-bottom: 1rem; border: 1px solid #e2e8f0; }
.tab-btn { flex: 1; border: none; background: transparent; padding: 0.55rem; border-radius: 50px; cursor: pointer; font-family: inherit; font-size: 0.88rem; transition: background 0.2s; color: #64748b; }
.tab-btn.active { background: #ffffff; color: var(--primary-color); font-weight: bold; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ม่านโหลดหน้าจอหลัก */
#loader { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.85); display: flex; justify-content: center; align-items: center; z-index: 9999; }
.loader-content { text-align: center; }
.spinner { width: 40px; height: 40px; border: 4px solid #cbd5e1; border-top-color: var(--primary-color); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto; }

/* โครงสร้างพิมพ์สลิปและใบเสร็จ (Receipt Layout) */
.receipt-card-box { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 1.25rem; }
.receipt-icon-logo { width: 50px; height: 50px; background: #f8fafc; color: var(--primary-color); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto; border: 1px solid #e2e8f0; }
.receipt-dashed-line { border-top: 2px dashed #cbd5e1; margin: 0.75rem 0; }
.receipt-detail-row { display: flex; justify-content: space-between; font-size: 13px; margin: 0.25rem 0; }

/* ตารางแสดงรายงานประวัติการเงิน */
.table-container { width: 100%; overflow-x: auto; background: #ffffff; border-radius: 12px; border: 1px solid var(--border-color); padding: 4px; box-shadow: var(--card-shadow); }
.clean-table { width: 100%; border-collapse: collapse; }
.clean-table th { padding: 10px 12px; font-size: 0.78rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; border-bottom: 2px solid #f1f5f9; background-color: #f8fafc; }
.clean-table td { padding: 12px; font-size: 0.85rem; vertical-align: middle; border-bottom: 1px solid #f1f5f9 !important; }
.clean-table tbody tr:last-child td { border-bottom: none !important; }
.clean-table tbody tr:hover { background-color: #fafafa; }
.tx-code { color: var(--accent-color); font-weight: bold; font-size: 0.8rem; }
.tx-time { font-size: 0.72rem; color: var(--text-muted); }

/* กล้องสแกนคิวอาร์และบอร์ดรองรับลายเซ็น */
.qr-camera-box { width: 100%; min-height: 250px; background: #000000; border-radius: 10px; overflow: hidden; border: 2px solid #64748b; margin: 8px 0; }
.signature-canvas-wrapper { background: #ffffff; border: 2px dashed #64748b; border-radius: 8px; touch-action: none; overflow: hidden; display: flex; margin: 8px 0; position: relative; height: 180px; }
#signature-pad-canvas { width: 100%; height: 100%; cursor: crosshair; }

/* การจัดการช่องอัปโหลดใบเสร็จสลิปโอนเงิน */
.slip-upload-container {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  background-color: #f8fafc;
  transition: all 0.25s ease-in-out;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 120px;
}
.slip-upload-container:hover {
  border-color: var(--primary-color);
  background-color: #fff5f5;
}
.slip-upload-container.has-file {
  border-style: solid;
  border-color: #10b981;
  background-color: #ffffff;
}
.slip-upload-container .upload-icon {
  font-size: 2.5rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.slip-upload-container .upload-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}
#slip-preview {
  max-width: 100%;
  max-height: 180px;
  object-fit: contain;
  margin-bottom: 0.5rem;
}

/* ภาพจัดแสดงสลิปฝั่ง Admin Control panel */
.admin-slip-view-img {
  max-width: 100%;
  max-height: 160px;
  display: block;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 6px;
  object-fit: contain;
}

.admin-border { border-left: 5px solid #e11d48 !important; }
.hover-shadow:hover { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05); }

/* คีย์เฟรมแอนิเมชันสำหรับโหลดดิ้งซอฟต์แวร์ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes zoomIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }