/* ============================================================
   NEMT Frontend – style.css
   ออกแบบ Mobile First สำหรับผู้สูงอายุ / ญาติผู้ป่วย / ผู้ป่วย / คนขับรถ
   ============================================================ */

:root {
  --color-primary: #1976D2;
  --color-primary-rgb: 25, 118, 210;
  --color-secondary: #43A047;
  --color-secondary-rgb: 67, 160, 71;
  --color-bg: #F5F7FA;
  --color-card: #FFFFFF;
  --color-danger: #E53935;
  --color-text: #263238;
  --color-text-muted: #6b7a82;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-full: 999px;

  --shadow-soft: 0 6px 20px rgba(38, 50, 56, 0.08);
  --shadow-soft-hover: 0 10px 28px rgba(38, 50, 56, 0.14);

  --font-display: 'Kanit', sans-serif;
  --font-body: 'Noto Sans Thai', sans-serif;

  --tap-target: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 18px;              /* ขนาดตัวอักษรพื้นฐานใหญ่ตาม requirement */
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, .app-topbar-title, .app-logo-title {
  font-family: var(--font-display);
}

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

/* ============================================================
   App Shell – จำกัดความกว้างบน Desktop ให้ยังดูเหมือน Mobile App
   ============================================================ */
.app-shell {
  width: 100%;
  min-height: 100vh;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

@media (min-width: 480px) {
  .app-shell { min-height: 100dvh; }
}

/* ============================================================
   Top App Bar
   ============================================================ */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, var(--color-primary), #1e88e5 60%, var(--color-secondary));
  color: #fff;
  padding: 14px max(16px, calc((100% - 640px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 4px 14px rgba(25, 118, 210, 0.25);
}

.app-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-logo-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: #fff;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.app-logo-badge .app-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius-md) - 3px);
  display: block;
}
.app-logo-badge .material-icons-round { font-size: 26px; }

.app-topbar-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.app-topbar-org {
  font-size: 13px;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-topbar-title {
  font-size: 20px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-icon-btn {
  width: var(--tap-target);
  height: var(--tap-target);
  min-width: 48px;
  min-height: 48px;
  border: none;
  background: rgba(255,255,255,0.16);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.15s ease;
}
.topbar-icon-btn:hover,
.topbar-icon-btn:focus-visible { background: rgba(255,255,255,0.3); }
.topbar-icon-btn:active { transform: scale(0.92); }

.notify-dot {
  position: absolute;
  top: 10px;
  right: 11px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-danger);
  border: 2px solid var(--color-primary);
}

/* ============================================================
   Content area
   ============================================================ */
.app-content {
  flex: 1;
  padding: 18px max(16px, calc((100% - 640px) / 2)) 32px;
}

.welcome-block {
  margin-bottom: 18px;
}
.welcome-block .hello {
  font-size: 15px;
  color: var(--color-text-muted);
  margin: 0 0 2px;
}
.welcome-block .app-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  color: var(--color-text);
}

/* ============================================================
   Banner / ประชาสัมพันธ์ (Carousel)
   ============================================================ */
.banner-carousel {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  margin-bottom: 22px;
}
.banner-slide {
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
  color: #fff;
}
.banner-slide.slide-1 { background: linear-gradient(120deg, #1976D2, #45a6ff); }
.banner-slide.slide-2 { background: linear-gradient(120deg, #43A047, #7fd189); }
.banner-slide.slide-3 { background: linear-gradient(120deg, #2f5f8a, #1976D2); }

.banner-slide .banner-text .banner-eyebrow {
  font-size: 13px;
  opacity: 0.85;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.18);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
}
.banner-slide .banner-text h3 {
  font-size: 18px;
  margin: 0 0 4px;
  font-weight: 600;
}
.banner-slide .banner-text p {
  font-size: 14px;
  margin: 0;
  opacity: 0.92;
}
.banner-slide .banner-icon {
  font-size: 44px;
  opacity: 0.9;
  flex-shrink: 0;
}
.banner-carousel .carousel-indicators { margin-bottom: 6px; }
.banner-carousel .carousel-indicators [data-bs-target] {
  width: 7px; height: 7px; border-radius: 50%; background: #fff; opacity: 0.6;
}
.banner-carousel .carousel-indicators .active { opacity: 1; }

/* ============================================================
   Section label
   ============================================================ */
.section-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: 4px 2px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-label .material-icons-round { font-size: 18px; color: var(--color-primary); }

/* ============================================================
   Menu Cards (การ์ดเมนูหลัก 5 เมนู)
   ============================================================ */
.menu-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.menu-card {
  --accent: var(--color-primary);
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--tap-target);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.22s cubic-bezier(.2,.7,.3,1),
              box-shadow 0.22s ease,
              border-color 0.22s ease;
  animation: card-rise 0.5s ease both;
}

/* stagger เข้ามาเรียงกันทีละใบ */
.menu-list .menu-card:nth-child(1) { animation-delay: 0.02s; }
.menu-list .menu-card:nth-child(2) { animation-delay: 0.08s; }
.menu-list .menu-card:nth-child(3) { animation-delay: 0.14s; }
.menu-list .menu-card:nth-child(4) { animation-delay: 0.20s; }
.menu-list .menu-card:nth-child(5) { animation-delay: 0.26s; }

@keyframes card-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.menu-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-soft-hover);
  border-color: rgba(var(--color-primary-rgb), 0.18);
}
.menu-card:active { transform: translateY(-1px) scale(0.99); }

.menu-card .menu-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: rgba(var(--color-primary-rgb), 0.1);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 26px;
  transition: transform 0.25s ease;
}
.menu-card:hover .menu-icon { transform: scale(1.08) rotate(-4deg); }

.menu-card.accent-secondary { --accent: var(--color-secondary); }
.menu-card.accent-secondary .menu-icon { background: rgba(var(--color-secondary-rgb), 0.12); }
.menu-card.accent-danger { --accent: var(--color-danger); }
.menu-card.accent-danger .menu-icon { background: rgba(229, 57, 53, 0.1); }

.menu-card .menu-body {
  flex: 1;
  min-width: 0;
}
.menu-card .menu-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 2px;
  color: var(--color-text);
}
.menu-card .menu-desc {
  font-size: 14px;
  color: var(--color-text-muted);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-card .menu-arrow {
  color: #b7c0c6;
  font-size: 22px;
  flex-shrink: 0;
  transition: transform 0.22s ease, color 0.22s ease;
}
.menu-card:hover .menu-arrow {
  transform: translateX(3px);
  color: var(--accent);
}

/* Ripple effect */
.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  animation: ripple-anim 0.6s linear;
  background: rgba(var(--color-primary-rgb), 0.25);
  pointer-events: none;
}
@keyframes ripple-anim {
  to { transform: scale(3.2); opacity: 0; }
}

/* ============================================================
   Big action buttons (ใช้ในหน้าอื่น ๆ เช่น login/register)
   ============================================================ */
.btn-app {
  width: 100%;
  min-height: var(--tap-target);
  border-radius: var(--radius-md);
  font-size: 18px;
  font-weight: 600;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn-app:active { transform: scale(0.98); }
.btn-app-primary { background: var(--color-primary); color: #fff; box-shadow: 0 6px 16px rgba(25,118,210,0.3); }
.btn-app-secondary { background: var(--color-secondary); color: #fff; box-shadow: 0 6px 16px rgba(67,160,71,0.3); }
.btn-app-outline { background: #fff; color: var(--color-primary); border: 2px solid rgba(25,118,210,0.25); }

.form-control-app {
  width: 100%;
  min-height: 56px;
  border-radius: var(--radius-md);
  border: 1.5px solid #dfe6ec;
  padding: 12px 16px;
  font-size: 17px;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-control-app:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(var(--color-primary-rgb), 0.12);
}
.form-label-app {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
  display: block;
}

.placeholder-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 22px 18px;
  text-align: center;
  color: var(--color-text-muted);
}
.placeholder-card .material-icons-round { font-size: 48px; color: var(--color-primary); margin-bottom: 10px; }

/* ============================================================
   Footer
   ============================================================ */
.app-footer {
  text-align: center;
  padding: 18px max(16px, calc((100% - 640px) / 2)) 26px;
  font-size: 13px;
  color: var(--color-text-muted);
}
.app-footer p { margin: 2px 0; }
.app-footer a { color: var(--color-primary); font-weight: 600; }

/* ============================================================
   Page Themes — สีเฉพาะหน้า
   ผู้ป่วย (theme-patient) โทนน้ำเงิน สื่อถึงความน่าเชื่อถือ/การแพทย์
   คนขับรถ (theme-driver)  โทนเขียว สื่อถึงการเดินทาง/พร้อมออกเดินทาง
   ============================================================ */
.app-shell.theme-patient {
  --color-primary: #1976D2;
  --color-primary-rgb: 25, 118, 210;
}
.app-shell.theme-patient .app-topbar {
  background: linear-gradient(135deg, #1565C0, #1976D2 55%, #4aa3f5);
}

.app-shell.theme-driver {
  --color-primary: #43A047;
  --color-primary-rgb: 67, 160, 71;
}
.app-shell.theme-driver .app-topbar {
  background: linear-gradient(135deg, #2E7D32, #43A047 55%, #7fd189);
}
.app-shell.theme-driver .btn-app-secondary {
  box-shadow: 0 6px 16px rgba(67,160,71,0.3);
}

.app-shell.theme-rights {
  --color-primary: #00897B;
  --color-primary-rgb: 0, 137, 123;
}
.app-shell.theme-rights .app-topbar {
  background: linear-gradient(135deg, #00695C, #00897B 55%, #4DB6AC);
}

.app-shell.theme-login .app-topbar {
  background: linear-gradient(135deg, #4527A0, #5E35B1 55%, #9575CD);
}

/* ============================================================
   Utility: reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .menu-card, .menu-icon, .menu-arrow, .topbar-icon-btn { animation: none !important; transition: none !important; }
}
