/* ============================================================
   ALLOVE Conference — Brand Theme
   Colors: แดงเลือดหมู (maroon) + ขาว + ทอง (gold accent)
   ============================================================ */

:root {
  /* Brand palette */
  --maroon:        #7a0172;   /* ม่วงแดงหลัก (แบรนด์ใหม่) */
  --maroon-dark:   #5e0158;   /* hover / active */
  --maroon-light:  #9a2090;   /* lighter accent */
  --maroon-tint:   #f6ecf5;   /* พื้นจาง สำหรับ highlight */
  --gold:          #c8923a;   /* ทองจากโลโก้ */
  --gold-dark:     #a8761f;
  --gold-tint:     #faf3e6;

  --white:         #ffffff;
  --bg:            #f7f5f3;   /* พื้นนอก off-white */
  --surface:       #ffffff;   /* การ์ด/พื้นใน */
  --ink:           #1d1b1a;   /* ตัวอักษรหลัก */
  --ink-soft:      #6b6660;   /* ตัวอักษรรอง */
  --ink-faint:     #9a948d;   /* hint */
  --line:          #e7e2dd;   /* เส้นขอบ */
  --line-strong:   #d4cec7;

  --success:       #1d7a4d;
  --success-tint:  #e6f3ec;
  --danger:        #b3261e;
  --danger-tint:   #fbeae9;
  --warning:       #a8761f;
  --warning-tint:  #faf3e6;

  /* สีฟ้าสำหรับปุ่ม "กลับ" (ใช้ร่วมทุกหน้า) — น้ำเงินอ่านง่ายบนพื้นขาว
     และตัดกับพื้นแถบหัวสี maroon ได้ชัด */
  --back-blue:       #185fa5;
  --back-blue-dark:  #0c447c;

  --radius:        10px;
  --radius-lg:     14px;
  --radius-pill:   999px;
  --shadow-sm:     0 1px 3px rgba(29, 27, 26, 0.08);
  --shadow:        0 4px 16px rgba(29, 27, 26, 0.10);
  --shadow-lg:     0 12px 40px rgba(29, 27, 26, 0.16);

  --font: "Noto Sans Thai", "Inter", -apple-system, BlinkMacSystemFont,
          "Segoe UI", Roboto, sans-serif;
  --header-h: 64px;
  --footer-h: 44px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--maroon); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.app-header {
  background: var(--maroon);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 4vw, 32px);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-header .brand { display: flex; align-items: center; gap: 12px; }
.app-header .brand img { height: 38px; width: auto; display: block; }
.app-header .brand-name {
  color: var(--white);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.app-header .header-right { display: flex; align-items: center; gap: 14px; }
.app-header .user-chip {
  display: flex; align-items: center; gap: 8px;
  color: var(--white); font-size: 14px;
}
.app-header .user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}

/* ---------- Footer (บรรทัดเดียวเสมอ คอม+มือถือ) ---------- */
.app-footer {
  background: var(--maroon);
  color: var(--white);
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 12px;
  margin-top: auto;
}
.app-footer span {
  color: var(--white);
  font-size: clamp(10px, 2.4vw, 13px);
  letter-spacing: 0.4px;
  white-space: nowrap;        /* บังคับบรรทัดเดียว */
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ---------- Main layout ---------- */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 36px) clamp(16px, 4vw, 32px);
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: clamp(18px, 3vw, 28px); }

/* ---------- Buttons (สวยงามระดับมืออาชีพ) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  padding: 0 20px;
  height: 44px;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease,
              box-shadow 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:focus-visible { outline: 3px solid rgba(122, 1, 114, 0.25); outline-offset: 2px; }
.btn .ti { font-size: 18px; }

/* Primary — แดงเลือดหมู */
.btn-primary { background: var(--maroon); color: var(--white); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--maroon-dark); box-shadow: var(--shadow); text-decoration: none; }

/* Gold — accent หรู */
.btn-gold { background: var(--gold); color: #3a2606; box-shadow: var(--shadow-sm); }
.btn-gold:hover { background: var(--gold-dark); color: var(--white); box-shadow: var(--shadow); text-decoration: none; }

/* Outline */
.btn-outline { background: transparent; color: var(--maroon); border-color: var(--maroon); }
.btn-outline:hover { background: var(--maroon-tint); text-decoration: none; }

/* Ghost / subtle */
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--bg); border-color: var(--line-strong); text-decoration: none; }

/* Danger */
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #8f1d17; text-decoration: none; }

/* Back — ปุ่ม "กลับ" สีฟ้า (ใช้ร่วมทุกหน้า เพื่อความสม่ำเสมอและดูแลง่ายระยะยาว)
   ใช้คู่กับไอคอน <i class="ti ti-arrow-left"></i> เสมอ */
.btn-back { background: var(--back-blue); color: var(--white); border-color: var(--back-blue); box-shadow: var(--shadow-sm); }
.btn-back:hover { background: var(--back-blue-dark); border-color: var(--back-blue-dark); color: var(--white); text-decoration: none; }
/* รูปแบบบนพื้นแถบหัวสี maroon: พื้นฟ้าทึบ ตัวอักษรขาว ขอบฟ้าจาง ให้เด่นและกลมกลืน */
.btn-back-header { background: var(--back-blue); color: var(--white); border-color: rgba(255,255,255,0.45); font-weight: 500; }
.btn-back-header:hover { background: var(--back-blue-dark); color: var(--white); text-decoration: none; }

/* Sizes */
.btn-sm { height: 36px; font-size: 13px; padding: 0 14px; border-radius: 8px; }
.btn-sm .ti { font-size: 16px; }
.btn-lg { height: 50px; font-size: 16px; padding: 0 28px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* Icon-only button */
.btn-icon {
  width: 40px; height: 40px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon.btn-sm { width: 34px; height: 34px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--ink-soft); margin-bottom: 6px;
}
.input, .select, .textarea {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--white);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea { height: auto; padding: 12px 14px; resize: vertical; min-height: 90px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px rgba(122, 1, 114, 0.12);
}
.input-group { position: relative; }
.input-group .ti {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint); font-size: 18px; pointer-events: none;
}
/* ปุ่มแสดง/ซ่อนรหัสผ่าน — icon ต้องไม่โดน rule ด้านบนครอบ */
.input-group button .ti {
  position: static; left: auto; top: auto; transform: none;
  color: inherit; font-size: inherit; pointer-events: auto;
}
.input-group .input { padding-left: 42px; }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: var(--radius-pill);
}
.badge-host    { background: var(--maroon-tint); color: var(--maroon); }
.badge-cohost  { background: var(--gold-tint);   color: var(--gold-dark); }
.badge-admin   { background: #efe9f7;            color: #5b3a99; }
.badge-success { background: var(--success-tint); color: var(--success); }
.badge-muted   { background: var(--bg);          color: var(--ink-soft); }
.badge-live    { background: var(--success-tint); color: var(--success); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 600; color: var(--ink-soft);
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

/* ---------- Page title ---------- */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 14px; margin-bottom: 22px;
}
.page-head h1 { font-size: 24px; font-weight: 700; color: var(--ink); }
.page-head .sub { font-size: 14px; color: var(--ink-soft); margin-top: 2px; }

/* ---------- Toast / alert ---------- */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 14px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}
.alert-error   { background: var(--danger-tint);  color: var(--danger); border: 1px solid #f1c6c3; }
.alert-success { background: var(--success-tint); color: var(--success); border: 1px solid #c2e2cf; }
.alert .ti { font-size: 18px; flex-shrink: 0; }

.toast-wrap {
  position: fixed; top: 76px; right: 20px; z-index: 1000;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--maroon);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 12px 16px; font-size: 14px; min-width: 240px; max-width: 340px;
  display: flex; align-items: center; gap: 10px;
  animation: toastIn 0.2s ease;
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(29,27,26,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto;
}
.modal-head {
  padding: 18px 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 22px; }
.modal-foot {
  padding: 16px 22px; border-top: 1px solid var(--line);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ---------- Auth (login) layout ---------- */
.auth-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.auth-card {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); width: 100%; max-width: 400px;
  padding: 36px 32px; border: 1px solid var(--line);
}
.auth-logo {
  background: var(--maroon); border-radius: var(--radius);
  padding: 18px; text-align: center; margin-bottom: 24px;
}
.auth-logo img { height: 52px; width: auto; }

/* ---------- Helpers ---------- */
.row { display: flex; gap: 12px; align-items: center; }
.spread { justify-content: space-between; }
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.hidden { display: none !important; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .app-header .brand-name { display: none; }
  .app-header .brand img { height: 28px; }
  .page-head h1 { font-size: 20px; }
  .table-wrap { overflow-x: auto; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}
