/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Fallback for skip link visibility (works without Tailwind) */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  left: 0.5rem; /* 8px */
  top: 0.5rem;
  width: auto;
  height: auto;
  overflow: visible;
  background: #fff;
  color: #1d4ed8; /* blue-700 */
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  z-index: 1000;
}

/* Brand tokens (fallbacks; can be overridden per-farm in layout) */
:root {
  --brand-primary: var(--color-primary-600, #2563eb); /* Tailwind blue-600 as default */
  --brand-secondary: #64748b; /* Tailwind slate-500 as default */
}

#sidebar-nav ul {
  list-style: none;
  padding-left: 0;
  margin-left: 0;
}
#sidebar-nav li {
  list-style: none;
}

@media (min-width: 640px) {
  #erp-sidebar {
    transform: translateX(0) !important;
  }
  #main-content {
    margin-left: 16rem !important; /* ml-64 */
    position: relative;
    z-index: 45; /* Above sidebar (z-40) but below navbar (z-50) */
  }
  .sm\:ml-64 {
    margin-left: 16rem !important;
  }
  .sm\:hidden {
    display: none !important;
  }
  .sm\:translate-x-0 {
    transform: translateX(0) !important;
  }
  #navbar-sidebar-toggle {
    display: none !important;
  }
}

/* Leaflet map marker overrides
 * We use CSS-based div icons for markers and do not need the default PNG icons.
 * Disable Leaflet's default background images to avoid external icon requests
 * and define a simple style for our custom map marker.
 */
.leaflet-marker-icon,
.leaflet-marker-shadow {
  background-image: none !important;
}

.custom-map-marker {
  width: 8px;
  height: 8px;
  border-radius: 9999px; /* fully rounded */
  background-color: #ffffff;
}

/* Generic button styles for primary/secondary/text actions */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem; /* rounded-md */
  font-size: 0.875rem; /* text-sm */
  font-weight: 500;
  color: #ffffff;
  background-color: var(--brand-primary);
  border: 1px solid var(--brand-primary);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.btn-primary:hover {
  background-color: #1d4ed8; /* slightly darker */
}

.btn-primary:focus {
  outline: 2px solid rgba(37, 99, 235, 0.4);
  outline-offset: 2px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #111827; /* gray-900 */
  background-color: #ffffff;
  border: 1px solid #d1d5db; /* gray-300 */
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.btn-secondary:hover {
  background-color: #f9fafb; /* gray-50 */
}

.btn-secondary:focus {
  outline: 2px solid rgba(156, 163, 175, 0.4); /* gray-400 */
  outline-offset: 2px;
}

.btn-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--brand-primary);
  background-color: transparent;
  border: none;
  text-decoration: none;
  cursor: pointer;
}

.btn-text:hover {
  text-decoration: underline;
}

.btn-text:focus {
  outline: 2px solid rgba(37, 99, 235, 0.4);
  outline-offset: 2px;
}

/* Toast notification styles */
.toast-container {
  position: fixed;
  top: 5rem; /* Below navbar */
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}

.toast-container > * {
  pointer-events: auto;
}

.toast {
  opacity: 1;
  transform: translateX(0);
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}

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

.toast-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast-exit {
  opacity: 0;
  transform: translateX(100%);
}

@media (max-width: 639px) {
  .toast-container {
    left: 1rem;
    right: 1rem;
  }
  
  .toast-container .toast {
    max-width: 100%;
  }
}

/* Flowbite/vanillajs datepicker: highlight today's date with a subtle vignette
 * without actually selecting it. We attach a custom class from JS so we don't
 * depend on internal option flags.
 */
.datepicker-cell.erp-datepicker-today:not(.selected):not(.range):not(.range-start):not(.range-end) {
  background-color: #f3f4f6 !important; /* tailwind gray-100 */
  color: #111827 !important;            /* gray-900 for readability */
  border-radius: 9999px;                /* fully rounded pill, like hover */
}

.dark .datepicker-cell.erp-datepicker-today:not(.selected):not(.range):not(.range-start):not(.range-end) {
  background-color: rgba(156, 163, 175, 0.35) !important; /* gray-400/35 */
  color: #e5e7eb !important;                                /* gray-200 */
}

/* FullCalendar custom styling to match app design */
.fc {
  --fc-border-color: #e5e7eb; /* gray-200 */
  --fc-page-bg-color: transparent;
  --fc-neutral-bg-color: #f9fafb; /* gray-50 */
  --fc-today-bg-color: #eff6ff; /* blue-50 */
  font-family: inherit;
}

.dark .fc {
  --fc-border-color: #374151; /* gray-700 */
  --fc-neutral-bg-color: #1f2937; /* gray-800 */
  --fc-today-bg-color: rgba(59, 130, 246, 0.1); /* blue-500/10 */
}

/* Header toolbar */
.fc .fc-toolbar {
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem !important;
}

.fc .fc-toolbar-title {
  font-size: 1.25rem !important;
  font-weight: 600 !important;
  color: #111827; /* gray-900 */
}

.dark .fc .fc-toolbar-title {
  color: #f9fafb; /* gray-50 */
}

/* Navigation buttons */
.fc .fc-button {
  background-color: #ffffff !important;
  border: 1px solid #d1d5db !important; /* gray-300 */
  color: #374151 !important; /* gray-700 */
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  padding: 0.5rem 0.75rem !important;
  border-radius: 0.5rem !important;
  box-shadow: none !important;
  text-transform: capitalize !important;
}

.fc .fc-button:hover {
  background-color: #f3f4f6 !important; /* gray-100 */
  border-color: #d1d5db !important;
}

.fc .fc-button:focus {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3) !important;
  outline: none !important;
}

.fc .fc-button-active,
.fc .fc-button:active {
  background-color: #2563eb !important; /* blue-600 */
  border-color: #2563eb !important;
  color: #ffffff !important;
}

.dark .fc .fc-button {
  background-color: #374151 !important; /* gray-700 */
  border-color: #4b5563 !important; /* gray-600 */
  color: #d1d5db !important; /* gray-300 */
}

.dark .fc .fc-button:hover {
  background-color: #4b5563 !important; /* gray-600 */
}

.dark .fc .fc-button-active,
.dark .fc .fc-button:active {
  background-color: #2563eb !important;
  border-color: #2563eb !important;
  color: #ffffff !important;
}

/* Button groups */
.fc .fc-button-group > .fc-button {
  border-radius: 0 !important;
}

.fc .fc-button-group > .fc-button:first-child {
  border-top-left-radius: 0.5rem !important;
  border-bottom-left-radius: 0.5rem !important;
}

.fc .fc-button-group > .fc-button:last-child {
  border-top-right-radius: 0.5rem !important;
  border-bottom-right-radius: 0.5rem !important;
}

/* Day headers */
.fc .fc-col-header-cell {
  background-color: #f9fafb; /* gray-50 */
  padding: 0.75rem 0.5rem !important;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280; /* gray-500 */
}

.dark .fc .fc-col-header-cell {
  background-color: #1f2937; /* gray-800 */
  color: #9ca3af; /* gray-400 */
}

.fc .fc-col-header-cell-cushion {
  padding: 0.5rem !important;
  color: inherit;
  text-decoration: none !important;
}

/* Week numbers */
.fc .fc-daygrid-week-number {
  background-color: #f3f4f6 !important; /* gray-100 */
  color: #6b7280 !important; /* gray-500 */
  font-size: 0.75rem !important;
  font-weight: 500 !important;
  padding: 0.25rem 0.5rem !important;
  border-radius: 0.25rem;
}

.dark .fc .fc-daygrid-week-number {
  background-color: #374151 !important; /* gray-700 */
  color: #9ca3af !important; /* gray-400 */
}

/* Day cells */
.fc .fc-daygrid-day {
  transition: background-color 150ms ease;
}

.fc .fc-daygrid-day:hover {
  background-color: #f9fafb; /* gray-50 */
}

.dark .fc .fc-daygrid-day:hover {
  background-color: #1f2937; /* gray-800 */
}

.fc .fc-daygrid-day-number {
  padding: 0.5rem !important;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151; /* gray-700 */
}

.dark .fc .fc-daygrid-day-number {
  color: #d1d5db; /* gray-300 */
}

/* Today highlight */
.fc .fc-day-today {
  background-color: var(--fc-today-bg-color) !important;
}

.fc .fc-day-today .fc-daygrid-day-number {
  color: #2563eb; /* blue-600 */
  font-weight: 600;
}

.dark .fc .fc-day-today .fc-daygrid-day-number {
  color: #60a5fa; /* blue-400 */
}

/* Events */
.fc .fc-event {
  border-radius: 0.375rem !important;
  border: none !important;
  font-size: 0.75rem !important;
  margin-bottom: 2px !important;
  cursor: pointer;
}

.fc .fc-daygrid-event {
  margin-left: 2px !important;
  margin-right: 2px !important;
}

.fc .fc-event-main {
  padding: 4px 6px !important;
}

/* Scrollbar styling for event overflow */
.fc .fc-scroller::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.fc .fc-scroller::-webkit-scrollbar-track {
  background: transparent;
}

.fc .fc-scroller::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
  border-radius: 3px;
}

.dark .fc .fc-scroller::-webkit-scrollbar-thumb {
  background-color: #4b5563;
}

/* Remove default borders on outer edges */
.fc .fc-scrollgrid {
  border: none !important;
}

.fc .fc-scrollgrid td:last-child {
  border-right: none !important;
}

.fc .fc-scrollgrid tr:last-child td {
  border-bottom: none !important;
}

