@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
  --fb-blue: #1877F2;
  --fb-blue-dark: #0866FF;
  --fb-blue-light: #e7f3ff;
  --primary: #1877F2;
  --primary-dark: #0866FF;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --purple: #7c3aed;
  --purple-light: #f5f3ff;
  --text-main: #0f172a;
  --text-heading: #0f172a;
  --text-muted: #64748b;
  --bg-main: #f0f2f5;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Prompt', 'Sarabun', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14.5px;
}

/* App Topbar Navigation */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 1.5rem;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.topbar-brand a {
  font-size: 1.05rem;
  color: var(--text-heading);
  text-decoration: none;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-body {
  display: flex;
  min-height: calc(100vh - 60px);
}

/* Sidebar aside styling to work with bandabsmarthub's includes/sidebar.php */
.sidebar-aside {
  width: 280px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  padding: 1.25rem 1rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-mobile-close-bar {
  display: none;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
  font-weight: 700;
  font-size: 1rem;
  color: #0f172a;
}
.sidebar-subtitle {
  font-size: 0.78rem;
  color: var(--primary);
  font-weight: 600;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 0.74rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  margin: 14px 0 6px 4px;
  letter-spacing: 0.5px;
}

.sidebar-item, .sidebar-sub-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  color: #475569;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.sidebar-item:hover, .sidebar-sub-item:hover {
  background: #f1f5f9;
  color: var(--primary);
}

.sidebar-item.active, .sidebar-sub-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.sidebar-sub-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: 0.85rem;
  padding-left: 0.5rem;
  border-left: 2px solid #e2e8f0;
}

.sidebar-dept-header {
  cursor: pointer;
  justify-content: space-between;
}

.dept-chevron {
  font-size: 0.75rem;
  transition: transform 0.25s ease;
}
.dept-chevron.rotated {
  transform: rotate(180deg);
}

/* App Main Content */
.app-main-content {
  flex: 1;
  padding: 1.5rem 2rem;
  max-width: 1400px;
  overflow-x: hidden;
}

/* Cards */
.card, .fb-card {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.glass-card {
  backdrop-filter: blur(10px);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 1.25rem 1.4rem;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-heading);
  margin: 6px 0;
  line-height: 1.2;
}

.stat-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--fb-blue), var(--fb-blue-dark));
  color: #ffffff;
  border-color: var(--fb-blue-dark);
  box-shadow: 0 2px 8px rgba(24, 119, 242, 0.25);
}
.btn-primary:hover {
  background: var(--fb-blue-dark);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #ffffff;
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #ffffff;
}

.btn-outline {
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  color: #334155;
}
.btn-outline:hover {
  border-color: var(--fb-blue);
  color: var(--fb-blue);
  background: var(--primary-light);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light); color: var(--danger); }
.badge-purple  { background: var(--purple-light); color: var(--purple); }

/* Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: #ffffff;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 1.5px solid var(--border-color);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.table tr:hover td {
  background: #f8fafc;
}

/* Form Controls */
.form-group {
  margin-bottom: 1.1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  border: 1.5px solid var(--border-color);
  border-radius: 9px;
  background: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--fb-blue);
  box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.12);
}

/* Filter Navigation Bar */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filter-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  color: #475569;
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter-tab:hover {
  background: #f1f5f9;
  color: var(--primary);
  border-color: #cbd5e1;
}

.filter-tab.active {
  background: var(--fb-blue);
  color: #ffffff;
  border-color: var(--fb-blue);
  box-shadow: 0 2px 6px rgba(24, 119, 242, 0.3);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-box, .modal-card {
  background: #ffffff !important;
  border-radius: 20px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  animation: modalFadeIn 0.25s ease-out;
  position: relative;
  z-index: 10000;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header, .modal-head {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border-radius: 20px 20px 0 0;
}

.modal-title, .modal-head h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-heading);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}
.modal-close:hover {
  color: #dc2626;
  background: #fee2e2;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-radius: 0 0 18px 18px;
}

/* =========================================================
   A4 PRINT STYLESHEET
   ========================================================= */
@page {
  size: A4 portrait;
  margin: 18mm 15mm 18mm 15mm;
}

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-family: 'Sarabun', 'TH Sarabun New', sans-serif !important;
    font-size: 14pt !important;
    line-height: 1.35 !important;
  }

  .app-topbar,
  .sidebar-aside,
  .btn-print-screen,
  .no-print,
  #sidebarMenu,
  header {
    display: none !important;
  }

  .app-body {
    display: block !important;
  }

  .app-main-content {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  .print-page {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    page-break-after: always;
  }

  .print-header {
    text-align: center;
    margin-bottom: 20px;
  }

  .print-logo {
    width: 65px;
    height: 65px;
    object-fit: contain;
    margin: 0 auto 10px auto;
    display: block;
  }

  .print-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 15px 0 !important;
    font-size: 13pt !important;
  }

  .print-table th,
  .print-table td {
    border: 1px solid #000000 !important;
    padding: 7px 10px !important;
  }

  .print-table th {
    background: #f1f5f9 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .sign-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 25px !important;
    margin-top: 35px !important;
    page-break-inside: avoid !important;
  }

  .sign-box {
    text-align: center !important;
    font-size: 13pt !important;
    line-height: 1.4 !important;
  }

  .sign-dots {
    border-bottom: 1px dotted #000000;
    display: inline-block;
    width: 180px;
    height: 24px;
    margin-bottom: 4px;
  }
}
