/* =====================================================================
   Custom Styles & Scrollbar for Weekly Planner
   Mobile UX & Responsive Enhancements
   ===================================================================== */

:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

/* Safe area support for iOS / Android screens */
body {
  padding-bottom: max(5rem, calc(var(--sab) + 4.5rem));
  padding-left: var(--sal);
  padding-right: var(--sar);
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 768px) {
  body {
    padding-bottom: max(1rem, var(--sab));
  }
}

header {
  padding-top: max(0.625rem, var(--sat));
}

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

::-webkit-scrollbar-track {
  background: rgba(100, 116, 139, 0.08);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.3);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.5);
}

/* Active Block Calm Highlight (Modern, non-distracting UX without jarring pulse/blink) */
.active-block-current {
  position: relative;
  outline: 2px solid #6366f1 !important;
  outline-offset: 1px;
  box-shadow: 0 4px 16px -2px rgba(99, 102, 241, 0.3), 0 0 0 1px rgba(99, 102, 241, 0.2) !important;
}

.dark .active-block-current {
  outline: 2px solid #818cf8 !important;
  box-shadow: 0 4px 20px -2px rgba(99, 102, 241, 0.45), 0 0 0 1px rgba(129, 140, 248, 0.3) !important;
}

.active-now-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.025em;
  background-color: #4f46e5;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  line-height: 1.2;
}

.dark .active-now-badge {
  background-color: #6366f1;
  color: #ffffff;
}

.weekly-scroll-container {
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

/* Sticky Time Column support for LTR & RTL */
html[dir="ltr"] .sticky-time-col {
  position: sticky;
  left: 0;
}

html[dir="rtl"] .sticky-time-col {
  position: sticky;
  right: 0;
}

.break-block-compact {
  opacity: 0.85;
  font-size: 0.75rem;
}

.break-block-compact:hover {
  opacity: 1;
}

/* Supabase Connection Badge Animation */
.status-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* Touch targets & Mobile Ergonomics */
@media (max-width: 640px) {
  /* Prevent automatic iOS zoom when focusing input fields */
  input[type="text"],
  input[type="number"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Improve tap target feedback on mobile touch screens */
  button,
  a,
  [role="button"] {
    touch-action: manipulation;
  }

  /* Bottom sheet modal styling for mobile screens */
  #modalBox,
  #tasksHubBox,
  #pasteBackupBox,
  #settingsModalBox,
  #insightsModalBox {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding-bottom: max(1.5rem, calc(var(--sab) + 1rem));
  }
}

/* Floating Pomodoro position on mobile to float cleanly above bottom nav */
@media (max-width: 767px) {
  #pomodoroFloatingBar {
    bottom: calc(4.75rem + var(--sab)) !important;
    left: 1rem !important;
    right: 1rem !important;
  }
}

/* Smooth horizontal scroll for day tabs & tag chips */
#dayTabsContainer,
#tasksHubFilterTabs {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}

#dayTabsContainer::-webkit-scrollbar,
#tasksHubFilterTabs::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Edge */
}

/* Drag and Drop Task Reordering Styles */
.task-drag-handle {
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.task-drag-handle:active {
  cursor: grabbing;
}

.task-drag-item {
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.task-drag-item.is-dragging {
  opacity: 0.45;
  transform: scale(0.98);
  box-shadow: 0 8px 20px -4px rgba(99, 102, 241, 0.25);
}

.task-drag-item.drag-over-top {
  border-top: 2px solid #6366f1 !important;
}

.task-drag-item.drag-over-bottom {
  border-bottom: 2px solid #6366f1 !important;
}
