/* ─── KSP Contact Worker — Stylesheet ─── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+Thai:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #f7f3ef;
  --paper: #fff;
  --ink: #3a2f27;
  --muted: #8b7e74;
  --line: #e7dfd8;
  --chip: #efe7df;
  --accent: #6b4a33;
  --accent-light: #efdccf;
  --accent-hover: #5a3d2b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(128, 98, 72, .12);
  --shadow-sm: 0 4px 12px rgba(128, 98, 72, .08);
  --success: #2e7d32;
  --success-bg: #eaf7ea;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --warning: #b58b63;
  --warning-bg: #fef3e2;
  --info: #0284c7;
  --info-bg: #f0f9ff;
  --font: 'Noto Sans Thai', 'Inter', system-ui, sans-serif;
  --transition: .2s ease;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font: 14px/1.65 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ─── Screens ─── */
.screen { display: none !important; }
.screen.active { display: block !important; }
#login-screen.active { display: flex !important; }

/* ─── Login Screen ─── */
#login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f7f3ef 0%, #e6dcd3 100%);
}
.login-box {
  background: var(--paper);
  padding: 40px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 400px;
  width: 90%;
  animation: fadeUp .5s ease;
}
.login-logo { margin-bottom: 16px; }
.login-box h2 {
  margin: 0 0 8px 0;
  color: var(--accent);
  font-weight: 700;
  font-size: 24px;
}

/* ─── App Header ─── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(128, 98, 72, .06);
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-title { font-weight: 700; font-size: 17px; color: var(--accent); }

/* ─── Tabs ─── */
.nav-tabs {
  display: flex;
  gap: 8px;
  background: var(--paper);
  padding: 8px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.nav-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
}

.nav-tab:hover { background: var(--bg); }
.nav-tab.active { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(107, 74, 51, .2); }

.view-content { display: none; flex-direction: column; gap: 16px; animation: fadeUp .3s ease; }
.view-content.active { display: flex; }

/* ─── Main Layout ─── */
.app-main {
  flex: 1;
  padding: 16px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Card ─── */
.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 0 6px;
}
.badge.danger { background: var(--danger); }
.badge.warning { background: var(--warning); }
.badge.info { background: var(--info); }

/* ─── Form Elements ─── */
.form-row { margin-bottom: 14px; }
.form-row:last-child { margin-bottom: 0; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(107, 74, 51, .08);
}

/* ─── List Items ─── */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: all var(--transition);
}
.list-item:hover { border-color: var(--accent); background: var(--accent-light); }
.list-item .avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #fff; 
  border: 2px solid var(--line);
}
.list-item-content { flex: 1; }
.list-item-title { font-weight: 600; font-size: 14px; color: var(--ink); }
.list-item-sub { color: var(--muted); font-size: 12px; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: default; transform: none; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 5px 12px; font-size: 12px; }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Empty State ─── */
.empty-state { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty-icon { font-size: 40px; margin-bottom: 8px; opacity: .6; }

/* ─── Animations ─── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(107, 74, 51, .15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
}

.search-belt {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.search-belt input { flex: 1; }
