/* BantayKalusugan Health Surveillance System - Main Stylesheet */
/* Base font standardization */
html,
body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto,
    Helvetica Neue, Arial, Noto Sans, "Apple Color Emoji", "Segoe UI Emoji",
    "Segoe UI Symbol", "Noto Color Emoji";
  height: 100%;
  overflow-x: hidden; /* Prevent body-level horizontal scrollbar */
  overflow-y: hidden; /* Use inner content area scroll, not body */
}

/* ==========================================================================
   Base Styles & Configuration
   ========================================================================== */

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

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

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

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* ==========================================================================
   Transitions & Animations
   ========================================================================== */

/* Smooth transitions */
* {
  transition-property: background-color, border-color, color, fill, stroke,
    opacity, box-shadow, transform;
  transition-duration: 200ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode transitions */
.dark-transition {
  transition: background-color 0.3s ease, border-color 0.3s ease,
    color 0.3s ease;
}

/* Loading animation */
.loading-spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Dark Mode Styles
   ========================================================================== */

/* Dark mode base */
.dark {
  --tw-bg-opacity: 1;
  background-color: rgb(17 24 39 / var(--tw-bg-opacity));
}

/* ==========================================================================
   Notifications
   ========================================================================== */

.notification-enter {
  transform: translateX(100%);
  opacity: 0;
}

.notification-enter-active {
  transform: translateX(0);
  opacity: 1;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.notification-exit {
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* ==========================================================================
   Tab Components (Health Records)
   ========================================================================== */

.tab-button {
  @apply py-2 px-4 text-sm font-medium text-gray-500 border-b-2 border-transparent hover:text-gray-700 hover:border-gray-300 transition-colors duration-200;
}

.tab-button.active {
  @apply text-blue-600 border-blue-500;
}

.tab-pane.hidden {
  @apply hidden;
}

.tab-pane.active {
  @apply block;
}

/* ==========================================================================
   Chart Components
   ========================================================================== */

/* Chart container responsive sizing */
canvas {
  max-height: 256px !important;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  .no-print {
    display: none !important;
  }

  /* Health Records Print Styles */
  body {
    font-family: Arial, sans-serif;
    margin: 20px;
    color: #333;
  }

  .header {
    text-align: center;
    border-bottom: 2px solid #333;
    padding-bottom: 10px;
    margin-bottom: 20px;
  }

  .patient-info {
    background: #f5f5f5;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
  }

  .section {
    margin-bottom: 20px;
  }

  .section-title {
    font-weight: bold;
    color: #2563eb;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
    margin-bottom: 10px;
  }

  .grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .full-width {
    grid-column: 1 / -1;
  }

  .vital-item {
    background: #f8f9fa;
    padding: 8px;
    border-radius: 3px;
    margin: 2px 0;
  }

  @media print {
    .no-print {
      display: none;
    }
    body {
      margin: 0;
    }
  }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Common utility classes for consistent spacing and styling */
.card-shadow {
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.card-shadow-lg {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Focus states for accessibility */
.focus-ring {
  @apply focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2;
}

/* Hover effects */
.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Status indicators */
.status-active {
  @apply bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300;
}

.status-inactive {
  @apply bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300;
}

.status-warning {
  @apply bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300;
}

.status-danger {
  @apply bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300;
}

/* ==========================================================================
   Modal Enhancements
   ========================================================================== */

.modal-overlay {
  backdrop-filter: blur(4px);
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  animation: modal-appear 0.3s ease-out;
}

@keyframes modal-appear {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ==========================================================================
   Responsive Design Helpers
   ========================================================================== */

/* Mobile-first responsive helpers */
@media (max-width: 640px) {
  .mobile-hidden {
    display: none;
  }

  .mobile-full {
    width: 100%;
  }

  .mobile-stack {
    flex-direction: column;
  }
}

/* Tablet styles */
@media (min-width: 768px) and (max-width: 1023px) {
  .tablet-grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Desktop styles */
@media (min-width: 1024px) {
  .desktop-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .desktop-grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ==========================================================================
   Form Enhancements
   ========================================================================== */

/* Enhanced form controls */
.form-input {
  @apply w-full px-4 py-3 border border-gray-300 dark:border-gray-600 rounded-lg 
           focus:ring-2 focus:ring-blue-500 focus:border-blue-500 
           bg-white dark:bg-gray-700 text-gray-900 dark:text-white 
           placeholder-gray-500 dark:placeholder-gray-400 dark-transition;
}

.form-select {
  @apply w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg 
           focus:ring-2 focus:ring-blue-500 focus:border-blue-500 
           bg-white dark:bg-gray-700 text-gray-900 dark:text-white dark-transition;
}

.form-textarea {
  @apply w-full px-4 py-3 border border-gray-300 dark:border-gray-600 rounded-lg 
           focus:ring-2 focus:ring-blue-500 focus:border-blue-500 
           bg-white dark:bg-gray-700 text-gray-900 dark:text-white 
           placeholder-gray-500 dark:placeholder-gray-400 dark-transition resize-vertical;
}

/* Button styles */
.btn-primary {
  @apply bg-blue-600 hover:bg-blue-700 dark:bg-blue-700 dark:hover:bg-blue-600 
           text-white font-medium py-3 px-6 rounded-lg 
           transition-colors duration-200 flex items-center justify-center dark-transition;
}

.btn-secondary {
  @apply bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600 
           text-gray-900 dark:text-white font-medium py-3 px-6 rounded-lg 
           transition-colors duration-200 flex items-center justify-center dark-transition;
}

.btn-danger {
  @apply bg-red-600 hover:bg-red-700 dark:bg-red-700 dark:hover:bg-red-600 
           text-white font-medium py-3 px-6 rounded-lg 
           transition-colors duration-200 flex items-center justify-center dark-transition;
}

/* ==========================================================================
   Table Enhancements
   ========================================================================== */

.table-responsive {
  @apply overflow-x-auto shadow ring-1 ring-black ring-opacity-5 rounded-lg;
}

.table-header {
  @apply bg-gray-50 dark:bg-gray-800;
}

.table-cell {
  @apply px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white;
}

.table-row-hover {
  @apply hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors duration-200;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

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

.dark .skeleton {
  background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
  background-size: 200% 100%;
}

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

/* ==========================================================================
   Accessibility Improvements
   ========================================================================== */

/* Screen reader only */
.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 {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .dark-transition {
    transition: none;
  }

  * {
    transition: none !important;
  }
}

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