/* ============================================================================
   Norasing Trip & Vehicle Report System - Stylesheet
   ธีมสีเขียว ตามดีไซน์ต้นแบบ (นรสิงห์ โซล่าเซลล์)
============================================================================ */

:root {
  --green-900: #1b5e20;
  --green-700: #2e7d32;
  --green-600: #388e3c;
  --green-500: #43a047;
  --green-100: #e8f5e9;
  --green-50:  #f1f8f2;

  --blue: #1976d2;
  --blue-bg: #e3f2fd;
  --yellow: #f9a825;
  --yellow-bg: #fff8e1;
  --orange: #ef6c00;
  --orange-bg: #fff3e0;
  --red: #c62828;
  --red-bg: #ffebee;
  --purple: #6a1b9a;
  --purple-bg: #f3e5f5;
  --teal: #00695c;
  --teal-bg: #e0f2f1;
  --gray: #616161;
  --gray-bg: #eeeeee;

  --ink: #1f2b22;
  --ink-soft: #5c6b60;
  --border: #e1e8e2;
  --bg-page: #f4f7f4;
  --bg-card: #ffffff;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(27, 94, 32, 0.06);
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Sarabun', 'Noto Sans Thai', -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-page);
  color: var(--ink);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------------- Layout shell ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
  transition: transform .2s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo-dot {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--green-500), var(--green-900));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.sidebar-brand .brand-text { line-height: 1.25; }
.sidebar-brand .brand-text b { display: block; font-size: 14.5px; color: var(--green-900); }
.sidebar-brand .brand-text span { font-size: 11px; color: var(--ink-soft); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }
.sidebar-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: #9aa79e; padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 2px;
  color: #3f4b43; font-size: 14px; font-weight: 500;
}
.nav-item:hover { background: var(--green-50); }
.nav-item.active { background: var(--green-700); color: #fff; }
.nav-item .ic { width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 11px; color: #9aa79e; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------------- Topbar ---------------- */
.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  position: sticky; top: 0; z-index: 30;
}
.hamburger {
  display: none;
  width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border);
  background: #fff; align-items: center; justify-content: center; cursor: pointer;
}
.topbar-search {
  flex: 1; max-width: 420px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-page); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; color: var(--ink-soft); font-size: 13.5px;
}
.topbar-search input { border: none; background: transparent; outline: none; flex: 1; font-size: 13.5px; font-family: inherit; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; position: relative;
  background: #fff; cursor: pointer;
}
.icon-btn .dot {
  position: absolute; top: -3px; right: -3px; background: var(--red); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--green-100); color: var(--green-900);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.user-chip .name { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.user-chip .role { font-size: 11px; color: var(--ink-soft); }

/* ---------------- Page content ---------------- */
.page { padding: 20px; max-width: 1400px; width: 100%; margin: 0 auto; }

.hero {
  background: linear-gradient(120deg, #1b5e20, #388e3c 60%, #66bb6a);
  border-radius: var(--radius);
  color: #fff;
  padding: 24px 26px;
  margin-bottom: 18px;
  display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px;
}
.hero h1 { margin: 0 0 4px; font-size: 20px; }
.hero p { margin: 0; opacity: .9; font-size: 13.5px; }
.hero .hero-date { font-size: 12.5px; opacity: .85; margin-bottom: 8px; text-align: right; }
.hero .status-chip {
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.4);
  border-radius: 20px; padding: 6px 14px; font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center;
}

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-main-side { grid-template-columns: 2fr 1fr; }

.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.card-head h3 { margin: 0; font-size: 15px; }
.card-head a.more { font-size: 12.5px; color: var(--green-700); font-weight: 600; }

.stat-card { display: flex; align-items: center; gap: 12px; padding: 16px; }
.stat-card .ic {
  width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-card .ic.green { background: var(--green-100); color: var(--green-700); }
.stat-card .ic.blue { background: var(--blue-bg); color: var(--blue); }
.stat-card .ic.yellow { background: var(--yellow-bg); color: var(--yellow); }
.stat-card .ic.purple { background: var(--purple-bg); color: var(--purple); }
.stat-card .label { font-size: 12px; color: var(--ink-soft); margin-bottom: 2px; }
.stat-card .value { font-size: 20px; font-weight: 700; }
.stat-card .sub { font-size: 11px; color: var(--ink-soft); }

.progress-bar { background: var(--gray-bg); border-radius: 20px; height: 8px; overflow: hidden; margin: 6px 0; }
.progress-bar > span { display: block; height: 100%; background: var(--green-600); border-radius: 20px; }
.progress-bar.warn > span { background: var(--orange); }
.progress-bar.danger > span { background: var(--red); }

.action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.action-btn {
  border-radius: var(--radius); padding: 16px; color: #fff; display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow); border: none; cursor: pointer; text-align: left; font-family: inherit;
}
.action-btn .t1 { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.action-btn .t2 { font-size: 11.5px; opacity: .9; }
.action-btn.a-start { background: linear-gradient(135deg, #43a047, #1b5e20); }
.action-btn.a-visit { background: linear-gradient(135deg, #1e88e5, #0d47a1); }
.action-btn.a-end { background: linear-gradient(135deg, #fb8c00, #e65100); }
.action-btn.a-history { background: #fff; color: var(--ink); border: 1px solid var(--border); }
.action-btn.a-history .t2 { color: var(--ink-soft); }
.action-btn[disabled] { opacity: .5; cursor: not-allowed; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; font-size: 12px; color: var(--ink-soft); font-weight: 600;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--green-50); }
.table-scroll { overflow-x: auto; }

.badge {
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.badge-green  { background: var(--green-100); color: var(--green-900); }
.badge-blue   { background: var(--blue-bg); color: var(--blue); }
.badge-yellow { background: var(--yellow-bg); color: #a16a00; }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-red    { background: var(--red-bg); color: var(--red); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-teal   { background: var(--teal-bg); color: var(--teal); }
.badge-gray   { background: var(--gray-bg); color: var(--gray); }

.summary-list { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.summary-list li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.summary-list li:last-child { border-bottom: none; }
.summary-list li b { font-weight: 700; }
.summary-list li.total { font-size: 15px; padding-top: 10px; }
.summary-list li.total b { color: var(--green-700); }

.alert-box {
  border-radius: 12px; padding: 12px 14px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start;
  margin-bottom: 14px;
}
.alert-box.info    { background: var(--yellow-bg); color: #8a5a00; border: 1px solid #f3d98b; }
.alert-box.success { background: var(--green-100); color: var(--green-900); border: 1px solid #b6dfba; }
.alert-box.danger  { background: var(--red-bg); color: var(--red); border: 1px solid #f0b7b7; }
.alert-box.warn    { background: var(--orange-bg); color: var(--orange); border: 1px solid #f6cf9e; }

.map-box { border-radius: 12px; overflow: hidden; height: 260px; border: 1px solid var(--border); }
.map-box.tall { height: 400px; }

.thumb-row { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb-row img, .thumb-row .thumb {
  width: 90px; height: 90px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); background: #f4f4f4;
}
.thumb-row .thumb-label { position: relative; }
.thumb-row .thumb-cap {
  position: absolute; bottom: 2px; left: 2px; right: 2px; background: rgba(0,0,0,.55); color: #fff;
  font-size: 9.5px; text-align: center; border-radius: 4px; padding: 1px 2px;
}

.news-list { list-style: none; margin: 0; padding: 0; }
.news-list li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.news-list li:last-child { border-bottom: none; }
.news-list .dot {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
}

/* ---------------- Forms ---------------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #3f4b43; }
.form-group .hint { font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; }
input[type=text], input[type=tel], input[type=number], input[type=password],
input[type=email], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green-500); box-shadow: 0 0 0 3px var(--green-100); }
.checkbox-row { display: flex; gap: 16px; flex-wrap: wrap; }
.checkbox-row label { display: flex; align-items: center; gap: 7px; font-weight: 500; font-size: 13.5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.file-drop {
  border: 2px dashed var(--border); border-radius: 12px; padding: 18px; text-align: center;
  color: var(--ink-soft); font-size: 13px; cursor: pointer; background: var(--bg-page);
}
.file-drop.has-preview { padding: 10px; }
.file-drop img { max-width: 100%; max-height: 180px; border-radius: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 10px; font-size: 14.5px; font-weight: 700;
  border: none; cursor: pointer; font-family: inherit;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-900); }
.btn-danger { background: var(--red); color: #fff; }
.btn-warn { background: var(--orange); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--ink); }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--green-900), var(--green-600));
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 18px; width: 100%; max-width: 380px; padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card .logo-wrap { text-align: center; margin-bottom: 18px; }
.login-card .logo-dot {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 10px;
  background: linear-gradient(135deg, var(--green-500), var(--green-900));
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px;
}
.login-card h1 { font-size: 17px; text-align: center; margin: 0 0 2px; }
.login-card p.sub { text-align: center; color: var(--ink-soft); font-size: 12.5px; margin: 0 0 22px; }

.tag-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--green-50); border: 1px solid var(--border); border-radius: 20px; padding: 5px 12px; font-size: 12px; }

.timeline { border-left: 2px solid var(--border); margin-left: 8px; padding-left: 18px; }
.timeline .t-item { position: relative; padding-bottom: 20px; }
.timeline .t-item::before {
  content: ''; position: absolute; left: -23px; top: 3px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--green-600); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--green-600);
}
.timeline .t-item .t-date { font-size: 11.5px; color: var(--ink-soft); }
.timeline .t-item .t-title { font-weight: 700; font-size: 13.5px; }
.timeline .t-item .t-note { font-size: 12.5px; color: var(--ink-soft); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty-state .ic { font-size: 40px; margin-bottom: 10px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-main-side { grid-template-columns: 1fr; }
  .action-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .topbar-search { display: none; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .action-grid { grid-template-columns: repeat(2, 1fr); }
  .page { padding: 14px; }
  .hero { padding: 18px; }
  .form-row { grid-template-columns: 1fr; }
}
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35;
}
.sidebar-backdrop.show { display: block; }

.print-only { display: none; }
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main { margin-left: 0 !important; }
  .print-only { display: block; }
  body { background: #fff; }
}
