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

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  body {
    @apply font-sans text-gray-800 bg-gray-50;
  }
  h1, h2, h3, h4, h5, h6 {
    @apply font-display font-bold;
  }
}

@layer components {
  .btn {
    @apply px-4 py-2 rounded font-medium transition-colors duration-200;
  }
  .btn-primary {
    @apply bg-primary text-white hover:bg-primary/90;
  }
  .btn-secondary {
    @apply bg-secondary text-white hover:bg-secondary/90;
  }
  .card {
    @apply bg-white rounded-lg shadow-md overflow-hidden;
  }
  .container-custom {
    @apply max-w-7xl mx-auto px-4 sm:px-6 lg:px-8;
  }
}

/* Navigation */
.nav-link {
  @apply relative text-gray-700 hover:text-primary transition-colors duration-200;
}

.nav-link::after {
  @apply absolute left-0 bottom-0 w-0 h-0.5 bg-primary transition-all duration-300 content-[''];
}

.nav-link:hover::after {
  @apply w-full;
}

/* Form styles */
.form-input {
  @apply w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary;
}

.form-label {
  @apply block mb-1 text-sm font-medium text-gray-700;
}

/* Custom Search Dropdown Styles */
.search-label {
  display: flex;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
}

.custom-dropdown {
  position: relative;
  width: 100%;
}

.custom-dropdown-trigger {
  width: 100%;
  padding: 0.875rem 1rem;
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 0.75rem;
  cursor: pointer;
  display: flex;
  justify-content: between;
  align-items: center;
  font-size: 0.875rem;
  color: #374151;
  transition: all 0.3s ease;
  outline: none;
}

.custom-dropdown-trigger:hover {
  border-color: #3498db;
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
}

.custom-dropdown-trigger:focus,
.custom-dropdown.active .custom-dropdown-trigger {
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.custom-dropdown-trigger.disabled {
  background-color: #f9fafb;
  color: #9ca3af;
  cursor: not-allowed;
  border-color: #e5e7eb;
}

.custom-dropdown-trigger.disabled:hover {
  border-color: #e5e7eb;
  box-shadow: none;
}

.dropdown-text {
  flex: 1;
  text-align: left;
}

.dropdown-arrow {
  margin-left: 0.5rem;
  transition: transform 0.3s ease;
  color: #6b7280;
}

.custom-dropdown.active .dropdown-arrow {
  transform: rotate(180deg);
}

.custom-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 2px solid #e5e7eb;
  border-top: none;
  border-radius: 0 0 0.75rem 0.75rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  max-height: 250px;
  overflow-y: auto;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.custom-dropdown.active .custom-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-option {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: #374151;
  transition: all 0.2s ease;
  border-bottom: 1px solid #f3f4f6;
}

.dropdown-option:last-child {
  border-bottom: none;
}

.dropdown-option:hover {
  background-color: #f8fafc;
  color: #3498db;
}

.dropdown-option.selected {
  background-color: #3498db;
  color: white;
}

.dropdown-option.selected:hover {
  background-color: #2980b9;
}

.search-btn {
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
  color: white;
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.search-btn:hover {
  background: linear-gradient(135deg, #2980b9 0%, #1f5f99 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.search-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

/* Custom scrollbar for dropdown menu */
.custom-dropdown-menu::-webkit-scrollbar {
  width: 6px;
}

.custom-dropdown-menu::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Navigation Dropdown Styles */
.nav-dropdown {
  max-height: 350px;
  overflow-y: auto;
  z-index: 50;
  border: none;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 12px;
  margin-top: 4px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.98);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  /* Tạo vùng bridge để không bị mất dropdown */
  top: calc(100% - 4px);
}

/* Add invisible bridge area to prevent dropdown from disappearing */
.group .nav-dropdown::before {
  content: '';
  position: absolute;
  top: -8px;
  left: -20px;
  right: -20px;
  height: 20px;
  background: transparent;
  z-index: 52;
}

.group:hover .nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  transition-delay: 0ms;
}

/* Tăng thời gian delay khi ẩn dropdown */
.nav-dropdown {
  transition-delay: 300ms;
}

.group:hover .nav-dropdown {
  transition-delay: 100ms;
}

/* Thêm hover cho toàn bộ group để giữ dropdown */
.group {
  position: relative;
}

.group::after {
  content: '';
  position: absolute;
  top: 100%;
  left: -10px;
  right: -10px;
  height: 10px;
  background: transparent;
  z-index: 49;
}

.nav-dropdown a {
  position: relative;
  display: flex;
  align-items: center;
  padding: 12px 16px;
  margin: 4px 0;
  border-radius: 12px;
  color: #374151;
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.nav-dropdown a::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.08), rgba(41, 128, 185, 0.12));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.nav-dropdown a:hover {
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.1), rgba(41, 128, 185, 0.15));
  border-left-color: #3498db;
  color: #1e293b;
  transform: translateX(8px);
  box-shadow: 0 8px 25px rgba(52, 152, 219, 0.15);
}

.nav-dropdown a:hover::before {
  opacity: 1;
}

.nav-dropdown a::after {
  content: '→';
  position: absolute;
  right: 16px;
  font-size: 14px;
  color: #3498db;
  opacity: 0;
  transform: translateX(-8px);
  transition: all 0.3s ease;
}

.nav-dropdown a:hover::after {
  opacity: 1;
  transform: translateX(0);
}

/* Enhanced scrollbar styling */
.nav-dropdown::-webkit-scrollbar {
  width: 8px;
}

.nav-dropdown::-webkit-scrollbar-track {
  background: rgba(241, 245, 249, 0.6);
  border-radius: 12px;
  margin: 8px 0;
}

.nav-dropdown::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.6), rgba(41, 128, 185, 0.8));
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.nav-dropdown::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.8), rgba(41, 128, 185, 1));
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* For Firefox */
.nav-dropdown {
  scrollbar-width: thin;
  scrollbar-color: rgba(52, 152, 219, 0.6) rgba(241, 245, 249, 0.6);
}

/* Add modern glow effect */
.group:hover .nav-dropdown {
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(52, 152, 219, 0.1),
    0 0 30px rgba(52, 152, 219, 0.1);
}

/* Subtle animation for parent nav item */
.group .nav-link {
  position: relative;
  transition: all 0.3s ease;
}

.group:hover .nav-link {
  color: #3498db;
}

/* Mobile dropdown styles */
.mobile-dropdown-content {
  max-height: 250px;
  overflow-y: auto;
}

.mobile-dropdown-content::-webkit-scrollbar {
  width: 4px;
}

.mobile-dropdown-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 2px;
}

.mobile-dropdown-content::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 2px;
}

.mobile-dropdown-content::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* CKEditor Table Styles */
.ck-content table,
.prose table {
  border-collapse: collapse;
  border: 1px solid #d1d5db;
  width: 100%;
  margin: 1rem 0;
  display: table;
  background: white;
  border-radius: 0.375rem;
  overflow: hidden;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.ck-content table td,
.ck-content table th,
.prose table td,
.prose table th {
  border: 1px solid #e5e7eb;
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
  word-wrap: break-word;
  word-break: break-word;
}

.ck-content table th,
.prose table th {
  background-color: #f9fafb;
  font-weight: 600;
  color: #374151;
  border-bottom: 2px solid #d1d5db;
}

.ck-content table tr:nth-child(even),
.prose table tr:nth-child(even) {
  background-color: #f8fafc;
}

.ck-content table tr:hover,
.prose table tr:hover {
  background-color: #f1f5f9;
}

.ck-content table caption,
.prose table caption {
  padding: 0.75rem;
  text-align: left;
  caption-side: top;
  font-weight: 600;
  color: #374151;
}

/* Table container with horizontal scroll */
.table-container {
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: 0.375rem;
  border: 1px solid #e5e7eb;
}

.ck-content,
.prose {
  position: relative;
}

@media (max-width: 768px) {
  /* Create scrollable container for tables on tablets */
  .ck-content table,
  .prose table {
    font-size: 0.875rem;
    min-width: 600px; /* Ensure table maintains minimum width */
  }
  
  .ck-content,
  .prose {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .ck-content table td,
  .ck-content table th,
  .prose table td,
  .prose table th {
    padding: 0.5rem;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  /* Card-style layout for mobile phones */
  .ck-content table,
  .prose table {
    border: 0;
    display: block;
    width: 100%;
    margin: 1rem 0;
    box-shadow: none;
  }
  
  .ck-content table thead,
  .prose table thead {
    display: none;
  }
  
  .ck-content table tbody,
  .prose table tbody {
    display: block;
  }
  
  .ck-content table tr,
  .prose table tr {
    border: 1px solid #e5e7eb;
    display: block;
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
  }
  
  .ck-content table tr:nth-child(even),
  .prose table tr:nth-child(even) {
    background-color: white;
  }
  
  .ck-content table tr:hover,
  .prose table tr:hover {
    background-color: #f8fafc;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
  }
  
  .ck-content table td,
  .prose table td {
    border: none;
    display: block;
    padding: 0.5rem 0;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
    position: relative;
    padding-left: 40%;
    white-space: normal;
    word-wrap: break-word;
  }
  
  .ck-content table td:last-child,
  .prose table td:last-child {
    border-bottom: none;
  }
  
  .ck-content table td:before,
  .prose table td:before {
    content: attr(data-label) ": ";
    position: absolute;
    left: 0;
    width: 35%;
    padding-right: 1rem;
    white-space: nowrap;
    font-weight: 600;
    color: #374151;
    text-align: left;
  }
  
  /* Fallback labels when data-label is not available */
  .ck-content table td:nth-child(1):not([data-label]):before,
  .prose table td:nth-child(1):not([data-label]):before {
    content: "Item: ";
  }
  
  .ck-content table td:nth-child(2):not([data-label]):before,
  .prose table td:nth-child(2):not([data-label]):before {
    content: "Details: ";
  }
  
  .ck-content table td:nth-child(3):not([data-label]):before,
  .prose table td:nth-child(3):not([data-label]):before {
    content: "Value: ";
  }
  
  .ck-content table td:nth-child(4):not([data-label]):before,
  .prose table td:nth-child(4):not([data-label]):before {
    content: "Info: ";
  }
}

/* Responsive table wrapper */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Additional table improvements */
.ck-content table td img,
.prose table td img {
  max-width: 100%;
  height: auto;
  border-radius: 0.25rem;
}

.ck-content table td a,
.prose table td a {
  color: #3498db;
  text-decoration: underline;
  word-break: break-all;
}

.ck-content table td strong,
.prose table td strong {
  font-weight: 600;
  color: #1f2936;
}

/* Improve table readability */
@media (min-width: 641px) {
  .ck-content table td,
  .prose table td {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .ck-content table td:hover,
  .prose table td:hover {
    overflow: visible;
    white-space: normal;
    position: relative;
    z-index: 10;
  }
}


