@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600&display=swap');

:root {
  --primary-color: #4CAF50;
  --primary-dark: #388E3C;
  --secondary-color: #0288D1;
  --accent-color: #FBC02D;
  --danger-color: #D32F2F;
  --text-color: #333;
  --bg-color: #f4f7f6;
  --card-bg: #fff;
  --sidebar-width: 250px;
  --header-height: 60px;
  --transition: all 0.3s ease;
}

body {
  font-family: 'Kanit', sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  color: var(--text-color);
  overflow-x: hidden;
}

/* AUTH Layout */
#auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.login-card {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 400px;
  text-align: center;
}

.login-card h2 {
  color: var(--primary-dark);
  margin-bottom: 20px;
}

/* MAIN Layout */
#app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-width);
  background: white;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
  position: fixed;
  height: 100%;
  left: 0;
  top: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #eee;
  color: var(--primary-color);
  font-weight: 600;
  font-size: 1.2rem;
}

.nav-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-links li a {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  text-decoration: none;
  color: #666;
  transition: var(--transition);
  border-left: 4px solid transparent;
}

.nav-links li a:hover,
.nav-links li a.active {
  background: #f0f7f1;
  color: var(--primary-color);
  border-left-color: var(--primary-color);
}

.nav-links li a i {
  margin-right: 15px;
  width: 20px;
  text-align: center;
}

/* Collapsible Menu Headers */
.nav-links li a[onclick*="toggleSubMenu"] {
  background: linear-gradient(135deg, #388E3C, #43A047);
  color: white !important;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  border-left: 4px solid #2E7D32 !important;
  padding: 12px 20px;
}

.nav-links li a[onclick*="toggleSubMenu"]:hover {
  background: linear-gradient(135deg, #2E7D32, #388E3C);
  color: white !important;
  border-left-color: #1B5E20 !important;
}

.nav-links li a[onclick*="toggleSubMenu"] i.fa-chevron-down {
  color: rgba(255,255,255,0.7);
  margin-right: 0;
}

/* Submenu Items (lighter shade) */
.nav-links div[id$="-submenu"] li a {
  background: #e8f5e9;
  color: #2E7D32 !important;
  font-size: 0.85rem;
  padding: 11px 20px 11px 25px;
  border-left: 4px solid transparent;
  border-bottom: 1px solid rgba(76,175,80,0.1);
}

.nav-links div[id$="-submenu"] li a:hover,
.nav-links div[id$="-submenu"] li a.active {
  background: #c8e6c9;
  color: #1B5E20 !important;
  border-left-color: #4CAF50;
}

.nav-links div[id$="-submenu"] li a i {
  color: #4CAF50;
}

/* Main Content */
#main-content {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  padding: 20px;
  transition: var(--transition);
}

.top-bar {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.hamburger {
  display: none;
  font-size: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary-color);
}

/* Cards & Dashboard */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  border-top: 4px solid var(--primary-color);
}

.card h3 {
  margin-top: 0;
  color: #777;
  font-size: 0.9rem;
  text-transform: uppercase;
}

.card .value {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text-color);
}

/* Forms */
.form-group {
  margin-bottom: 15px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: #555;
}

/* Premium Input Style (Tailwind-inspired) */
.form-control {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: #1f2937;
  /* gray-800 */
  background-color: #fff;
  background-clip: padding-box;
  border: 1px solid #d1d5db;
  /* gray-300 */
  border-radius: 0.375rem;
  /* rounded-md */
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  /* shadow-sm */
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  appearance: none;
}

.form-control:focus {
  color: #1f2937;
  background-color: #fff;
  border-color: #6366f1;
  /* indigo-500 */
  outline: 0;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  /* ring-indigo-500/25 */
}

.form-control::placeholder {
  color: #9ca3af;
  /* gray-400 */
  opacity: 1;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-secondary {
  background: #eee;
  color: #333;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

th,
td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

th {
  background-color: #f8f9fa;
  color: #444;
  font-weight: 600;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  #sidebar {
    left: -250px;
  }

  #sidebar.active {
    left: 0;
  }

  #main-content {
    margin-left: 0;
    width: 100%;
  }

  .hamburger {
    display: block;
  }

  .overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
  }

  .overlay.active {
    display: block;
  }
}

/* --- UI LIB OVERRIDES --- */

/* Fix SweetAlert2 Input Width Issues */
div:where(.swal2-container) input:where(.swal2-input),
div:where(.swal2-container) file:where(.swal2-file),
div:where(.swal2-container) textarea:where(.swal2-textarea),
div:where(.swal2-container) select:where(.swal2-select),
div:where(.swal2-container) div:where(.swal2-radio),
div:where(.swal2-container) label:where(.swal2-checkbox) {
  margin: 1em 0;
  /* Align with standard form group */
  width: 100% !important;
  /* Force full width */
  box-sizing: border-box !important;
}

/* Remove default Swal input margin if inside a form-group to prevent double spacing */
.swal2-html-container .form-group input,
.swal2-html-container .form-group select {
  margin: 0 !important;
}

/* Tom Select Integration */
/* Tom Select Integration - Match Premium Style */
.ts-control {
  border-radius: 0.375rem !important;
  border: 1px solid #d1d5db !important;
  padding: 0.6rem 0.75rem !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
  font-size: 1rem !important;
  background-color: #fff !important;
}

.ts-control.focus {
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25) !important;
}

/* Flatpickr Integration */
.flatpickr-input {
  background-color: #fff !important;
  height: 38px !important;
  box-sizing: border-box;
}

/* Ensure Dropdowns appear ON TOP of Modal */
.swal2-container {
  z-index: 2000 !important;
}

.flatpickr-calendar {
  z-index: 2005 !important;
}

/* Tom Select Dropdown Z-Index fix */
.ts-dropdown {
  z-index: 2005 !important;
}

/* General Modal Tweaks */
.swal2-popup {
  padding: 2em !important;
}

.swal2-html-container {
  margin: 1em 0 0 !important;
  text-align: left !important;
  /* Align form left */
  overflow: visible !important;
  /* Allow dropdowns to overflow */
}

.swal2-html-container .form-group {
  margin-bottom: 15px;
}

/* Premium SweetAlert2 Buttons */
.swal2-popup .swal2-actions {
  gap: 15px;
  /* Add space between buttons */
}

.swal2-confirm,
.swal2-cancel {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
  /* shadow-md */
  border: none !important;
  border-radius: 0.375rem !important;
  /* rounded-md */
  padding: 0.75rem 1.5rem !important;
  font-weight: 500 !important;
  font-size: 1rem !important;
  transition: all 0.2s ease !important;
}

.swal2-confirm {
  background-color: #4CAF50 !important;
  /* Green */
}

.swal2-confirm:hover {
  background-color: #43A047 !important;
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
  /* shadow-lg */
}

.swal2-cancel {
  background-color: #ef4444 !important;
  /* Red */
  color: white !important;
}

.swal2-cancel:hover {
  background-color: #dc2626 !important;
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
  /* shadow-lg */
}

/* ========== REPORT STYLES ========== */

.report-section {
  margin-bottom: 12px;
}

.report-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin: 0 0 6px 0;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--primary-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.report-section-title i {
  color: var(--primary-color);
}

/* Report Table — Bordered, Formal */
.report-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 0.78rem;
}

.report-table th,
.report-table td {
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  text-align: center;
}

.report-table thead th {
  background: linear-gradient(135deg, #2d3748, #4a5568);
  color: white;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  padding: 5px 8px;
}

.report-table tbody tr:nth-child(even) {
  background-color: #f9fafb;
}

.report-table tbody tr:hover {
  background-color: #eef2ff;
}

.report-table tbody td {
  color: #374151;
}

.report-table .empty-row td {
  color: #d1d5db;
  height: 22px;
}

/* Summary Row */
.report-summary-row td {
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9) !important;
  font-weight: 700 !important;
  color: #1b5e20 !important;
  font-size: 0.8rem;
  border-top: 2px solid var(--primary-color);
}

/* Export Buttons */
.export-btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.export-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.export-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.export-btn-excel {
  background: linear-gradient(135deg, #217346, #2e7d32);
  color: white;
}

.export-btn-excel:hover {
  background: linear-gradient(135deg, #1b5e20, #217346);
}

.export-btn-pdf {
  background: linear-gradient(135deg, #c62828, #e53935);
  color: white;
}

.export-btn-pdf:hover {
  background: linear-gradient(135deg, #b71c1c, #c62828);
}

/* Report Filter Bar */
.report-filter-bar {
  display: flex;
  gap: 25px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.report-filter-bar .filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.report-filter-bar .filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: #555;
}

.report-filter-bar .filter-group input.form-control,
.report-filter-bar .filter-group select.form-control {
  height: 38px;
  box-sizing: border-box;
}

.report-filter-bar .btn {
  height: 38px;
  box-sizing: border-box;
}

/* Print-friendly: hide non-report elements when printing */
@media print {

  #sidebar,
  .top-bar,
  .report-filter-bar,
  .export-btn-group,
  .hamburger,
  .overlay {
    display: none !important;
  }

  #main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }
}