/**
 * Fallback layout + คอมโพเนนต์พื้นฐาน เมื่อ /_next/static/css/*.css โหลดไม่ได้ (เช่น 400/404 บน production)
 * โหลดจาก /critical-shell.css — ไม่ผ่าน webpack chunk
 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: #f8fafc;
  color: #1e293b;
}

/* หน้า login/auth — พื้นหลังส้มเต็มจอ (สอดคล้อง Tailwind bg-orange-500 บน AppShell) */
body:has([data-layout="auth"]) {
  background: #f97316;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

a {
  color: #ea580c;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  cursor: pointer;
}

/* --- Login (data-layout="auth") --- */
[data-layout="auth"] {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-bottom: 2.5rem;
  padding-top: 3.5rem;
  background: #f97316;
}

@media (min-width: 640px) {
  [data-layout="auth"] {
    padding-top: 2rem;
    padding-bottom: 2rem;
  }
}

[data-layout="auth"] .input,
.critical-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  background: #fff;
  padding: 0.5rem 0.75rem;
  color: #1e293b;
}

[data-layout="auth"] .input:focus,
.critical-input:focus {
  outline: 2px solid #f97316;
  outline-offset: 0;
  border-color: #f97316;
}

[data-layout="auth"] .btn-primary,
.critical-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: none;
  border-radius: 0.5rem;
  background: #ea580c;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
}

[data-layout="auth"] .btn-primary:hover:not(:disabled),
.critical-btn-primary:hover:not(:disabled) {
  background: #c2410c;
}

[data-layout="auth"] .btn-primary:disabled,
.critical-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- App chrome (data-layout="app") --- */
[data-layout="app"] {
  display: flex;
  min-height: 100vh;
}

[data-layout="app"] > aside {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: 16rem;
  height: 100vh;
  background: #fff;
  border-right: 1px solid #f1f5f9;
}

[data-layout="app"] > aside nav a,
[data-layout="app"] > aside nav button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  border-radius: 0.75rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
  text-decoration: none;
}

[data-layout="app"] > aside nav a:hover,
[data-layout="app"] > aside nav button:hover {
  background: #fff7ed;
  text-decoration: none;
}

[data-layout="app"] > aside nav ul ul a {
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  color: #475569;
}

[data-layout="app"] > aside nav ul ul {
  margin-top: 0.25rem;
  margin-left: 1.25rem;
  padding-left: 0.75rem;
  border-left: 2px solid #fed7aa;
}

[data-layout="app"] > .app-main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-left: 16rem;
  background: #f8fafc;
}

[data-layout="app"] > .app-main-wrap > header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 1rem 1.5rem;
}

[data-layout="app"] > .app-main-wrap > main {
  flex: 1;
  overflow: auto;
  padding: 1.5rem;
}

/* Logout */
[data-layout="app"] aside .aside-footer-logout {
  color: #ef4444;
}

[data-layout="app"] aside .aside-footer-logout:hover {
  background: #fef2f2;
}

/* --- Settings tabs (data-settings-tabs) --- */
[data-settings-tabs] {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  max-width: 42rem;
  padding: 0.25rem;
  margin-bottom: 1.5rem;
  border-radius: 0.75rem;
  background: #f1f5f9;
}

[data-settings-tabs] a {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 8rem;
  padding: 0.625rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748b;
  text-decoration: none;
}

[data-settings-tabs] a:hover {
  color: #334155;
  text-decoration: none;
}

[data-settings-tabs] a[aria-current="page"] {
  background: #fff;
  color: #ea580c;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
}

[data-settings-root] h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
  color: #1e293b;
}
