/* ExSenCo Qualiopi POC - Custom Styles */

/* Hide Alpine.js elements until initialized */
[x-cloak] { display: none !important; }

/* Smooth transitions */
.fade-in { animation: fadeIn 0.3s ease-in; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.slide-in-left { animation: slideInLeft 0.3s ease-out; }
@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.slide-in-right { animation: slideInRight 0.3s ease-out; }
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* Sidebar styles */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  border-radius: 0.5rem;
  transition-property: color, background-color, border-color;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}
.sidebar-link:hover {
  background-color: #EEF0F8;
  color: #1A2B6D;
}
.sidebar-link.active {
  background-color: #1A2B6D;
  color: #fff;
}

/* Card hover effect */
.card-hover {
  transition-property: all;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 200ms;
}
.card-hover:hover {
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  transform: translateY(-0.125rem);
}

/* Status badge base */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 500;
}

/* Form field focus ring */
.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  outline: none;
  transition-property: color, background-color, border-color, box-shadow;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}
.form-input:focus {
  border-color: #3B5BA8;
  box-shadow: 0 0 0 2px rgba(59, 91, 168, 0.3);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.25rem;
}

/* Button styles */
.btn-primary {
  padding: 0.625rem 1rem;
  background-color: #1A2B6D;
  color: #fff;
  font-weight: 500;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition-property: color, background-color, border-color;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}
.btn-primary:hover { background-color: #2D4A8E; }
.btn-primary:focus { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #3B5BA8; }

.btn-secondary {
  padding: 0.625rem 1rem;
  background-color: #fff;
  color: #374151;
  font-weight: 500;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  cursor: pointer;
  transition-property: color, background-color, border-color;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}
.btn-secondary:hover { background-color: #f9fafb; }
.btn-secondary:focus { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #6b7280; }

.btn-danger {
  padding: 0.625rem 1rem;
  background-color: #dc2626;
  color: #fff;
  font-weight: 500;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition-property: color, background-color, border-color;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}
.btn-danger:hover { background-color: #b91c1c; }
.btn-danger:focus { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #ef4444; }

.btn-success {
  padding: 0.625rem 1rem;
  background-color: #16a34a;
  color: #fff;
  font-weight: 500;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition-property: color, background-color, border-color;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}
.btn-success:hover { background-color: #15803d; }
.btn-success:focus { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #22c55e; }

/* Progress bar for compliance */
.progress-bar {
  height: 0.5rem;
  border-radius: 9999px;
  background-color: #e5e7eb;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition-property: all;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 500ms;
}

/* Toast animations */
.toast-enter { animation: toastIn 0.3s ease-out; }
.toast-exit { animation: toastOut 0.3s ease-in forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Print styles */
@media print {
  .no-print { display: none !important; }
  .sidebar, .header { display: none !important; }
  main { margin: 0 !important; padding: 0 !important; }
}

/* Signature pad */
.signature-canvas {
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  background: #fefefe;
  touch-action: none;
}
.signature-canvas.active {
  border-color: #3B5BA8;
  border-style: solid;
}

/* Qualiopi indicator row */
.indicator-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition-property: color, background-color, border-color;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}
.indicator-row:hover {
  background-color: #f9fafb;
}
.indicator-critical {
  border-left: 4px solid #ef4444;
}

/* Accordion */
.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}
.accordion-content.open {
  max-height: 2000px;
}

/* Responsive table */
@media (max-width: 768px) {
  .responsive-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Tab styles */
.tab-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  transition-property: color, background-color, border-color;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}
.tab-btn.active {
  border-bottom-color: #1A2B6D;
  color: #1A2B6D;
}
.tab-btn:not(.active) {
  border-bottom-color: transparent;
  color: #6b7280;
}
.tab-btn:not(.active):hover {
  color: #374151;
  border-bottom-color: #d1d5db;
}

/* Glass effect */
.glass {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Gradient text */
.gradient-text {
  background: linear-gradient(135deg, #1A2B6D 0%, #3B5BA8 50%, #2D4A8E 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Subtle card shine on hover */
.card-shine {
  position: relative;
  overflow: hidden;
}
.card-shine::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  transition: left 0.5s ease;
}
.card-shine:hover::before {
  left: 100%;
}

/* Smooth scale on hover */
.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.1), 0 4px 10px -6px rgba(0, 0, 0, 0.1);
}

/* Pulse dot animation for alerts */
.pulse-dot {
  position: relative;
}
.pulse-dot::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulse-ring 2s ease infinite;
}
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Better focus styles */
.focus-ring:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 91, 168, 0.25);
}

/* Skeleton loading animation */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
}
@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Stagger animation for cards */
.stagger-in > * {
  animation: staggerFade 0.4s ease forwards;
  opacity: 0;
}
.stagger-in > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-in > *:nth-child(6) { animation-delay: 0.3s; }
@keyframes staggerFade {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE NATIVE EXPERIENCE
   ═══════════════════════════════════════════════════════════════ */

/* Safe areas for notched phones (iPhone X+) */
@supports (padding: env(safe-area-inset-bottom)) {
  .safe-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .safe-top {
    padding-top: env(safe-area-inset-top);
  }
}

/* Smooth native scrolling everywhere */
html {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
}

/* Prevent rubber-band overscroll on the body */
body {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* Touch feedback — active state press effect */
.touch-feedback {
  transition: transform 0.1s ease, opacity 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}
.touch-feedback:active {
  transform: scale(0.97);
  opacity: 0.9;
}

/* Smaller press for cards */
.touch-press {
  transition: transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}
.touch-press:active {
  transform: scale(0.98);
}

/* Minimum touch target (44x44 per Apple/Google guidelines) */
.touch-target {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Mobile bottom nav bar */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 0 2px;
  min-height: 50px;
  flex: 1;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease, transform 0.1s ease;
  cursor: pointer;
  position: relative;
}

.mobile-bottom-nav .nav-item:active {
  transform: scale(0.9);
}

.mobile-bottom-nav .nav-item.active {
  color: #1A2B6D;
}

.mobile-bottom-nav .nav-item:not(.active) {
  color: #9CA3AF;
}

.mobile-bottom-nav .nav-item .nav-icon {
  width: 22px;
  height: 22px;
  margin-bottom: 2px;
}

.mobile-bottom-nav .nav-label {
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.01em;
}

.mobile-bottom-nav .nav-item.active .nav-dot {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #1A2B6D;
}

/* Mobile-specific form improvements */
@media (max-width: 640px) {
  /* Prevent browser zoom on input focus (needs 16px minimum) */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="number"],
  input[type="url"],
  input[type="date"],
  input[type="time"],
  textarea,
  select {
    font-size: 16px !important;
  }

  /* Stack action buttons vertically */
  .mobile-stack {
    flex-direction: column !important;
    gap: 0.75rem !important;
  }
  .mobile-stack > * {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Full-width buttons on mobile */
  .mobile-full {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Smaller section headings */
  .mobile-heading {
    font-size: 1.25rem !important;
  }

  /* Tighter padding on cards */
  .mobile-compact {
    padding: 1rem !important;
  }

  /* Better modal for mobile — full screen */
  .mobile-modal {
    position: fixed !important;
    inset: 0 !important;
    border-radius: 0 !important;
    max-height: 100vh !important;
    max-width: 100vw !important;
    margin: 0 !important;
  }
}

/* Pull-to-refresh visual indicator (CSS only) */
.pull-indicator {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: height 0.3s ease;
}

/* Swipe hint animation for cards */
@keyframes swipeHint {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-5px); }
}

/* Page transition for mobile */
.page-enter {
  animation: pageSlideIn 0.25s ease-out;
}
@keyframes pageSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile notification dropdown */
@media (max-width: 640px) {
  .notification-dropdown {
    position: fixed !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    top: 3.5rem !important;
    width: auto !important;
    max-height: 70vh !important;
    border-radius: 1rem !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
  }
}

/* Momentum scroll containers */
.scroll-momentum {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

/* Hide scrollbar on mobile but keep scrolling */
.scroll-hide::-webkit-scrollbar {
  display: none;
}
.scroll-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Active/pressed state for list items */
.list-item-press {
  transition: background-color 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}
.list-item-press:active {
  background-color: rgba(0, 0, 0, 0.04);
}

/* Floating action button for mobile */
.fab {
  position: fixed;
  bottom: 80px; /* above bottom nav */
  right: 1rem;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(26, 43, 109, 0.35);
  z-index: 40;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.fab:active {
  transform: scale(0.92);
  box-shadow: 0 2px 8px rgba(26, 43, 109, 0.25);
}

@supports (padding: env(safe-area-inset-bottom)) {
  .fab {
    bottom: calc(80px + env(safe-area-inset-bottom));
  }
}
