/* ============================================================
   APK Logistics — Shared Design System
   Dùng chung cho index.html (admin) và user.html (customer)
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --primary:       #0f1729;
  --primary-light: #2E75B6;
  --primary-dark:  #0f1729;
  --green:         #2E7D32;
  --red:           #C62828;
  --orange:        #E65100;
  --bg:            #F0F4F8;
  --card-bg:       #fff;
  --text:          #1a1a2e;
  --text-muted:    #888;
  --border:        #E8EDF2;
  --radius:        12px;
  --shadow:        0 1px 4px rgba(0,0,0,.07);
}

/* ── Base Reset ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

/* ── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.card-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.card-val {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
}

.card-val.green { color: var(--green); }
.card-val.red   { color: var(--red); }
.card-val.orange { color: var(--orange); }

.card-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.b-green       { background: #E8F5E9; color: #2E7D32; }
.b-green-light { background: #C8E6C9; color: #1B5E20; }
.b-yellow      { background: #FFE0B2; color: #BF360C; }
.b-blue        { background: #E3F2FD; color: #1565C0; }
.b-orange      { background: #FFF3E0; color: #E65100; }
.b-purple      { background: #F3E5F5; color: #7B1FA2; }
.b-gray        { background: #F5F5F5; color: #666; }
.b-red         { background: #FFEBEE; color: #C62828; }
.b-white       { background: #FAFAFA; color: #555; border: 1px solid #E0E0E0; }
.b-pink        { background: #FCE4EC; color: #C2185B; }

/* Badge vai trò tài khoản */
.badge-admin { background: #E8EAF6; color: #3949AB; }
.badge-kh    { background: #E8F5E9; color: #2E7D32; }
.badge-on    { background: #E8F5E9; color: #2E7D32; }
.badge-off   { background: #FFEBEE; color: #C62828; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity .15s;
}

.btn:active { opacity: .8; }

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

.btn-primary:hover { background: var(--primary-light); }

.btn-green {
  background: var(--green);
  color: #fff;
}

.btn-red {
  background: var(--red);
  color: #fff;
}

.btn-outline {
  background: #fff;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}

.btn-sm {
  padding: 7px 13px;
  font-size: 13px;
  border-radius: 7px;
}

.btn:disabled {
  opacity: .4;
  cursor: default;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 15px;
}

th {
  background: var(--primary);
  color: #fff;
  padding: 12px 15px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

td {
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fbff; }

/* ── Form elements ──────────────────────────────────────────── */
.fg {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fg label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.fg input,
.fg select,
.form-input,
.form-select {
  padding: 9px 11px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  font-family: inherit;
  width: 100%;
}

.fg input:focus,
.fg select:focus,
.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary-light);
}

/* ── Empty & loading states ─────────────────────────────────── */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 15px;
}

.spinner {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 15px;
}

/* ── Pager ──────────────────────────────────────────────────── */
.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
}

.pager button {
  padding: 8px 17px;
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  background: #fff;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.pager button:disabled { opacity: .3; cursor: default; }

.pager span {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Detail grid (order detail) ─────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-item {
  padding: 11px 14px;
  background: #F8FBFF;
  border-radius: 9px;
}

.detail-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 3px;
}

.detail-val {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* ── Section header ─────────────────────────────────────────── */
.section-header {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 14px;
}

/* ── Alert / Error box ──────────────────────────────────────── */
.alert-error {
  background: #FFEBEE;
  color: #C62828;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

.alert-success {
  background: #E8F5E9;
  color: #2E7D32;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ── Small modal (dùng cho Sửa user) ────────────────────────── */
.mini-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 600;
  align-items: center;
  justify-content: center;
}

.mini-modal-backdrop.show {
  display: flex;
}

.mini-modal {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 16px 48px rgba(0,0,0,.3);
}

.mini-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
}

/* ── Login Screen (dùng chung index.html + user.html) ───────── */
#login-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--primary);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}

.login-brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.login-brand-name {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

.login-brand-sub {
  font-size: 13px;
  color: rgba(255,255,255,.55);
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
}

.login-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 20px;
  text-align: center;
}

.login-field {
  margin-bottom: 14px;
}

.login-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #444;
  margin-bottom: 5px;
}

.login-field input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}

.login-field input:focus {
  border-color: var(--primary-light);
}

.login-btn {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  margin-top: 6px;
  transition: background .15s;
}

.login-btn:hover   { background: var(--primary-light); }
.login-btn:disabled { opacity: .6; cursor: default; }

.login-error {
  display: none;
  background: #FFEBEE;
  color: #C62828;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 13px;
}

/* ── trang_thai color helper ─────────────────────────────────── */
.tt-delivered { color: #2E7D32; font-weight: 700; }
.tt-violation { color: #C62828; font-weight: 700; }
.tt-other     { color: var(--text-muted); }
