/* =============================================
   Sign Queue System — Main Stylesheet
   ============================================= */
:root {
  --bg-page:    #0f1117;
  --bg-card:    #1a1d27;
  --bg-sidebar: #13151f;
  --bg-input:   #1e2130;
  --border:     #2a2d3e;
  --border-hover: #3d4160;

  --text-primary:   #e8eaf0;
  --text-secondary: #8b90a8;
  --text-muted:     #565b78;

  --accent:     #6366f1;
  --accent-dim: #3730a3;
  --accent-glow:#6366f133;
  --success:    #22c55e;
  --warning:    #f59e0b;
  --danger:     #ef4444;
  --info:       #06b6d4;

  --font-body: 'Sarabun', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  --shadow: 0 2px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}

/* ── Light Theme ── */
body.theme-light {
  --bg-page:    #f0f2f8;
  --bg-card:    #ffffff;
  --bg-sidebar: #1e2130;
  --bg-input:   #f4f5fb;
  --border:     #dde0ee;
  --border-hover: #b0b5d0;

  --text-primary:   #1a1d2e;
  --text-secondary: #4a4f6a;
  --text-muted:     #8b90a8;

  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

/* sidebar stays dark in light mode for contrast */
body.theme-light .sidebar {
  background: var(--bg-sidebar);
  border-right-color: #2a2d3e;
}
body.theme-light .nav-item   { color: #8b90a8; }
body.theme-light .nav-item:hover { background: #252840; color: #e8eaf0; }
body.theme-light .nav-item.active { color: #818cf8; background: #6366f122; border-left-color: #818cf8; }
body.theme-light .nav-label  { color: #565b78; }
body.theme-light .sidebar-footer { border-top-color: #2a2d3e; }
body.theme-light .user-name  { color: #e8eaf0; }
body.theme-light .user-role  { color: #565b78; }
body.theme-light .brand-name { color: #e8eaf0; }
body.theme-light .brand-sub  { color: #565b78; }

/* Theme toggle button */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 0 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #2a2d3e;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  color: #8b90a8;
  width: calc(100% - 16px);
  transition: all .15s;
}
.theme-toggle:hover { background: #252840; color: #e8eaf0; border-color: #3d4160; }
.theme-toggle .toggle-track {
  width: 32px; height: 18px;
  border-radius: 9px;
  background: #2a2d3e;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.theme-toggle .toggle-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #565b78;
  position: absolute;
  top: 3px; left: 3px;
  transition: transform .2s, background .2s;
}
body.theme-light .theme-toggle .toggle-track { background: #6366f1; }
body.theme-light .theme-toggle .toggle-thumb { background: #fff; transform: translateX(14px); }
body.theme-light .theme-toggle { border-color: #3d4160; }


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

body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
}

/* ── Layout ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 28px; }
.brand-name  { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.brand-sub   { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { margin-bottom: 4px; }
.nav-label   {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 10px 16px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.nav-item:hover  { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.user-info   { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar {
  width: 34px; height: 34px;
  background: var(--accent-dim);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.user-name   { font-size: 13px; font-weight: 600; }
.user-role   { font-size: 11px; color: var(--text-muted); }
.btn-logout  {
  display: block; text-align: center;
  padding: 7px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid var(--border);
  color: var(--text-secondary); text-decoration: none;
  font-size: 13px; transition: all .15s;
}
.btn-logout:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ── Main Content ── */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.sidebar-toggle { background: none; border: none; color: var(--text-secondary); font-size: 20px; cursor: pointer; padding: 4px; }
.topbar-title  { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-right  { color: var(--text-muted); font-size: 13px; font-family: var(--font-mono); }

.content-body { padding: 24px; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 16px; font-weight: 600; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 14px; font-weight: 500;
  border: none; cursor: pointer; text-decoration: none;
  transition: all .15s;
}
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: #4f46e5; }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { background: #16a34a; }
.btn-warning  { background: var(--warning); color: #000; }
.btn-warning:hover  { background: #d97706; color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: #dc2626; }
.btn-secondary { background: var(--bg-input); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border-hover); color: var(--text-primary); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-label .req { color: var(--danger); }
.form-control {
  width: 100%; padding: 10px 12px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font-body); font-size: 14px;
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control option { background: var(--bg-card); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 10px 14px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  background: var(--bg-page);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:hover { background: var(--bg-input); }
tbody td { padding: 11px 14px; vertical-align: middle; }

/* ── Status Badge ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 100px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}

/* ── Job Type Badge ── */
.type-badge {
  display: inline-block; padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600;
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-value { font-size: 28px; font-weight: 700; font-family: var(--font-mono); color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Queue Grid ── */
.queue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.job-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color .15s, transform .1s;
}
.job-card:hover { border-color: var(--border-hover); transform: translateY(-1px); }
.job-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.job-number { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--accent); }
.job-customer { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.job-meta { font-size: 13px; color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: 6px; }
.job-meta span::before { content: '•'; margin-right: 6px; color: var(--text-muted); }
.job-meta span:first-child::before { display: none; }
.job-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Due date warning ── */
.due-soon  { color: var(--warning); font-weight: 600; }
.due-late  { color: var(--danger); font-weight: 600; }
.due-ok    { color: var(--text-secondary); }

/* ── Checklist ── */
.checklist { list-style: none; }
.checklist li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.checklist li:last-child { border-bottom: none; }
.checklist input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ── File Upload ── */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--accent); background: var(--accent-glow); }
.file-drop input[type=file] { display: none; }
.file-drop .drop-icon { font-size: 36px; margin-bottom: 10px; }

/* ── Print A6 ── */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin: 0; }
  body { background: #fff; color: #000; }
  .a6-ticket {
    width: 105mm; height: 148mm;
    border: 2px solid #000;
    padding: 10mm;
    margin: 0 auto;
    font-family: 'Sarabun', sans-serif;
    page-break-inside: avoid;
  }
}
.a6-ticket {
  width: 105mm; min-height: 148mm;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg-card);
  font-size: 13px;
}
.a6-ticket .ticket-job { font-size: 18px; font-weight: 700; font-family: var(--font-mono); color: var(--accent); border-bottom: 2px solid var(--border); padding-bottom: 8px; margin-bottom: 10px; }
.a6-ticket table { width: 100%; font-size: 13px; }
.a6-ticket td { padding: 3px 4px; }
.a6-ticket td:first-child { color: var(--text-muted); width: 40%; }
.a6-ticket .qr-box { text-align: center; margin-top: 14px; }
.a6-ticket .qr-box img { width: 100px; height: 100px; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: #052e16; border: 1px solid #166534; color: #86efac; }
.alert-danger   { background: #450a0a; border: 1px solid #991b1b; color: #fca5a5; }
.alert-warning  { background: #422006; border: 1px solid #92400e; color: #fcd34d; }
.alert-info     { background: #0c1a2e; border: 1px solid #0e4070; color: #7dd3fc; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -240px; z-index: 100; transition: left .25s; }
  .sidebar.open { left: 0; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Login Page ── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-page);
  background-image: radial-gradient(ellipse at 50% 0%, #1e1b4b 0%, transparent 60%);
}
.login-box {
  width: 100%; max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .icon { font-size: 48px; }
.login-logo h1 { font-size: 22px; font-weight: 700; margin-top: 8px; }
.login-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; background: var(--bg-page); padding: 4px; border-radius: var(--radius); margin-bottom: 20px; }
.tab-btn { flex: 1; padding: 8px; text-align: center; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; border: none; background: transparent; color: var(--text-secondary); transition: all .15s; }
.tab-btn.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow); }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.7); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px;
  width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: 22px; cursor: pointer; }
