/* Admin & Auth CSS - Modern Redesign */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Sans+Thai:wght@400;500;600;700&display=swap');

:root {
  --admin-sidebar-width: 280px;
  
  /* Modern Color Palette — เขียวตามแบรนด์ CHAP DEE FAST */
  --admin-primary: #1a2e22; /* เขียวเข้มเกือบดำ */
  --admin-primary-light: #2c4a38;
  --admin-primary-accent: #2d7f3e; /* เขียวแบรนด์ */
  --admin-bg: #f4f8f2; /* เขียวอ่อนมาก */
  --admin-card: #ffffff;
  --admin-border: #e2ebe0;
  --admin-text: #33463a;
  --admin-muted: #7c8f83;
  
  /* Status Colors */
  --success: #16a34a;
  --danger: #dc2626;
  --warn: #d97706;
  --info: #2d7f3e;
  
  /* Brand */
  --brand-color: #2d7f3e; /* เขียวแบรนด์ */
  
  /* Shadows & Borders */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
  --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

body.admin-body, body.auth-body {
  margin: 0;
  font-family: 'Inter', 'Noto Sans Thai', sans-serif;
  background-color: var(--admin-bg);
  color: var(--admin-text);
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════
   AUTH LAYOUT & COMPONENTS
   ═══════════════════════════════════════ */
body.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: #b5ead7;
}

.auth-card {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 18px 50px rgba(45, 127, 62, 0.18);
  transform: translateY(0);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.auth-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.1);
}
.auth-card--wide {
  max-width: 650px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--admin-primary);
  margin-bottom: 35px;
  justify-content: center;
  transition: opacity 0.2s;
}
.auth-brand:hover {
  opacity: 0.8;
}
.auth-brand .brand-mark {
  width: 48px;
  height: 48px;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}
.auth-brand span:last-child {
  display: flex;
  flex-direction: column;
}
.auth-brand strong {
  display: block;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #1a2e22;
  line-height: 1.1;
}
.auth-brand small {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: #4a6553;
  font-size: 0.62rem;
  margin-top: 5px;
  line-height: 1;
}
.auth-card h1 {
  text-align: center;
  margin-bottom: 30px;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--admin-primary);
}

.auth-form .form-group {
  margin-bottom: 24px;
}
.auth-form label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--admin-primary-light);
}
.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="tel"] {
  width: 100%;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  font-size: 1rem;
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
  color: var(--admin-primary);
}
.auth-form input:focus {
  background: #fff;
  border-color: #2d7f3e;
  box-shadow: 0 0 0 3px rgba(45, 127, 62, 0.15);
}

.form-row { display: flex; gap: 20px; }
.form-row .form-group { flex: 1; }

.role-options { display: flex; gap: 15px; }
.role-card {
  flex: 1;
  border: 2px solid var(--admin-border);
  border-radius: var(--radius-md);
  padding: 18px 15px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  background: #fff;
  text-align: center;
}
.role-card input {
  position: absolute;
  opacity: 0;
}
.role-card-inner strong {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 1rem;
  color: var(--admin-primary);
  transition: color 0.2s;
}
.role-card-inner strong svg {
  flex-shrink: 0;
  display: block;
}
.role-card-inner span {
  font-size: 0.8rem;
  color: var(--admin-muted);
}
.role-card:has(input:checked) {
  border-color: #2d7f3e;
  background: rgba(45, 127, 62, 0.05);
}
.role-card:has(input:checked) .role-card-inner strong {
  color: #2d7f3e;
}
.role-card:hover {
  border-color: #9dc9a4;
  transform: translateY(-2px);
}

.auth-switch {
  text-align: center;
  margin-top: 30px;
  font-size: 0.95rem;
  color: var(--admin-muted);
}
.auth-switch a {
  color: #2d7f3e;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}
.auth-switch a:hover {
  color: #1a2e22;
  text-decoration: underline;
}

/* ═══════════════════════════════════════
   ADMIN LAYOUT
   ═══════════════════════════════════════ */
.admin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--admin-sidebar-width);
  height: 100vh;
  background: var(--admin-primary);
  background: linear-gradient(180deg, #1a2e22 0%, #24402f 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  z-index: 100;
}
.sidebar-brand {
  padding: 30px 25px;
  display: flex;
  align-items: center;
  gap: 15px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .brand-mark {
  width: 40px;
  height: 40px;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 8px;
}
.sidebar-brand div { display: flex; flex-direction: column; }
.sidebar-brand strong { font-size: 1.2rem; letter-spacing: 0.5px; }
.sidebar-brand small { color: #9db8a5; font-size: 0.8rem; letter-spacing: 0.04em; }

.sidebar-nav {
  flex: 1;
  padding: 25px 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: #cbd5e1;
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
  transform: translateX(5px);
}
.sidebar-nav a.active {
  background: rgba(154, 203, 85, 0.14);
  color: #b9d98b;
  border-left: 4px solid #9acb55;
  font-weight: 600;
}
.sidebar-nav a span { display: flex; }

.sidebar-footer {
  padding: 25px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  background: rgba(0,0,0,0.1);
}
.sidebar-footer span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.sidebar-footer a {
  color: #ef4444;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.1);
}
.sidebar-footer a:hover {
  background: rgba(239, 68, 68, 0.2);
}

.admin-main {
  margin-left: var(--admin-sidebar-width);
  padding: 40px;
  min-height: 100vh;
}
.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}
.page-title {
  margin: 0;
  font-size: 2rem;
  color: var(--admin-primary);
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* ═══════════════════════════════════════
   UI COMPONENTS
   ═══════════════════════════════════════ */
.admin-card {
  background: var(--admin-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 30px;
  margin-bottom: 30px;
  border: 1px solid rgba(0,0,0,0.02);
  transition: box-shadow 0.3s;
}
.admin-card:hover {
  box-shadow: var(--shadow-lg);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}
.card-header h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--admin-primary);
}

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 25px;
  margin-bottom: 40px;
}
.stat-card {
  background: #fff;
  padding: 25px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 6px;
  height: 100%;
  background: var(--admin-primary-accent);
}
.stat-card--warn::before { background: var(--warn); }
.stat-card--green::before { background: var(--success); }

.stat-icon {
  background: #edf4e9;
  color: var(--brand-color);
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  flex-shrink: 0;
}
.stat-icon svg {
  width: 26px;
  height: 26px;
}
.stat-card--warn .stat-icon { background: #fef3e2; color: var(--warn); }
.stat-card--green .stat-icon { background: #e7f6ec; color: var(--success); }
.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--admin-primary);
}
.stat-label {
  color: var(--admin-muted);
  font-size: 0.95rem;
  font-weight: 500;
  margin-top: 5px;
}
.stat-action {
  position: absolute;
  top: 25px;
  right: 25px;
  font-size: 0.85rem;
  text-decoration: none;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.1);
  color: var(--warn);
  padding: 4px 10px;
  border-radius: 20px;
  transition: background 0.2s;
}
.stat-action:hover { background: rgba(245, 158, 11, 0.2); }

/* Tables */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}
.data-table th {
  padding: 15px;
  border-bottom: 2px solid var(--admin-border);
  color: var(--admin-muted);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.data-table td {
  padding: 18px 15px;
  border-bottom: 1px solid var(--admin-border);
  vertical-align: middle;
  color: var(--admin-primary-light);
}
.data-table tr:hover td {
  background: #f8fafc;
}
.td-empty {
  text-align: center;
  padding: 60px !important;
  color: var(--admin-muted);
  font-size: 1.1rem;
}
.product-name-cell {
  display: flex;
  align-items: center;
  gap: 15px;
  font-weight: 500;
}

/* Forms */
.form-stack { display: flex; flex-direction: column; gap: 24px; }
.input-base {
  width: 100%;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.2s ease;
  color: var(--admin-primary);
}
.input-base:focus {
  background: #fff;
  border-color: var(--brand-color);
  box-shadow: 0 0 0 3px rgba(45, 127, 62, 0.15);
  outline: none;
}
select.input-base {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1em;
}
.inline-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.input-sm {
  padding: 8px 12px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: #f8fafc;
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--brand-color) 0%, #246b34 100%);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(45, 127, 62, 0.25);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(45, 127, 62, 0.35);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-full { width: 100%; }
.btn-outline {
  background: transparent;
  border: 2px solid var(--admin-border);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  color: var(--admin-text);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.btn-outline:hover {
  background: var(--admin-bg);
  border-color: #cbd5e1;
}
.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: 8px;
}
.btn-danger {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}
.btn-danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* Badges & Text */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.badge-pending { background: #fffbeb; color: #b45309; border: 1px solid #fef3c7; }
.badge-confirmed { background: #eff6ff; color: #1d4ed8; border: 1px solid #dbeafe; }
.badge-shipped { background: #f0fdf4; color: #15803d; border: 1px solid #dcfce7; }
.badge-completed { background: #ecfdf5; color: #047857; border: 1px solid #d1fae5; }
.badge-cancelled { background: #fef2f2; color: #b91c1c; border: 1px solid #fee2e2; }
.badge svg { width: 13px; height: 13px; }

.text-danger { color: var(--danger); font-weight: 600; }
.text-warn { color: var(--warn); font-weight: 600; }
.text-muted { color: var(--admin-muted); }
.link-muted { color: var(--admin-muted); text-decoration: none; font-weight: 500; transition: color 0.2s; }
.link-muted:hover { color: var(--brand-color); }

/* SVG icons in admin UI */
.sidebar-nav a svg,
.icon-inline {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.page-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-title svg {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  color: var(--brand-color);
}
.sidebar-footer span svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.btn-primary svg,
.btn-outline svg,
.btn-danger svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Layouts */
.admin-two-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 30px;
  align-items: start;
}
.admin-stack {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* Flash */
.flash {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 30px;
  font-weight: 600;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-sm);
  animation: slideIn 0.3s ease forwards;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.flash-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.flash-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Order summary */
.order-summary {
  margin-top: 25px;
  padding-top: 25px;
  border-top: 1px solid var(--admin-border);
  background: #f8fafc;
  border-radius: var(--radius-md);
  padding: 25px;
}
.summary-row {
  display: flex;
  justify-content: flex-end;
  gap: 40px;
  margin-bottom: 12px;
  color: var(--admin-primary-light);
  font-weight: 500;
}
.summary-total {
  font-size: 1.4rem;
  font-weight: 800;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px dashed #cbd5e1;
  color: var(--admin-primary);
}

/* Tabs */
.filter-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 30px;
  background: #fff;
  padding: 10px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  width: fit-content;
}
.filter-tab {
  padding: 10px 20px;
  border-radius: 20px;
  text-decoration: none;
  color: var(--admin-muted);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}
.filter-tab.active {
  background: var(--brand-color);
  color: #fff;
  box-shadow: 0 2px 8px rgba(45, 127, 62, 0.3);
}
.filter-tab:not(.active):hover {
  background: var(--admin-bg);
  color: var(--admin-primary);
}
