/* =============================================
   Custom UI Enhancements — ระบบฐานข้อมูลโครงการ
   ============================================= */

/* ── Typography & Thai Font ── */
body {
  font-family: 'Sarabun', 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.95rem;
  color: #5a5c69;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Sarabun', 'Nunito', sans-serif;
  font-weight: 600;
}

/* ── Sidebar Brand ── */
.sidebar-brand {
  padding: 1rem 1rem;
}
.sidebar-brand-text {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
}
.sidebar .nav-item .nav-link span {
  font-size: 0.88rem;
  font-weight: 500;
}
.sidebar .nav-item .nav-link i {
  font-size: 0.95rem;
}

/* ── Topbar ── */
.topbar {
  height: auto;
  min-height: 4.375rem;
  padding: 0 1.5rem;
}
.topbar-system-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #4e73df;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 480px;
}

/* ── Page Heading ── */
.page-heading-bar {
  border-left: 4px solid #4e73df;
  padding-left: 0.75rem;
  margin-bottom: 1.5rem;
}
.page-heading-bar h1 {
  font-size: 1.3rem;
  color: #3a3b45;
  margin-bottom: 0;
}

/* ── Cards ── */
.card {
  border: none;
  border-radius: 0.5rem;
  box-shadow: 0 0.1rem 1rem 0 rgba(58,59,69,.1) !important;
  transition: box-shadow 0.2s ease;
}
.card:hover {
  box-shadow: 0 0.25rem 1.5rem 0 rgba(58,59,69,.18) !important;
}
.card-header {
  border-radius: 0.5rem 0.5rem 0 0 !important;
  background: #fff;
  border-bottom: 1px solid #e3e6f0;
  padding: 0.85rem 1.25rem;
}
.card-header h6 {
  font-size: 0.9rem;
  font-weight: 700;
  color: #4e73df;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 1.1rem;
}
.form-group label {
  font-weight: 600;
  font-size: 0.875rem;
  color: #5a5c69;
  margin-bottom: 0.35rem;
}
.form-control {
  border-radius: 0.375rem;
  border: 1px solid #d1d3e2;
  font-size: 0.9rem;
  padding: 0.45rem 0.75rem;
  color: #3a3b45;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus {
  border-color: #4e73df;
  box-shadow: 0 0 0 0.15rem rgba(78,115,223,.2);
}
.form-control:disabled,
.form-control[readonly] {
  background-color: #f8f9fc;
  color: #858796;
}
.form-check-label {
  font-size: 0.88rem;
  padding-left: 0.25rem;
}

/* Form card wrapper */
.container.card.shadow,
.card.shadows {
  padding: 1.5rem;
  border-radius: 0.5rem;
}

/* ── Buttons ── */
.btn {
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.45rem 1.1rem;
  transition: all 0.18s ease;
  letter-spacing: 0.02em;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
}
.btn-primary {
  background: linear-gradient(135deg, #4e73df, #3a5fc8);
  border-color: #3a5fc8;
}
.btn-success {
  background: linear-gradient(135deg, #1cc88a, #17a673);
  border-color: #17a673;
}
.btn-info {
  background: linear-gradient(135deg, #36b9cc, #258d9e);
  border-color: #258d9e;
}
.btn-warning {
  background: linear-gradient(135deg, #f6c23e, #e0a800);
  border-color: #e0a800;
  color: #fff;
}
.btn-danger {
  background: linear-gradient(135deg, #e74a3b, #c0392b);
  border-color: #c0392b;
}
.btn-save {
  background: linear-gradient(135deg, #4e73df, #3a5fc8);
  border-color: #3a5fc8;
  color: #fff;
  min-width: 140px;
}
.btn-save:hover {
  color: #fff;
  background: linear-gradient(135deg, #3a5fc8, #2d4ca0);
}
.btn-block-save {
  display: block;
  width: 100%;
  max-width: 200px;
  margin: 1rem auto 0.5rem auto;
}

/* ── Tables ── */
table.dataTable thead th {
  background: #4e73df !important;
  color: #fff !important;
  font-family: 'Sarabun', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  border-bottom: none !important;
  padding: 10px 12px;
}
table.dataTable thead th:first-child { border-radius: 0.375rem 0 0 0; }
table.dataTable thead th:last-child  { border-radius: 0 0.375rem 0 0; }
table.dataTable tbody tr:hover {
  background: #eef0fb !important;
}
table.dataTable tbody td {
  font-size: 0.875rem;
  padding: 8px 12px;
  vertical-align: middle !important;
}
.dataTables_wrapper .dataTables_filter input {
  border-radius: 0.375rem;
  border: 1px solid #d1d3e2;
  padding: 0.3rem 0.6rem;
  font-size: 0.875rem;
}
.dataTables_wrapper .dataTables_length select {
  border-radius: 0.375rem;
  border: 1px solid #d1d3e2;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

/* ── Alerts ── */
.alert {
  border-radius: 0.4rem;
  font-size: 0.875rem;
  border: none;
  padding: 0.75rem 1rem;
}
.alert-success { background: #d4edda; color: #155724; border-left: 4px solid #1cc88a; }
.alert-danger  { background: #fde8e7; color: #842029; border-left: 4px solid #e74a3b; }
.alert-warning { background: #fff3cd; color: #856404; border-left: 4px solid #f6c23e; }
.alert-info    { background: #d1ecf1; color: #0c5460; border-left: 4px solid #36b9cc; }

/* ── Login Modal ── */
#loginModal .modal-content {
  border: none;
  border-radius: 0.75rem;
  box-shadow: 0 0.5rem 2rem rgba(0,0,0,.2);
}
#loginModal .modal-header {
  background: linear-gradient(135deg, #4e73df, #3a5fc8);
  color: #fff;
  border-radius: 0.75rem 0.75rem 0 0;
  padding: 1rem 1.5rem;
}
#loginModal .modal-title { color: #fff; font-weight: 700; font-size: 1.1rem; }
#loginModal .modal-header .close { color: #fff; opacity: 0.8; }
#loginModal .modal-header .close:hover { opacity: 1; }
#loginModal .modal-body { padding: 1.5rem; }
#loginModal .modal-footer {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid #e3e6f0;
}
#loginModal .form-control-user {
  margin-bottom: 0.75rem;
  height: calc(1.5em + 0.75rem + 2px);
}

/* ── Footer ── */
.sticky-footer {
  border-top: 1px solid #e3e6f0;
}
.sticky-footer .copyright {
  font-size: 0.8rem;
  color: #858796;
}

/* ── Scroll to Top ── */
.scroll-to-top {
  background: linear-gradient(135deg, #4e73df, #3a5fc8) !important;
}

/* ── Badge / Status ── */
.badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3em 0.6em;
  border-radius: 0.3rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .topbar-system-title { display: none; }
  .container.card.shadow,
  .card.shadows { padding: 1rem; }
}

/* ── Section Divider ── */
.section-divider {
  border: none;
  border-top: 2px solid #e3e6f0;
  margin: 1.5rem 0;
}

/* ── File Input ── */
input[type="file"].form-control {
  padding: 0.35rem 0.75rem;
  height: auto;
}

/* ── Sidebar Active Nav ── */
.sidebar .nav-item.active .nav-link {
  font-weight: 700;
}

/* ── Chart container ── */
.chart-line {
  position: relative;
  height: 350px;
  width: 100%;
}
/* bar_type is nested inside .chart-line, so inherit height */
.chart-line #bar_type {
  height: 100%;
  width: 100%;
}
/* pie chart has direct container */
#pie_project_by_department {
  height: 350px;
  width: 100%;
}

/* Fix Bootstrap's svg{overflow:hidden} which clips Highcharts SVG */
.highcharts-root {
  overflow: visible !important;
}
svg.highcharts-root {
  overflow: visible !important;
}
