@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600&display=swap');

:root {
  --primary: #ff6b00;
  --primary-hover: #e65c00;
  --primary-light: #fff5eb;
  --text-dark: #2d3748;
  --text-light: #718096;
  --border: #e2e8f0;
  --bg-main: #fffaf0;
}

* { box-sizing: border-box; font-family: 'Kanit', sans-serif; margin: 0; padding: 0; }

body { background-color: var(--bg-main); display: flex; justify-content: center; min-height: 100vh; padding: 20px; }

.app-wrapper { 
  width: 100%; 
  max-width: 1000px; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  animation: pageFadeIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

.back-hub-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dark);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 14px;
  padding: 8px 16px;
  border-radius: 99px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.back-hub-btn svg { transition: transform 0.2s ease; }
.back-hub-btn:hover {
  color: var(--primary);
  border-color: rgba(255, 107, 0, 0.35);
  background: var(--primary-light);
  transform: translateX(-4px);
}
.back-hub-btn:hover svg { stroke: var(--primary); transform: translateX(-2px); }

.app-container {
  background: #ffffff;
  width: 100%;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(255, 107, 0, 0.08);
  display: flex;
  overflow: hidden;
  margin-bottom: 20px;
}

.sidebar {
  width: 35%;
  background: linear-gradient(160deg, #ff8c00 0%, #ff512f 100%); 
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
}

.logo-circle {
  width: 80%;
  max-width: 220px;
  height: auto; 
  background: #ffffff;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px 20px;
  margin-bottom: 20px;
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
  animation: pulse-glow 2.5s infinite;
}

.company-logo {
  width: 100%;
  height: auto;
  object-fit: contain;
}

@keyframes pulse-glow {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(255, 255, 255, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.sidebar h3 { font-size: 16px; font-weight: 400; margin-bottom: 5px; opacity: 0.9; }
.sidebar h1 { font-size: 30px; font-weight: 600; letter-spacing: 0.5px; }

.form-section { width: 65%; padding: 50px; }
.form-title { color: var(--primary); font-size: 26px; font-weight: 600; margin-bottom: 28px; } 

.grid-2-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13.5px; font-weight: 500; color: var(--text-dark); margin-bottom: 5px; }
.form-group label span { color: #ef4444; }

.input-field {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-dark);
  background: transparent;
  outline: none;
  transition: all 0.3s;
}

.input-field::placeholder { color: #a0aec0; font-weight: 300; }
.input-field:focus { border-bottom: 2px solid var(--primary); padding-bottom: 7px; }

.upload-box {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 20px 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; cursor: pointer; background: #ffffff; transition: all 0.2s;
}
.upload-box:hover { border-color: var(--primary); background: #fffaf0; }
.upload-box span { font-size: 12px; color: var(--text-light); text-align: center; word-break: break-all;}
.upload-box:hover svg { stroke: var(--primary); transition: stroke 0.2s;}

.submit-btn {
  width: 100%; background-color: var(--primary); color: white; border: none;
  padding: 14px; border-radius: 8px; font-size: 16px; font-weight: 600;
  cursor: pointer; margin-top: 10px; box-shadow: 0 4px 10px rgba(255, 107, 0, 0.2);
  transition: all 0.3s;
}
.submit-btn:hover { background-color: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 6px 15px rgba(255, 107, 0, 0.3); }
.submit-btn:disabled { background-color: #cbd5e1; cursor: not-allowed; box-shadow: none; transform: none;}

.footer { width: 100%; max-width: 1000px; background: #2d3748; color: #fff; text-align: center; padding: 15px; font-size: 12px; border-radius: 8px; }

@media (max-width: 768px) {
  .app-container { flex-direction: column; }
  .sidebar { width: 100%; padding: 40px 30px; }
  .form-section { width: 100%; padding: 30px 20px; }
  .grid-2-cols { grid-template-columns: 1fr; gap: 15px; }
}

/* Modal Popup แจ้งเตือนสถานะการทำงาน */
.status-modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; z-index: 99999;
  opacity: 0; visibility: hidden; transition: opacity 0.25s ease, visibility 0.25s ease;
}
.status-modal-overlay.active { opacity: 1; visibility: visible; }
.status-modal-card {
  background: #ffffff; width: 90%; max-width: 350px; border-radius: 24px;
  padding: 32px 24px 28px; text-align: center; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  transform: scale(0.85); transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.status-modal-overlay.active .status-modal-card { transform: scale(1); }
.status-modal-card.anim-pop { animation: modalPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
@keyframes modalPop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  80% { transform: scale(0.96); }
  100% { transform: scale(1); }
}
.status-modal-card.anim-shake { animation: modalShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
@keyframes modalShake {
  10%, 90% { transform: translate3d(-3px, 0, 0); }
  20%, 80% { transform: translate3d(5px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-7px, 0, 0); }
  40%, 60% { transform: translate3d(7px, 0, 0); }
}
.modal-icon-box { width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.modal-icon-box.loading-bg { background: #fff5eb; }
.modal-icon-box.success-bg { background: #ecfdf5; }
.modal-icon-box.error-bg { background: #fef2f2; }
.svg-spin { animation: iconSpin 0.9s linear infinite; }
@keyframes iconSpin { 100% { transform: rotate(360deg); } }
.check-path { stroke-dasharray: 48; stroke-dashoffset: 48; animation: drawStroke 0.4s ease-out 0.15s forwards; }
@keyframes drawStroke { to { stroke-dashoffset: 0; } }
.modal-title { font-size: 20px; font-weight: 600; color: var(--text-dark); margin-bottom: 8px; }
.modal-desc { font-size: 14px; color: var(--text-light); line-height: 1.5; margin-bottom: 22px; word-break: break-word; }
.modal-btn {
  width: 100%; padding: 12px; border-radius: 10px; border: none; font-size: 15px; font-weight: 500;
  cursor: pointer; background: #f1f5f9; color: #334155; transition: all 0.2s;
}
.modal-btn:hover { background: #e2e8f0; }
.modal-btn.btn-primary { background: var(--primary); color: #ffffff; }
.modal-btn.btn-primary:hover { background: var(--primary-hover); }

/* สไตล์สำหรับปุ่มเปิดเงื่อนไขประกันและแอนิเมชัน SVG */
.warranty-info-container {
  margin-bottom: 20px;
}

.warranty-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px dashed var(--primary);
  padding: 14px 20px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: all 0.3s ease;
}

.warranty-btn:hover {
  background: #ffedd6;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 0, 0.15);
}

.warranty-svg-icon {
  animation: floatIcon 2.5s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Dialog Modal ป๊อปอัพเงื่อนไขการรับประกัน (Native HTML) */
.warranty-modal {
  margin: auto;
  padding: 0;
  border: none;
  border-radius: 20px;
  background: #ffffff;
  width: 90%;
  max-width: 650px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.warranty-modal[open] {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.warranty-modal::backdrop {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.warranty-modal[open]::backdrop {
  opacity: 1;
}

.warranty-modal-content {
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.warranty-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 20px 20px 0 0;
}

.warranty-modal-header h2 {
  font-size: 18px;
  color: var(--text-dark);
  font-weight: 600;
  margin: 0;
}

.close-dialog-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.close-dialog-btn:hover {
  background: #f1f5f9;
  color: #ef4444;
}

.warranty-modal-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 14px;
  color: var(--text-dark);
  line-height: 1.6;
}

.warranty-list {
  padding-left: 20px;
  margin-bottom: 24px;
}

.warranty-list li {
  margin-bottom: 10px;
}

.warranty-modal-body h3 {
  font-size: 16px;
  color: var(--primary);
  margin: 0 0 12px 0;
  font-weight: 600;
}

.warranty-exclusion-list {
  padding-left: 20px;
  margin-bottom: 24px;
}

.warranty-exclusion-list li {
  margin-bottom: 8px;
}

.warranty-remark {
  background: #fef2f2;
  border-left: 4px solid #ef4444;
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin: 0;
  color: #991b1b;
}

/* 1. อนิเมชั่นเด้งป๊อปอัพตัวหน้าต่าง */
.warranty-modal[open] {
  animation: modalPopBounce 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes modalPopBounce {
  0% { transform: translateY(40px) scale(0.5); opacity: 0; }
  50% { transform: translateY(-8px) scale(1.05); opacity: 1; }
  75% { transform: translateY(4px) scale(0.98); }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* 2. อนิเมชั่นสร้างเครื่องหมายตกใจแบบลากเส้นทีละส่วน */
.alert-icon-box {
  display: flex;
  justify-content: center;
  margin-top: -10px;
  margin-bottom: 20px;
}

/* เส้นวงกลมด้านนอก */
.play-anim .draw-outline {
  stroke-dasharray: 65; /* ความยาวเส้นรอบวงโดยประมาณ */
  stroke-dashoffset: 65;
  animation: drawStroke 0.5s ease-out 0.2s forwards;
}

/* ขีดตกใจตรงกลาง */
.play-anim .draw-line {
  stroke-dasharray: 10;
  stroke-dashoffset: 10;
  animation: drawStroke 0.3s ease-out 0.6s forwards;
}

/* จุดตกใจด้านล่าง */
.play-anim .draw-dot {
  stroke-dasharray: 2;
  stroke-dashoffset: 2;
  animation: drawStroke 0.2s ease-out 0.8s forwards;
}

@keyframes drawStroke {
  to { stroke-dashoffset: 0; }
}