/* =========================================================
   ระบบทะเบียนครุภัณฑ์ — Custom Stylesheet
   ========================================================= */
:root {
  --sidebar-width: 260px;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #3b82f6;
  --topbar-height: 60px;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --body-bg: #f1f5f9;
  --card-bg: #ffffff;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --font: 'Sarabun', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--body-bg);
  color: #1e293b;
  font-size: 15px;
  overflow-x: hidden;
}

/* =========================================================
   WRAPPER / LAYOUT
   ========================================================= */
.wrapper { display: flex; min-height: 100vh; }

/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 1000;
  transition: transform .3s ease;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
  flex-shrink: 0;
}

.brand-title { display: block; font-size: 14px; font-weight: 700; color: #fff; line-height: 1.2; }
.brand-subtitle { display: block; font-size: 11px; color: #94a3b8; }

.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.user-avatar {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.12);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role { margin-top: 2px; }

.sidebar-nav { list-style: none; padding: 12px 0; margin: 0; flex: 1; }

.nav-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #475569;
  padding: 12px 20px 4px;
  font-weight: 600;
}

.sidebar-nav .nav-item { margin: 2px 8px; }

.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  color: #94a3b8;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .2s;
}
.sidebar-nav .nav-link i { font-size: 16px; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav .nav-item.active .nav-link {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,.4);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-logout {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  color: #94a3b8;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  transition: all .2s;
}
.sidebar-logout:hover { background: rgba(239,68,68,.15); color: #ef4444; }

/* =========================================================
   MAIN CONTENT
   ========================================================= */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .3s ease;
}

/* TOPBAR */
.topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky; top: 0; z-index: 900;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar-btn {
  background: none; border: none;
  font-size: 22px; color: #475569;
  cursor: pointer; padding: 4px;
  border-radius: 6px;
  transition: background .2s;
}
.topbar-btn:hover { background: var(--body-bg); }
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; color: #1e293b; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-user-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px;
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font); font-size: 14px;
  cursor: pointer; color: #374151;
  transition: all .2s;
}
.topbar-user-btn:hover { background: var(--body-bg); }
.avatar-sm {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px;
}

.content-area { padding: 24px; flex: 1; }

/* =========================================================
   CARDS
   ========================================================= */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  background: none;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  font-weight: 600;
  font-size: 15px;
}

/* STAT CARDS */
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--border);
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 54px; height: 54px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #eff6ff; color: var(--primary); }
.stat-icon.green  { background: #ecfdf5; color: var(--success); }
.stat-icon.yellow { background: #fffbeb; color: var(--warning); }
.stat-icon.red    { background: #fef2f2; color: var(--danger); }
.stat-icon.purple { background: #f5f3ff; color: #7c3aed; }

.stat-value { font-size: 28px; font-weight: 700; line-height: 1; color: #1e293b; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* =========================================================
   TABLES
   ========================================================= */
.table { font-size: 14px; }
.table th { font-weight: 600; color: #475569; background: #f8fafc; font-size: 13px; }
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fafc; }

/* =========================================================
   FORMS
   ========================================================= */
.form-label { font-weight: 500; font-size: 14px; color: #374151; }
.form-control, .form-select {
  border-radius: 8px;
  border: 1px solid var(--border);
  font-family: var(--font);
  font-size: 14px;
  padding: 9px 14px;
  transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-text { font-size: 12px; color: var(--text-muted); }
.required-mark { color: var(--danger); }

/* =========================================================
   BUTTONS
   ========================================================= */
.btn { border-radius: 8px; font-family: var(--font); font-weight: 500; font-size: 14px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sm { border-radius: 6px; }

/* =========================================================
   BADGES
   ========================================================= */
.badge { font-weight: 500; font-size: 11px; padding: 4px 8px; border-radius: 6px; }

/* =========================================================
   PAGE HEADER
   ========================================================= */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 22px; font-weight: 700; margin: 0; color: #1e293b; }
.page-header .breadcrumb { margin: 0; }
.breadcrumb-item, .breadcrumb-item a { font-size: 13px; color: var(--text-muted); }
.breadcrumb-item.active { color: #1e293b; }

/* =========================================================
   EQUIPMENT CODE
   ========================================================= */
.equipment-code {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  font-size: 13px;
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 4px;
  color: #1e293b;
  letter-spacing: .5px;
}

/* =========================================================
   LOGIN PAGE
   ========================================================= */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 60%, #1e3a5f 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 440px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  overflow: hidden;
}
.login-header {
  background: linear-gradient(135deg, var(--primary), #6366f1);
  padding: 32px 40px;
  text-align: center;
  color: #fff;
}
.login-logo {
  width: 64px; height: 64px;
  background: rgba(255,255,255,.2);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin: 0 auto 12px;
}
.login-header h1 { font-size: 20px; font-weight: 700; margin: 0; }
.login-header p { margin: 4px 0 0; opacity: .8; font-size: 13px; }
.login-body { padding: 32px 40px; }

/* =========================================================
   PRINT LABEL
   ========================================================= */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .content-area { padding: 0 !important; }
  body { background: #fff; }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
.sidebar.collapsed { transform: translateX(-100%); }
.main-content.expanded { margin-left: 0; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .content-area { padding: 16px; }
  .stat-value { font-size: 22px; }
  .login-body { padding: 24px 20px; }
  .login-header { padding: 24px 20px; }
}

/* =========================================================
   OVERLAY
   ========================================================= */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}
.sidebar-overlay.show { display: block; }

/* =========================================================
   MISC
   ========================================================= */
.text-muted { color: var(--text-muted) !important; }
.img-thumbnail-sm { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; }
.dataTables_wrapper .dataTables_filter input { border-radius: 8px; border: 1px solid var(--border); padding: 6px 12px; }
.dataTables_wrapper .dataTables_length select { border-radius: 8px; border: 1px solid var(--border); }
.alert { border-radius: 10px; font-size: 14px; }
