/* no.raceup.co.th — Race Pack Module
   Sync brand tokens กับ hub.raceup.co.th (assets/css/main.css)
*/

:root {
  /* Sync จาก raceup-hub/assets/css/main.css */
  --red: #EE4439;
  --red-dark: #C4342A;
  --green: #1D9E75;
  --blue: #185FA5;
  --yellow: #EF9F27;
  --purple: #534AB7;
  --dark: #1A1A1A;
  --gray-100: #F8F9FA;
  --gray-200: #F0F1F3;
  --gray-300: #E0E2E6;
  --gray-400: #C4C7CC;
  --gray-500: #8E939B;
  --gray-700: #4A4F57;
  --white: #FFFFFF;

  /* Aliases (backward-compat กับ class เก่า) */
  --primary: var(--red);
  --primary-dark: var(--red-dark);
  --primary-light: #FFE9E7;
  --secondary: var(--dark);
  --accent: var(--yellow);
  --success: var(--green);
  --warning: var(--yellow);
  --danger: var(--red);
  --info: var(--blue);
  --bg: var(--gray-100);
  --bg-card: var(--white);
  --border: var(--gray-300);
  --text-dark: var(--dark);
  --text-mid: var(--gray-700);
  --text-light: var(--gray-500);

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.10);
  --radius: 12px;
  --radius-sm: 8px;
}

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

html, body {
  font-family: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, .heading {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  color: var(--text-dark);
  letter-spacing: -0.01em;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ==== Layout ==== */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--red), var(--red-dark));
  color: #fff;
  padding: 20px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.25);
  margin-bottom: 16px;
}

.sidebar-logo h1 {
  color: #fff;
  font-size: 18px;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.sidebar-logo small {
  color: rgba(255,255,255,0.85);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.92);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border-left: 3px solid #fff;
  padding-left: 17px;
}

.sidebar-nav .nav-icon { font-size: 16px; width: 22px; text-align: center; }
.sidebar-nav .nav-section {
  padding: 14px 20px 6px;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.65);
  text-transform: uppercase;
  font-weight: 600;
}

.main-content {
  padding: 24px 32px;
  max-width: 100%;
  overflow-x: hidden;
}

/* ==== Top bar ==== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.topbar-title { display: flex; flex-direction: column; }
.topbar-title h1 { font-size: 22px; }
.topbar-title .breadcrumb {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}
.breadcrumb a { color: var(--text-mid); }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 13px;
}
.user-chip .avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px;
}

/* ==== Cards ==== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-family: 'Prompt', sans-serif;
  font-size: 16px;
  font-weight: 500;
}

/* ==== KPI Cards ==== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi {
  background: var(--bg-card);
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-mid);
  margin-bottom: 6px;
}

.kpi-value {
  font-family: 'Prompt', sans-serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--text-dark);
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

.kpi-icon {
  position: absolute;
  top: 14px; right: 14px;
  font-size: 22px;
  opacity: 0.18;
}

.kpi.primary { border-top: 3px solid var(--primary); }
.kpi.success { border-top: 3px solid var(--success); }
.kpi.warning { border-top: 3px solid var(--warning); }
.kpi.info    { border-top: 3px solid var(--info); }

/* ==== Buttons ==== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-dark);
}
.btn:hover { background: #F8F9FA; border-color: var(--text-light); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-warning { background: var(--warning); color: #1A1A2E; border-color: var(--warning); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* ==== Status Badges ==== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
}
.badge-planning { background: #F1F3F5; color: var(--text-mid); }
.badge-quoted   { background: #E3F2FD; color: #1976D2; }
.badge-po-sent  { background: #FFF3E0; color: #F57C00; }
.badge-production{background: #FFEBEE; color: #C62828; }
.badge-qc       { background: #FFF9C4; color: #F9A825; }
.badge-shipping { background: #E1F5FE; color: #0277BD; }
.badge-arrived  { background: #E8F5E9; color: #2E7D32; }
.badge-completed{ background: #C8E6C9; color: #1B5E20; }
.badge-race-ready{background: #C8E6C9; color: #2E7D32; }
.badge-upcoming { background: #F1F3F5; color: var(--text-mid); }

/* ==== Tables ==== */
.table-wrap {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  overflow-x: auto;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data-table thead th {
  background: #FAFBFC;
  text-align: left;
  padding: 12px 14px;
  font-family: 'Prompt', sans-serif;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-mid);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #F0F2F5;
}
table.data-table tbody tr:hover {
  background: #FAFBFC;
}
table.data-table tbody tr:last-child td { border-bottom: none; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-mono { font-family: 'Roboto Mono', monospace; }

.diff-negative { color: var(--danger); font-weight: 500; }
.diff-positive { color: var(--success); font-weight: 500; }
.diff-zero { color: var(--text-light); }

/* ==== Forms ==== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-mid);
  margin-bottom: 4px;
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(238, 68, 57, 0.1);
}

.input-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

/* ==== Tabs ==== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mid);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab:hover { color: var(--text-dark); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ==== Progress Bar ==== */
.progress {
  width: 100%;
  height: 6px;
  background: #F0F2F5;
  border-radius: 100px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 100px;
  transition: width 0.4s;
}

/* ==== Empty / Loading ==== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}
.loader {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==== Modal ==== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(26, 26, 46, 0.55);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 90%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-body { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-light); }

/* ==== Toast ==== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--red-dark);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.25s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--text-dark); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ==== Login Page ==== */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  width: 80px; height: 80px;
  margin: 0 auto 20px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-family: 'Prompt', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
}
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card p { color: var(--text-mid); font-size: 14px; margin-bottom: 24px; }
.google-signin-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
 
/* ==== Lucide Icons ==== */
[data-lucide], .lucide {
  display: inline-block;
  vertical-align: middle;
  stroke-width: 1.75;
  width: 18px;
  height: 18px;
}
.icon-sm { width: 14px; height: 14px; }
.icon-md { width: 18px; height: 18px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 28px; height: 28px; }

/* Inline icon spacing in buttons / labels */
.btn [data-lucide], .card-title [data-lucide], .topnav-link [data-lucide] {
  margin-right: 4px;
}
