body, .font-sans {
  font-family: 'CMU', sans-serif !important;
}

/* SweetAlert (toast / flash) แสดงบนสุดของทุกอย่าง */
.swal2-container {
  z-index: 999999 !important;
}

/* ตารางรายการผู้ใช้ - hover แถว (Soft UI style) */
#users-table .user-row:hover {
  background-color: #f8fafc !important; /* slate-50 */
  transition: background-color 0.15s ease;
}

/* ตารางรายการงานประชุม - hover แถว (Soft UI style) */
#meeting-table .meeting-row:hover {
  background-color: #f8fafc !important; /* slate-50 */
  transition: background-color 0.15s ease;
}

/* ปุ่มในตารางรายการผู้ใช้ - กำหนดสีโดยตรง (ไม่พึ่ง Tailwind) */
.btn-view-detail {
  background-color: #2563eb !important;
  color: #fff !important;
}
.btn-view-detail:hover {
  background-color: #1d4ed8 !important;
}
.btn-view-detail:active {
  background-color: #1e40af !important;
}
.btn-edit-user {
  background-color: #d97706 !important;
  color: #fff !important;
}
.btn-edit-user:hover {
  background-color: #b45309 !important;
}
.btn-edit-user:active {
  background-color: #92400e !important;
}
.btn-delete-user {
  background-color: #dc2626 !important;
  color: #fff !important;
}
.btn-delete-user:hover {
  background-color: #b91c1c !important;
}
.btn-delete-user:active {
  background-color: #991b1b !important;
}

/* Desktop only - show on xl (1280px) and above */
.desktop-only,
.desktop-only-flex {
  display: none !important;
}

/* Mobile only - hide on xl (1280px) and above */
.mobile-only {
  display: block !important;
}

.mobile-only-flex {
  display: flex !important;
}

@media screen and (min-width: 1280px) {
  .desktop-only {
    display: block !important;
  }
  .desktop-only-flex {
    display: flex !important;
  }
  .mobile-only,
  .mobile-only-flex {
    display: none !important;
  }
}

@keyframes fade-in-up {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in-up {
  animation: fade-in-up 0.8s ease-out forwards;
}

/* Modal - ใช้ visibility แทน opacity ของพ่อ เพื่อให้ backdrop เบลอได้ตอนเปิด */
[data-modal] {
  visibility: hidden;
  pointer-events: none;
  opacity: 1;
}
[data-modal].modal-open {
  visibility: visible;
  pointer-events: auto;
}
/* Backdrop: ตอนปิด opacity 0 + blur(0) → ตอนเปิด opacity 1 + blur(8px) เลยเห็นการเบลอชัด */
[data-modal] [data-modal-backdrop] {
  opacity: 0;
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition: opacity 0.35s ease-out, backdrop-filter 0.5s cubic-bezier(0.33, 1, 0.68, 1);
}
[data-modal].modal-open [data-modal-backdrop] {
  opacity: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  will-change: backdrop-filter;
}
/* กล่องเนื้อหา: scale + fade */
[data-modal] .modal-content-box {
  transform: scale(0.96);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.33, 1, 0.68, 1), opacity 0.4s cubic-bezier(0.33, 1, 0.68, 1);
  transition-delay: 0.06s;
}
[data-modal].modal-open .modal-content-box {
  transform: scale(1);
  opacity: 1;
  transition-delay: 0s;
}

/* Page Loader */
#loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #f8fafc; /* Slate-50 */
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.6s;
  backdrop-filter: blur(5px);
}

#loader.hidden {
  opacity: 0;
  visibility: hidden;
}

.loader-content {
  position: relative;
  width: 180px;
  height: 180px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.logo-container {
  width: 100px;
  height: 100px;
  background: white;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 10px 25px rgba(59, 130, 246, 0.15); /* Soft blue shadow */
  z-index: 10;
  position: relative;
}

/* Glowing blur effect behind logo */
.logo-container::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #22c55e);
  z-index: -1;
  opacity: 0.4;
  filter: blur(12px);
  animation: pulse-glow 2s ease-in-out infinite alternate;
}

.logo-container img {
  width: 65%;
  height: auto;
  object-fit: contain;
}

.spinner-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #3b82f6; /* Blue-500 */
  border-bottom-color: #22c55e; /* Green-500 */
  animation: spin-elastic 1.5s ease-in-out infinite;
  filter: drop-shadow(0 0 2px rgba(59, 130, 246, 0.3));
}

.spinner-ring::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-left-color: #60a5fa; /* Blue-400 */
  border-right-color: #4ade80; /* Green-400 */
  animation: spin-elastic 2s ease-in-out infinite reverse;
}

.loading-text {
  margin-top: 32px;
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: #64748b; /* Slate-500 fallback */
  display: flex; /* Flex to align spans */
  gap: 2px;
}

.loading-text span {
  display: inline-block;
  animation: letter-wave 1.2s ease-in-out infinite; /* Smoother timing */
  background: linear-gradient(to bottom, #3b82f6, #059669); 
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0.6; /* Higher base opacity for smoothness */
  transform: translateY(0);
}

.loading-text span:nth-child(1) { animation-delay: 0.0s; }
.loading-text span:nth-child(2) { animation-delay: 0.1s; }
.loading-text span:nth-child(3) { animation-delay: 0.2s; }
.loading-text span:nth-child(4) { animation-delay: 0.3s; }
.loading-text span:nth-child(5) { animation-delay: 0.4s; }
.loading-text span:nth-child(6) { animation-delay: 0.5s; }
.loading-text span:nth-child(7) { animation-delay: 0.6s; }
.loading-text span:nth-child(8) { animation-delay: 0.7s; }
.loading-text span:nth-child(9) { animation-delay: 0.8s; }
.loading-text span:nth-child(10) { animation-delay: 0.9s; }

@keyframes letter-wave {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  50% {
    transform: translateY(-8px); /* Higher jump */
    opacity: 1;
    text-shadow: 0 4px 8px rgba(59, 130, 246, 0.2); /* Soft shadow */
  }
}

@keyframes spin-elastic {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulse-glow {
  0% { opacity: 0.3; transform: scale(0.95); }
  100% { opacity: 0.6; transform: scale(1.05); }
}

@keyframes slide-in-left {
  0% {
    transform: translateX(-100%);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

.animate-slide-in-left {
  animation: slide-in-left 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slide-in-top {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.animate-slide-in-top {
  animation: slide-in-top 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slide-in-right {
  0% {
    transform: translateX(100%);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

.animate-slide-in-right {
  animation: slide-in-right 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Mobile Sidebar - hide completely when closed */
@media (max-width: 1279px) {
  aside#sidenav-main {
    transform: translateX(calc(-100% - 2rem)) !important;
  }
}

/* Mobile Sidebar Toggle */
.sidenav-show aside#sidenav-main {
  transform: translateX(0) !important;
}

/* Mobile overlay when sidebar is open */
.sidenav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 980;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidenav-show .sidenav-overlay {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Mobile Navbar Adjustments */
@media (max-width: 1024px) {
  main {
    margin-left: 0 !important;
  }
  
  aside {
    z-index: 1000 !important;
  }
}

@media (max-width: 768px) {
  /* Navbar mobile adjustments */
  nav[navbar-main] {
    padding: 0.5rem 0 !important;
    margin: 0.75rem !important;
  }
  
  nav[navbar-main] .flex-wrap-inherit {
    flex-wrap: wrap !important;
    gap: 0.5rem;
  }
  
  /* Breadcrumb hide on very small screens */
  nav[navbar-main] nav ol {
    display: none;
  }
  
  /* Page title adjustment */
  nav[navbar-main] nav h6 {
    font-size: 1rem;
  }
  
  /* User info mobile adjustments */
  .user-info-desktop {
    display: none !important;
  }
  
  .user-info-mobile {
    display: flex !important;
  }
  
  /* Navbar icons and buttons */
  nav[navbar-main] ul {
    gap: 0.25rem !important;
  }
  
  nav[navbar-main] ul li a {
    padding: 0.5rem !important;
  }
  
  /* Main content padding */
  .w-full.px-6 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  
  /* Cards responsive */
  .flex-wrap > [class*="w-1/4"] {
    width: 50% !important;
  }
}

@media (max-width: 640px) {
  /* Navbar compact mode */
  nav[navbar-main] {
    padding: 0.5rem !important;
    margin: 0.5rem !important;
  }
  
  /* Full width cards on mobile */
  .flex-wrap > [class*="w-1/4"],
  .flex-wrap > [class*="w-1/2"] {
    width: 100% !important;
    flex: none !important;
  }
  
  /* Main content padding */
  .w-full.px-6,
  .px-6 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  
  .py-6 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }
  
  /* Table responsive */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Hide user email on small mobile */
  .user-email-text {
    display: none !important;
  }
  
  /* Logout button text */
  .logout-text {
    display: none !important;
  }
  
  /* Footer adjustments */
  footer {
    padding: 1rem 0.5rem !important;
  }
  
  footer .flex-wrap {
    flex-direction: column;
    text-align: center;
  }
  
  /* Sidebar close button */
  aside i[sidenav-close] {
    display: block !important;
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.25rem;
    cursor: pointer;
    z-index: 10;
  }
}

@media (max-width: 480px) {
  /* Very small screens */
  nav[navbar-main] nav h6 {
    font-size: 0.875rem;
  }
  
  /* Card content adjustments */
  .p-4 {
    padding: 0.75rem !important;
  }
  
  /* Text size adjustments */
  h5 {
    font-size: 1rem !important;
  }
  
  .text-sm {
    font-size: 0.75rem !important;
  }
  
  /* Avatar smaller on mobile */
  .w-9, .h-9 {
    width: 2rem !important;
    height: 2rem !important;
  }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  a, button {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Sidebar items touch-friendly */
  aside ul li a {
    padding: 0.875rem 1rem !important;
  }
  
  /* Remove hover effects on touch devices */
  .hover\:scale-102:hover {
    transform: none;
  }
}

/* Safe area insets for notched phones */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
  
  aside {
    padding-left: max(1rem, env(safe-area-inset-left));
  }
}

/* Smooth scrolling for mobile */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Prevent horizontal scroll on mobile */
body {
  overflow-x: hidden;
}

/* Mobile-friendly dropdown menus */
@media (max-width: 768px) {
  [dropdown-menu] {
    position: fixed !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    top: auto !important;
    bottom: 1rem !important;
    max-height: 60vh;
    overflow-y: auto;
    border-radius: 1rem !important;
  }
}

/* Animation adjustments for reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
