/* =====================================================
   EABaseHub — formPlan.css (Pastel Mint Theme)
   ===================================================== */

/* =====================================================
   1. CSS VARIABLES
   ===================================================== */
   @import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&family=IBM+Plex+Sans+Thai:wght@300;400;500;600&display=swap');

:root {
  /* Pastel Mint */
  --mint-50:  #f4fdf9;
  --mint-100: #e0f7ed;
  --mint-200: #b8ebd4;
  --mint-300: #8fdfba;
  --mint-400: #6dd3a3;
  --mint-500: #4caf8a;
  --mint-600: #3d8c6f;
  --mint-700: #2f6b54;
  --mint-800: #234d3d;

  --mint-900: #25A385;     /* base */

  --mint-light-50: #E8F6F3;
  --mint-light-100: #B5E3D9;
  --mint-light-200: #82D1BF;
  --mint-light-300: #4FBEA5;
  --mint-light-400: #25A385;    /* base */

  --mint-dark-500: #1E826A;
  --mint-dark-600: #176250;
  --mint-dark-700: #104135;
  --mint-dark-800: #08211B;

  /* Sage Green */
  --sage-100: #d9ebd9;
  --sage-300: #8cc68c;
  --sage-400: #66b366;
  --sage-500: #4d994d;

  /* Warm Gray */
  --gray-50:  #fafaf9;
  --gray-100: #f5f5f3;
  --gray-200: #e8e8e5;
  --gray-300: #d4d4cf;
  --gray-400: #a8a8a0;
  --gray-500: #787870;
  --gray-600: #5a5a52;

  --bg-base:        #f9fcfb;
  --bg-card:        #ffffff;
  --bg-subtle:      #e8f7f0;
  --bg-muted:       var(--mint-100);

  --border:         #e0ede5;
  --border-strong:  var(--mint-200);

  --text-primary:   #2f5045;
  --text-secondary: #4a7060;
  --text-muted:     #7a9b8b;
  --text-light:     #a0bfbc;

  --accent:         #e8a020;
  --accent-light:   #f5d98a;
  --danger:         #d95b5b;
  --danger-dark:    #b83c3c;
  --success:        #3a9e6a;

  --shadow-sm:  0 1px 4px rgba(92,189,154,0.06);
  --shadow-md:  0 4px 16px rgba(92,189,154,0.08);
  --shadow-lg:  0 8px 32px rgba(92,189,154,0.12);
  --shadow-inset: inset 0 1px 2px rgba(0,0,0,0.02);

  --radius-sm:  10px;
  --radius-md:  14px;
  --radius-lg:  18px;
  --radius-xl:  24px;

  --font-xs:   12px;
  --font-sm:   13px;
  --font-base: 14px;
  --font-md:   15px;
  --font-lg:   17px;
  --font-xl:   21px;
  --font-2xl:  27px;

  --transition: 0.20s ease;

  /* Pastel Mint */
  --mint-50:  #f4fdf9;
  --mint-100: #e0f7ed;
  --mint-200: #b8ebd4;
  --mint-300: #8fdfba;
  --mint-400: #6dd3a3;
  --mint-500: #4caf8a;
  --mint-600: #3d8c6f;
  --mint-700: #2f6b54;

  /* Neutral */
  --gray-50:  #fafaf9;
  --gray-100: #f5f5f3;
  --gray-200: #e8e8e5;
  --gray-300: #d4d4cf;
  --gray-400: #a8a8a0;
  --gray-500: #787870;
  --gray-600: #5a5a52;
  --gray-700: #3f3f39;
  --gray-800: #2b2b26;

  /* Semantic */
  --color-success: #16a34a;
  --color-danger:  #dc2626;
  --color-warning: #d97706;
  --color-info:    #2563eb;

  /* Layout */
  --sidebar-w: 240px;
  --surface:   #f0f4f8;

  /* Typography */
  --font: 'Kanit', sans-serif;

  /* Shadows */
  --shadow-xs: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
  --shadow-teal: 0 4px 14px rgba(92,189,154,0.20);

  /* Radius */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;

  --primary:#0d9488;
     --primary-dark:#0f766e;
     --primary-xdark:#115e59;
     
  --bg-base: #f9fcfb;
  --bg-card: #ffffff;
     
  --border: #e0ede5;
  --radius-md: 14px;
}

/* =====================================================
   2. RESET
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--surface);
  color: var(--gray-800);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* =====================================================
   3. LAYOUT
   ===================================================== */
.layout { display: flex; min-height: 100vh; }

/* =====================================================
   4. SIDEBAR
   ===================================================== */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-xdark) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 3px 0 16px rgba(0,0,0,0.14);
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 2px; }

/* Header */
.sidebar-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255,255,255,0.18);
  margin-bottom: 14px;
}

.logo-circle {
  width: 84px; height: 84px;
  background: rgba(255,255,255,0.96);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18), 0 0 0 4px rgba(255,255,255,0.18);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.logo-circle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 22px rgba(0,0,0,0.22), 0 0 0 5px rgba(255,255,255,0.25);
}

.logo-circle img { width: 52px; height: 52px; object-fit: contain; }

.logo-text {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.4px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.18);
}

/* Menu */
.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: rgba(255,255,255,0.82);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.sidebar-menu a .material-symbols-outlined {
  font-size: 19px;
  opacity: 0.8;
  flex-shrink: 0;
}

.sidebar-menu a:hover {
  background: rgba(255,255,255,0.14);
  color: #fff;
  transform: translateX(3px);
}

.sidebar-menu a.active {
  background: #fff;
  color: var(--mint-700);
  font-weight: 700;
  box-shadow: var(--shadow-md);
  margin-right: -14px;
  padding-right: 26px;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}

.sidebar-menu a.active .material-symbols-outlined {
  color: var(--mint-500);
  opacity: 1;
}

/* Logout */
.sidebar-logout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 14px;
}

.sidebar-email {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  text-align: center;
  word-break: break-all;
  line-height: 1.4;
}

.logout-btn {
  width: 100%;
  padding: 8px 14px;
  background: rgba(255,255,255,0.13);
  color: rgba(255,255,255,0.88);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.2px;
}

.logout-btn:hover {
  background: rgba(255,255,255,0.24);
  color: #fff;
  border-color: rgba(255,255,255,0.45);
}

/* =====================================================
   5. MAIN CONTENT
   ===================================================== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 28px 28px 48px;
  display: flex;
  flex-direction: column;
}

/* =====================================================
   6. PAGE + TITLE
   ===================================================== */
.page {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--mint-700);
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
}

h2 {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--mint-700);
  margin-bottom: 26px;
}

/* =====================================================
   7. SECTION CARD
   ===================================================== */
.paper {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-xdark) 100%);
  box-shadow: var(--shadow-xs);
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  padding: 20px 24px;
} 

.section,
.summary-section {
  background: #fff;
  border-radius: var(--r-lg);
  padding: 24px 28px;
  margin-bottom: 18px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.22s ease;
  animation: slideUp 0.3s ease both;
}

.section:hover,
.paper:hover { box-shadow: var(--shadow-md); }

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

.paper h1 {
  font-size: 20px;
  font-weight: 700; 
  color: #fff;
  text-align: center;  
  justify-content: center;
  margin-bottom: 6px;
}

.section h3,
.paper h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--mint-600);
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--mint-100);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section h3::before,
.paper h3::before {
  content: '';
  display: inline-block;
  width: 3px; height: 16px;
  background: var(--mint-400);
  border-radius: 2px;
  flex-shrink: 0;
}

/* =====================================================
   8. FORM ELEMENTS
   ===================================================== */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.section .form-row {
  grid-template-columns: 1fr 1fr !important;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

label {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-500);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  padding: 10px 13px;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-800);
  transition: all 0.18s ease;
  -webkit-appearance: none; appearance: none;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--mint-400);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(109,211,163,0.12);
}

input[readonly], input:disabled {
  background: #e8f7f0;
  color: var(--mint-600);
  font-weight: 700;
  cursor: not-allowed;
  border-color: var(--mint-100);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24'%3E%3Cpath fill='%2364748b' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

#empName, #area, #empZone {
  color: var(--mint-600);
  font-weight: 700;
  font-size: 15px;
}

/* =====================================================
   9. TABLE
   ===================================================== */
table,
.trip-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  margin-top: 6px;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-xs);
}

thead { position: sticky; top: 0; z-index: 1; }

th {
  background: linear-gradient(145deg, #e8f7f0, var(--mint-100));
  padding: 11px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--mint-700);
  text-align: center;
  border-bottom: 2px solid var(--mint-200);
  white-space: nowrap;
  letter-spacing: 0.2px;
}

td {
  padding: 5px 5px;
  border-bottom: 1px solid var(--gray-100);
  text-align: center;
  vertical-align: middle;
}

tbody tr:nth-child(even)  { background: var(--gray-50); }
tbody tr:nth-child(odd)   { background: #fff; }
tbody tr:hover { background: #e8f7f0; transition: background 0.15s; }
tbody tr:last-child td { border-bottom: none; }

td input, td select {
  width: 100%;
  padding: 7px 8px;
  border: 1.5px solid transparent;
  background: transparent;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 13px;
  text-align: center;
  color: var(--gray-800);
  transition: all 0.18s ease;
  -webkit-appearance: none; appearance: none;
}

td input:focus, td select:focus {
  border-color: var(--mint-400);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(109,211,163,0.12);
  outline: none;
}

td input[type="date"] { text-align: center; }
td input[type="number"] { text-align: right; }

.trip-table th { border: none; }
.trip-table td { border: none; }

/* =====================================================
   10. BUTTONS
   ===================================================== */
.btn-group,
.actions {
  display: flex;
  gap: 9px;
  margin-top: 16px;
  flex-wrap: wrap;
  align-items: center;
}

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

button:active { transform: scale(0.97); }

.btn-add,
.actions button:first-child {
  background: var(--color-success);
  color: #fff;
  box-shadow: 0 2px 8px rgba(22,163,74,0.22);
}
.btn-add:hover, .actions button:first-child:hover {
  background: #15803d;
  box-shadow: 0 4px 12px rgba(22,163,74,0.32);
  transform: translateY(-1px);
}

.btn-delete,
.actions button:nth-child(2) {
  background: var(--color-danger);
  color: #fff;
  box-shadow: 0 2px 8px rgba(220,38,38,0.18);
}
.btn-delete:hover, .actions button:nth-child(2):hover {
  background: #b91c1c;
  box-shadow: 0 4px 12px rgba(220,38,38,0.28);
  transform: translateY(-1px);
}

.btn-save,
.actions button:nth-child(3) {
  background: var(--mint-500);
  color: #fff;
  box-shadow: var(--shadow-teal);
}
.btn-save:hover, .actions button:nth-child(3):hover {
  background: var(--mint-600);
  box-shadow: 0 4px 16px rgba(92,189,154,0.32);
  transform: translateY(-1px);
}

.btn-export {
  background: var(--color-warning);
  color: #fff;
  box-shadow: 0 2px 8px rgba(217,119,6,0.18);
}
.btn-export:hover {
  background: #b45309;
  transform: translateY(-1px);
}

.actions button:last-child {
  background: var(--color-info);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,0.18);
}
.actions button:last-child:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37,99,235,0.28);
  transform: translateY(-1px);
}

/* =====================================================
   11. BADGE
   ===================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #e8f7f0;
  color: var(--mint-700);
  border: 1.5px solid var(--mint-200);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

.badge #shopCount {
  background: var(--mint-500);
  color: #fff;
  border-radius: 999px;
  padding: 1px 10px;
  font-size: 13px;
  font-weight: 700;
}

/* =====================================================
   12. SUMMARY BOX (formActual)
   ===================================================== */
.summary-box {
  background: linear-gradient(135deg, #e8f7f0, #eff6ff);
  border: 1px solid var(--mint-100);
  padding: 14px 22px;
  border-radius: var(--r-md);
  margin-top: 16px;
  text-align: center;
  font-size: 15px;
  color: var(--mint-700);
  font-weight: 500;
}

.summary-box strong {
  color: var(--mint-600);
  font-size: 18px;
  font-weight: 700;
}

/* =====================================================
   13. SUMMARY GRID (formPlan)
   ===================================================== */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 6px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.summary-item label {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-500);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.summary-item input { width: 100%; }

.summary-item.total input {
  background: linear-gradient(135deg, #dbeafe, #eff6ff);
  border-color: var(--color-info);
  color: var(--color-info);
  font-weight: 800;
  font-size: 20px;
  height: 50px;
  text-align: right;
  padding-right: 14px;
  letter-spacing: 0.5px;
}

/* =====================================================
   14. FOOTER
   ===================================================== */
.footer {
  margin-left: var(--sidebar-w);
  text-align: center;
  padding: 14px;
  font-size: 12px;
  color: var(--gray-400);
  border-top: 1px solid var(--gray-200);
  background: #fff;
}

/* =====================================================
   15. PREVIEW MODAL
   ===================================================== */
.preview-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,20,30,0.70);
  backdrop-filter: blur(5px);
  justify-content: center;
  align-items: flex-start;
  z-index: 2000;
  padding: 20px 16px 30px;
  overflow-y: auto;
}

.preview-wrapper {
  background: #dde3ea;
  padding: 18px 18px 28px;
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 820px;
  margin: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
}

.preview-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
  padding: 10px 14px;
  background: var(--mint-700);
  border-radius: var(--r-md);
}

.preview-actions button {
  padding: 7px 16px;
  font-size: 13px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  transition: all 0.18s ease;
  letter-spacing: 0.2px;
}

.preview-actions button:hover {
  background: rgba(255,255,255,0.28);
  border-color: rgba(255,255,255,0.5);
  transform: translateY(-1px);
}

.preview-actions button:last-child {
  background: rgba(239,68,68,0.25);
  border-color: rgba(239,68,68,0.5);
  margin-left: auto;
}
.preview-actions button:last-child:hover {
  background: rgba(239,68,68,0.45);
}

/* =====================================================
   16. A4 PREVIEW PAGE
   ===================================================== */
.a4-page {
  width: 100%;
  max-width: 760px;
  min-height: 1040px;
  padding: 32px 40px 40px;
  margin: 0 auto;
  background: #fff;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.65;
  box-shadow: 0 4px 32px rgba(0,0,0,0.22), 0 1px 4px rgba(0,0,0,0.1);
  border-radius: 2px;
  border-top: 4px solid var(--mint-500);
}

/* =====================================================
   17. PRINT
   ===================================================== */
@media print {
  * { visibility: hidden !important; }

  #previewContent,
  #previewContent * { visibility: visible !important; }

  #previewContent {
    position: fixed !important;
    inset: 0 !important;
    width: 210mm !important;
    height: auto !important;
    margin: 0 auto !important;
    padding: 8mm 10mm !important;
    background: #fff !important;
    box-shadow: none !important;
    border: none !important;
    transform-origin: top left !important;
    transform: scale(0.82) !important;
    overflow: visible !important;
    font-size: 11px !important;
  }

  @page {
    size: A4 portrait;
    margin: 6mm;
  }
}

/* =====================================================
   18. RESPONSIVE — Tablet (iPad landscape ~1180px)
   ===================================================== */
@media (max-width: 1200px) {
  .main-content { padding: 20px 18px 40px; }
  .page { max-width: 100%; }
  .section, .paper { padding: 20px 20px; }
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 200px; }

  .sidebar { padding: 16px 10px 14px; }
  .logo-circle { width: 68px; height: 68px; }
  .logo-circle img { width: 42px; height: 42px; }
  .logo-text { font-size: 13px; }
  .sidebar-menu a { font-size: 12px; padding: 8px 10px; gap: 7px; }
  .sidebar-menu a.active { margin-right: -10px; }

  .section .form-row { grid-template-columns: 1fr !important; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .a4-page { width: 100%; padding: 10mm 12mm; }
}

@media (max-width: 700px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 220px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.open { transform: translateX(0); }

  .main-content { margin-left: 0; padding: 16px; }
  .footer { margin-left: 0; }

  table { display: block; overflow-x: auto; }
  .summary-grid { grid-template-columns: 1fr; }
  .signature-section { grid-template-columns: 1fr 1fr; }
}

/* =====================================================
   📱 MOBILE (<= 600px)
   ===================================================== */
@media (max-width: 600px) {

  body {
    font-size: 15px;
  }

  .main-content {
    padding: 12px;
  }

  h1 {
    font-size: 18px;
  }

  .section {
    padding: 14px;
    border-radius: 12px;
  }

  .section .form-row {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  input, select {
    height: 44px;
    font-size: 15px;
  }

}

/* =====================================================
   📱 TABLE → CARD MODE
   ===================================================== */
@media (max-width: 600px) {

  .trip-table thead {
    display: none;
  }

  .trip-table,
  .trip-table tbody,
  .trip-table tr,
  .trip-table td {
    display: block;
    width: 100%;
  }

  .trip-table tr {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-xs);
  }

  .trip-table td {
    text-align: left;
    padding: 6px 0;
    border: none;
  }

  .trip-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-400);
    margin-bottom: 2px;
  }

}