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

:root {
  --background: #ffffff;
  --foreground: #171717;
  --card: #f9fafb;
  --card-border: #e5e7eb;
  --muted: #6b7280;
  --primary: #3b82f6;
}

.dark {
  --background: #0a0a0a;
  --foreground: #ededed;
  --card: #1a1a2e;
  --card-border: #2d2d44;
  --muted: #9ca3af;
  --primary: #60a5fa;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 16px; /* prevent auto-zoom on iOS */
  max-width: 100vw;
  overflow-x: hidden;
}

/* Mobile-first base */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
textarea,
select {
  font-size: 16px; /* Prevent zoom on iOS */
}

/* Touch targets - minimum 44px for accessibility */
@media (max-width: 768px) {
  button,
  a,
  [role="button"] {
    min-height: 44px;
  }
}

@layer utilities {
  .scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .scrollbar-hide::-webkit-scrollbar {
    display: none;
  }

  .text-muted {
    color: var(--muted);
  }
}

/* Smooth scrolling with snap */
.snap-x {
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.snap-center {
  scroll-snap-align: center;
}
.snap-mandatory {
  scroll-snap-type: x mandatory;
}

/* Bottom navigation responsive */
@media (max-width: 640px) {
  .bottom-nav {
    display: flex;
  }
  .desktop-sidebar {
    display: none;
  }
}
@media (min-width: 641px) {
  .bottom-nav {
    display: none;
  }
}

/* Safe area for notched devices */
.safe-area-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Smooth page transitions */
main {
  animation: fadeIn 0.15s ease-out;
}

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

/* Slide-in animations for drawer */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

.animate-slideInRight {
  animation: slideInRight 0.25s ease-out;
}

/* Swipe overlay animations */
@keyframes slideOverlayLeft {
  0% {
    opacity: 0;
    transform: translateX(40px) scale(0.9);
  }
  30% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  70% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-20px) scale(0.95);
  }
}

@keyframes slideOverlayRight {
  0% {
    opacity: 0;
    transform: translateX(-40px) scale(0.9);
  }
  30% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  70% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(20px) scale(0.95);
  }
}

.animate-slideOverlayLeft {
  animation: slideOverlayLeft 0.6s ease-out forwards;
}

.animate-slideOverlayRight {
  animation: slideOverlayRight 0.6s ease-out forwards;
}

/* Content slide animations for group switch */
@keyframes slideContentLeft {
  0% {
    opacity: 0.3;
    transform: translateX(30px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideContentRight {
  0% {
    opacity: 0.3;
    transform: translateX(-30px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-slideContentLeft {
  animation: slideContentLeft 0.3s ease-out;
}

.animate-slideContentRight {
  animation: slideContentRight 0.3s ease-out;
}

/* Fade-in for backdrop */
@keyframes fadeInBackdrop {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.animate-fadeIn {
  animation: fadeInBackdrop 0.2s ease-out;
}

/* Mobile overscroll behavior */
@media (max-width: 640px) {
  html {
    overscroll-behavior-y: contain;
  }
}


/* Mobile modal fix */
.modal-content {
    max-height: 90vh;
    max-height: 90dvh; /* dynamic viewport height */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Ensure modal buttons visible above keyboard */
@media (max-width: 640px) {
    .modal-content {
        max-height: 85vh;
        max-height: 85dvh;
    }
}

/* Selection color */
::selection {
  background: rgba(59, 130, 246, 0.3);
}

/* ============================
   FullCalendar Compact Layout
   ============================ */

/* Single-row toolbar: date + nav + view switcher all in one line */
.fc .fc-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  padding: 0;
  margin-bottom: 8px !important;
}

/* Each toolbar chunk inline */
.fc .fc-toolbar-chunk {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Center chunk (title) takes remaining space, truncates */
.fc .fc-toolbar-chunk:nth-child(2) {
  flex: 1;
  min-width: 0;
  justify-content: center;
}

/* Title: compact, truncates */
.fc .fc-toolbar-title {
  font-size: 16px !important;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Compact buttons */
.fc .fc-button {
  padding: 4px 8px !important;
  font-size: 12px !important;
  line-height: 1.3 !important;
  min-height: 32px;
  border-radius: 6px;
}

/* Button group: pill shape */
.fc .fc-button-group {
  gap: 0;
}
.fc .fc-button-group .fc-button {
  border-radius: 0 !important;
}
.fc .fc-button-group .fc-button:first-child {
  border-radius: 9999px 0 0 9999px !important;
}
.fc .fc-button-group .fc-button:last-child {
  border-radius: 0 9999px 9999px 0 !important;
}

/* Mobile: tighten further but keep single row */
@media (max-width: 640px) {
  .fc .fc-toolbar {
    gap: 4px;
  }

  .fc .fc-toolbar-title {
    font-size: 13px !important;
  }

  .fc .fc-button {
    padding: 3px 6px !important;
    font-size: 11px !important;
    min-height: 32px !important;
  }

  /* Hide text labels on smallest screens - show abbreviated */
  .fc .fc-dayGridMonth-button,
  .fc .fc-timeGridWeek-button,
  .fc .fc-timeGridDay-button {
    font-size: 10px !important;
    padding: 3px 5px !important;
  }

  /* Reduce page padding */
  .fc {
    font-size: 12px;
  }

  /* Time grid slot labels smaller */
  .fc .fc-timegrid-slot-label {
    font-size: 10px;
  }

  /* Day header smaller */
  .fc .fc-col-header-cell-cushion {
    font-size: 11px;
    padding: 3px 2px;
  }
}

/* Small mobile (< 400px) - even tighter */
@media (max-width: 400px) {
  .fc .fc-toolbar-title {
    font-size: 12px !important;
  }

  .fc .fc-button {
    padding: 2px 4px !important;
    font-size: 10px !important;
    min-height: 28px !important;
  }

  .fc .fc-today-button {
    display: none;
  }
}

/* Status dot pulse animation for in_progress tasks */
@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.status-dot-active {
  animation: statusPulse 2s ease-in-out infinite;
}

/* ============================
   Mobile Responsive Compact Headers (#9)
   ============================ */

/* Ensure no horizontal overflow on any page */
@media (max-width: 640px) {
  main {
    overflow-x: hidden;
  }

  /* Page action bars: single row, no wrap */
  .flex.items-center.justify-between {
    flex-wrap: nowrap;
    overflow: hidden;
  }

  /* Touch targets minimum 44px on mobile */
  button,
  a[role='button'],
  [role='button'] {
    min-height: 44px;
    min-width: 44px;
  }

  /* Exception: status pills and small inline elements */
  .scrollbar-hide button,
  .fc button {
    min-width: auto;
    min-height: 28px;
  }

  /* Compact text on mobile */
  h1 {
    font-size: 1.125rem;
    line-height: 1.4;
  }
}
