/* css/form-style.css */

/* Global box-sizing for responsive layout */
*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --primary-color: #2c3e50; /* สีน้ำเงินเข้ม */
  --accent-color: #3498db; /* สีฟ้าสดใส */
  --success-color: #2ecc71; /* สีเขียว */
  --danger-color: #e74c3c; /* สีแดง */
  --text-color: #34495e; /* สีตัวอักษร */
  --bg-color: #f4f6f9; /* สีพื้นหลัง */
  --card-bg: #ffffff; /* สีพื้นหลังการ์ด */
  --border-radius: 0.5rem;
}

html {
  font-size: 16px;
}

body {
  font-family: "Sarabun", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 1.25rem;
  line-height: 1.6;
  min-height: 100vh;
  width: 100%;
}

/* Container หลักของฟอร์ม - Responsive with viewport units */
.form-container {
  width: 100%;
  max-width: 56.25rem; /* 900px */
  margin: 0 auto;
  background: var(--card-bg);
  padding: 1.875rem;
  border-radius: var(--border-radius);
  box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.05);
}

/* ส่วนหัว - Responsive */
.form-header {
  text-align: center;
  margin-bottom: 1.875rem;
  border-bottom: 0.125rem solid #eee;
  padding-bottom: 1.25rem;
}

.form-header h2 {
  margin: 0 0 0.3125rem 0;
  color: var(--primary-color);
}

.form-header p {
  margin: 0;
  color: #7f8c8d;
  font-size: 0.9rem;
}

/* การจัด Layout ของฟอร์ม */
.form-section {
  margin-bottom: 1.875rem;
  padding: 1.25rem;
  background: #fff;
  border: 0.0625rem solid #eee;
  border-radius: var(--border-radius);
}

.form-section h3 {
  margin-top: 0;
  margin-bottom: 1.25rem;
  color: var(--primary-color);
  font-size: 1.1rem;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 0.9375rem;
}

.form-col {
  flex: 1;
  min-width: 15.625rem; /* 250px - รองรับมือถือ */
}

.form-group {
  margin-bottom: 0.9375rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.3125rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-color);
}

/* Input Styles */
input[type="text"],
input[type="date"],
input[type="tel"],
input[type="email"],
textarea,
select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 0.0625rem solid #ced4da;
  border-radius: 0.25rem;
  font-family: inherit;
  font-size: 1rem;
  box-sizing: border-box; /* สำคัญเพื่อไม่ให้ padding ดันขนาดเกิน */
  transition: border-color 0.2s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 0.1875rem rgba(52, 152, 219, 0.1);
}

textarea {
  resize: vertical;
}

/* ปุ่มกด (Buttons) */
.form-footer {
  text-align: center;
  margin-top: 1.875rem;
}

button[type="submit"] {
  background-color: var(--primary-color);
  color: white;
  padding: 0.75rem 1.875rem;
  border: none;
  border-radius: 3.125rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 0.3s,
    transform 0.2s;
  box-shadow: 0 0.25rem 0.375rem rgba(0, 0, 0, 0.1);
}

button[type="submit"]:hover {
  background-color: var(--accent-color);
  transform: translateY(-2px);
}

button[type="submit"]:disabled {
  background-color: #95a5a6;
  cursor: not-allowed;
  transform: none;
}

/* =========================================
   COMPREHENSIVE MOBILE RESPONSIVE STYLES
   ========================================= */

/* Large Tablets (992px and below) */
@media (max-width: 992px) {
  .form-container {
    max-width: 95%;
    padding: 25px;
  }

  .form-col {
    min-width: 200px;
  }
}

/* Tablets (768px and below) */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .form-container {
    padding: 20px;
    max-width: 100%;
  }

  .form-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
  }

  .form-header h2 {
    font-size: 1.3rem;
  }

  .form-section {
    padding: 15px;
    margin-bottom: 20px;
  }

  .form-section h3 {
    font-size: 1rem;
    margin-bottom: 15px;
  }

  .form-row {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
  }

  .form-col {
    min-width: 100%;
  }

  .form-group {
    margin-bottom: 12px;
  }

  .form-group label {
    font-size: 0.85rem;
    margin-bottom: 4px;
  }

  input[type="text"],
  input[type="date"],
  input[type="tel"],
  input[type="email"],
  textarea,
  select {
    padding: 12px;
    font-size: 16px; /* Prevent zoom on iOS */
    min-height: 44px; /* Touch-friendly */
  }

  textarea {
    min-height: 100px;
  }

  .form-footer {
    margin-top: 20px;
  }

  button[type="submit"] {
    width: 100%;
    padding: 14px 20px;
    font-size: 1rem;
    min-height: 48px;
  }

  .form-footer {
    margin-top: 20px;
  }

  button[type="submit"] {
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
  }

  .photo-upload-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }
}

/* Mobile (480px and below) */
@media (max-width: 480px) {
  body {
    padding: 0;
    background-color: var(--card-bg);
  }

  .form-container {
    padding: 1rem;
    border-radius: 0;
    box-shadow: none;
    max-width: 100%;
  }

  .form-header {
    margin-bottom: 15px;
    padding-bottom: 12px;
  }

  .form-header h2 {
    font-size: 1.15rem;
  }

  .form-header p {
    font-size: 0.85rem;
  }

  .form-section {
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 6px;
  }

  .form-section h3 {
    font-size: 0.95rem;
    margin-bottom: 12px;
  }

  .form-row {
    gap: 10px;
    margin-bottom: 10px;
  }

  .form-col {
    min-width: 100%;
    flex: 1 1 100%;
  }

  .form-group {
    margin-bottom: 10px;
  }

  .form-group label {
    font-size: 0.8rem;
  }

  input[type="text"],
  input[type="date"],
  input[type="tel"],
  input[type="email"],
  textarea,
  select {
    padding: 10px;
    font-size: 16px;
    min-height: 44px;
    border-radius: 4px;
  }

  textarea {
    min-height: 80px;
  }

  .form-footer {
    margin-top: 15px;
  }

  button[type="submit"] {
    padding: 12px 16px;
    font-size: 0.95rem;
    min-height: 44px;
    border-radius: 25px;
  }

  .photo-upload-grid {
    grid-template-columns: 1fr !important; /* Single column on small mobile */
    gap: 8px;
  }
}

/* Small Mobile (360px and below) */
@media (max-width: 360px) {
  body {
    padding: 5px;
  }

  .form-container {
    padding: 12px;
  }

  .form-header h2 {
    font-size: 1.1rem;
  }

  .form-section {
    padding: 10px;
  }

  input[type="text"],
  input[type="date"],
  input[type="tel"],
  input[type="email"],
  textarea,
  select {
    padding: 8px;
    font-size: 15px;
  }

  button[type="submit"] {
    padding: 10px 14px;
    font-size: 0.9rem;
  }
}

/* Touch-friendly improvements for all mobile devices */
@media (hover: none) and (pointer: coarse) {
  input[type="text"],
  input[type="date"],
  input[type="tel"],
  input[type="email"],
  textarea,
  select,
  button {
    min-height: 44px; /* iOS recommended minimum */
  }

  button[type="submit"]:hover {
    transform: none; /* Remove hover effects on touch devices */
  }

  button[type="submit"]:active {
    transform: scale(0.98);
  }
}
