/* Custom CSS for AppSheet Integration */

/* Base styles */
* {
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  line-height: 1.6;
  color: #374151;
}

/* Mobile-first responsive design */
@media (max-width: 767px) {
  #desktopView {
    display: none !important;
  }

  #desktopView * {
    display: none !important;
  }

  #mobileView {
    display: block !important;
  }

  /* Hide any desktop table elements that might still show */
  table.min-w-full {
    display: none !important;
  }

  thead.bg-gray-50 {
    display: none !important;
  }
}

@media (min-width: 768px) {
  #desktopView {
    display: block !important;
  }

  #mobileView {
    display: none !important;
  }

  /* Ensure table elements are visible on desktop */
  table.min-w-full {
    display: table !important;
  }

  thead.bg-gray-50 {
    display: table-header-group !important;
  }
}

/* Input error styles */
.input-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* Loading spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff40;
  border-top: 2px solid #ffffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Modal animations */
.modal-enter {
  animation: modalEnter 0.3s ease-out;
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Focus styles */
.focus-ring:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
}

/* Gradient text */
.gradient-text {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Card hover effects */
.card-hover {
  transition: all 0.3s ease;
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Button animations */
.btn-animate {
  transition: all 0.2s ease;
}

.btn-animate:hover {
  transform: translateY(-1px);
}

.btn-animate:active {
  transform: translateY(0);
}

/* Glass morphism effect */
.glass {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Responsive utilities */
@media (max-width: 640px) {
  .mobile-full {
    width: 100% !important;
  }

  .mobile-text-sm {
    font-size: 0.875rem !important;
  }
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .bg-gray-50 {
    background-color: #ffffff !important;
  }

  .text-gray-600 {
    color: #000000 !important;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .dark-mode-auto {
    background-color: #1f2937;
    color: #f9fafb;
  }
}

/* Custom form styles */
.form-input {
  transition: all 0.2s ease;
}

.form-input:focus {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

/* Toast notification styles */
.toast-enter {
  animation: toastEnter 0.3s ease-out;
}

.toast-exit {
  animation: toastExit 0.3s ease-in;
}

@keyframes toastEnter {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastExit {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* Enhanced Card Styles for Don An */
.case-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.case-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  border-color: #cbd5e0;
}

.case-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, #fbbf24, #f59e0b);
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.025em;
}

.status-civil {
  background-color: #dbeafe;
  color: #1e40af;
}

.status-criminal {
  background-color: #fecaca;
  color: #b91c1c;
}

.status-admin {
  background-color: #e9d5ff;
  color: #7c2d12;
}

/* Table enhancements */
.table-row:hover {
  background-color: #f8fafc;
  transform: scale(1.01);
  transition: all 0.2s ease;
}

/* Data display helpers */
.data-chip {
  display: inline-block;
  background-color: #f1f5f9;
  color: #475569;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  margin: 1px;
  border: 1px solid #e2e8f0;
}

.data-chip:hover {
  background-color: #e2e8f0;
}

/* Responsive text truncation */
.text-truncate-mobile {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

@media (max-width: 768px) {
  .text-truncate-mobile {
    max-width: 120px;
  }
}

/* Enhanced form layout */
.form-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.form-section h3 {
  color: #374151;
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Enhanced search styles */
.search-highlight {
  background-color: #fef3c7;
  padding: 1px 2px;
  border-radius: 2px;
}

/* Loading states */
.loading-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Enhanced pagination */
.pagination-button {
  transition: all 0.2s ease;
}

.pagination-button:hover {
  background-color: #fef3c7;
  color: #92400e;
  transform: translateY(-1px);
}

.pagination-button.active {
  background-color: #f59e0b;
  color: white;
  font-weight: 600;
}

/* Accessibility improvements */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visible for keyboard navigation */
.focus-visible:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Custom checkbox and radio styles */
.custom-checkbox {
  appearance: none;
  width: 1rem;
  height: 1rem;
  border: 2px solid #d1d5db;
  border-radius: 0.25rem;
  background-color: #ffffff;
  cursor: pointer;
  position: relative;
}

.custom-checkbox:checked {
  background-color: #3b82f6;
  border-color: #3b82f6;
}

.custom-checkbox:checked::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 0.75rem;
  font-weight: bold;
}

/* Utility classes */
.text-shadow {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.border-gradient {
  border: 2px solid transparent;
  background: linear-gradient(white, white) padding-box,
    linear-gradient(135deg, #667eea, #764ba2) border-box;
}

/* Performance optimizations */
.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

/* Container queries support */
@container (min-width: 768px) {
  .container-md\:text-lg {
    font-size: 1.125rem;
  }
}

/* Law Modal Styles */
.law-checkbox:checked {
  background-color: #2563eb;
  border-color: #2563eb;
}

.law-checkbox:focus {
  box-shadow: 0 0 0 2px #2563eb;
  outline: none;
}

/* Selected law chips */
.law-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  margin: 0.125rem;
  background-color: #dbeafe;
  color: #1e40af;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.15s ease-in-out;
}

.law-chip:hover {
  background-color: #bfdbfe;
}

.law-chip button {
  margin-left: 0.25rem;
  padding: 0.125rem;
  border-radius: 50%;
  color: #3b82f6;
  transition: all 0.15s ease-in-out;
}

.law-chip button:hover {
  background-color: #93c5fd;
  color: #1e40af;
}

/* Law table styles */
.law-table-row:hover {
  background-color: #f9fafb;
}

.law-table-cell {
  padding: 0.75rem 1rem;
  white-space: nowrap;
  font-size: 0.875rem;
  line-height: 1.25rem;
}

/* Scrollbar styling for law modal */
.law-modal-content::-webkit-scrollbar {
  width: 6px;
}

.law-modal-content::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.law-modal-content::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.law-modal-content::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Input with icon styling */
.input-with-icon {
  position: relative;
}

.input-with-icon input {
  padding-right: 2.5rem;
}

.input-with-icon .input-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
}

/* Loading state for law modal */
.law-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.law-loading-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid #e5e7eb;
  border-top: 3px solid #2563eb;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Transition effects */
.fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-up {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Document Modal Specific Styles */
.document-modal-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  background-color: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.document-modal-chip .remove-btn {
  margin-left: 0.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  color: #4ade80;
  transition: all 0.2s;
  cursor: pointer;
}

.document-modal-chip .remove-btn:hover {
  background-color: #bbf7d0;
  color: #16a34a;
}

.document-modal-table-row {
  transition: background-color 0.2s;
}

.document-modal-table-row:hover {
  background-color: #f9fafb;
}

.document-modal-table-row.selected {
  background-color: #eff6ff;
  border-color: #93c5fd;
}

.document-modal-table-row:hover .document-modal-checkbox {
  opacity: 1;
}

.document-modal-checkbox {
  opacity: 0.6;
  transition: opacity 0.2s;
}

.document-modal-loading {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.document-modal-search {
  transition: all 0.2s ease-in-out;
}

.document-modal-search:focus {
  box-shadow: 0 0 0 2px #10b981;
  border-color: #10b981;
}

.document-modal-empty {
  color: #9ca3af;
}

.document-modal-empty i {
  display: block;
  margin: 0 auto 1rem;
  font-size: 3.75rem;
  opacity: 0.5;
}

/* Document Modal Responsive */
@media (max-width: 640px) {
  .document-modal-table th,
  .document-modal-table td {
    padding: 0.5rem;
    font-size: 0.75rem;
  }

  .document-modal-chip {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }

  .document-modal-search {
    font-size: 0.875rem;
  }
}

/* Add Document Form Styles */
.add-document-form input,
.add-document-form textarea {
  transition: all 0.2s ease-in-out;
}

.add-document-form input:focus,
.add-document-form textarea:focus {
  box-shadow: 0 0 0 2px #10b981, 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  border-color: #10b981;
}

.add-document-form .required::after {
  content: " *";
  color: #ef4444;
}

/* Document Card Styles */
.document-card {
  transition: all 0.3s ease;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
  padding: 1rem;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.document-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border-color: #d1d5db;
}

.document-card.selected {
  border-color: #3b82f6;
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.document-card.selected:hover {
  border-color: #2563eb;
  background: #dbeafe;
}

.document-card .document-checkbox {
  margin-top: 0.25rem;
  width: 1rem;
  height: 1rem;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  cursor: pointer;
}

.document-card .document-checkbox:checked {
  background: #3b82f6;
  border-color: #3b82f6;
}

.document-card .document-checkbox:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.document-card h4 {
  font-size: 0.875rem;
  font-weight: 500;
  color: #111827;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.document-card .space-y-1 > div {
  display: flex;
  align-items: flex-start;
  margin-bottom: 0.25rem;
}

.document-card .space-y-1 > div:last-child {
  margin-bottom: 0;
}

.document-card .space-y-1 i {
  width: 12px;
  height: 12px;
  margin-right: 0.25rem;
  margin-top: 0.125rem;
  color: #6b7280;
  font-size: 0.625rem;
  flex-shrink: 0;
}

.document-card .space-y-1 span {
  font-size: 0.75rem;
  color: #6b7280;
  line-height: 1.3;
}

.document-card .space-y-1 .inline-flex {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 500;
  background: #dbeafe;
  color: #1e40af;
}

/* Responsive adjustments for document cards */
@media (max-width: 768px) {
  .document-card {
    padding: 0.75rem;
  }

  .document-card h4 {
    font-size: 0.8125rem;
  }

  .document-card .space-y-1 span {
    font-size: 0.6875rem;
  }
}

/* Grid layout for document cards */
#documentCardGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  padding: 1rem;
  max-height: 20rem;
  overflow-y: auto;
}

@media (max-width: 768px) {
  #documentCardGrid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 0.75rem;
  }
}

/* Scrollbar styling for document grid */
#documentCardGrid::-webkit-scrollbar {
  width: 6px;
}

#documentCardGrid::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

#documentCardGrid::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

#documentCardGrid::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
