/* PanelQA Quick Wins Phase 5 - UI/UX, Mobile, Animations, Accessibility */

/* ===== BACK-TO-TOP BUTTON ===== */
#backToTopQW {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #0891b2, #06b6d4);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.3);
  z-index: 999;
}

#backToTopQW.show {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

#backToTopQW:hover {
  box-shadow: 0 6px 20px rgba(8, 145, 178, 0.4);
  transform: translateY(-3px);
}

@media (max-width: 768px) {
  #backToTopQW {
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
}

/* ===== BREADCRUMB NAVIGATION ===== */
.breadcrumb-qw {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 14px;
  color: #64748b;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.breadcrumb-qw a {
  color: #0891b2;
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb-qw a:hover {
  color: #06b6d4;
  text-decoration: underline;
}

.breadcrumb-qw span {
  color: #cbd5e1;
  margin: 0 0.25rem;
}

.breadcrumb-qw .current {
  color: #1e293b;
  font-weight: 500;
}

/* ===== LOADING SKELETON ===== */
.skeleton-qw {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 6px;
}

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

.skeleton-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.skeleton-cell {
  height: 20px;
  border-radius: 4px;
}

.skeleton-cell.name {
  grid-column: span 2;
}

/* ===== MICRO-ANIMATIONS ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-fade-in-up {
  animation: fadeInUp 0.4s ease-out;
}

.animate-slide-in {
  animation: slideIn 0.3s ease-out;
}

.animate-scale-in {
  animation: scaleIn 0.3s ease-out;
}

/* Filter/Sort animation */
.table-rows-animating {
  opacity: 0;
  animation: fadeInUp 0.3s ease-out forwards;
}

.table-rows-animating:nth-child(1) { animation-delay: 0ms; }
.table-rows-animating:nth-child(2) { animation-delay: 50ms; }
.table-rows-animating:nth-child(3) { animation-delay: 100ms; }
.table-rows-animating:nth-child(4) { animation-delay: 150ms; }
.table-rows-animating:nth-child(5) { animation-delay: 200ms; }

/* ===== EMPTY STATE ===== */
.empty-state-qw {
  text-align: center;
  padding: 3rem 2rem;
  color: #64748b;
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.5rem;
}

.empty-state-description {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 1.5rem;
}

/* ===== TOOLTIPS ===== */
.tooltip-qw {
  position: relative;
}

.tooltip-qw[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tooltip-qw[title]:hover::before {
  content: '';
  position: absolute;
  bottom: 118%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e293b;
  z-index: 1000;
}

/* ===== ANIMATED PROGRESS RINGS ===== */
.progress-ring-qw {
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.progress-ring-circle-qw {
  transition: stroke-dashoffset 0.35s;
  stroke-dasharray: 339.292;
}

/* ===== COPY ANIMATION (RIPPLE) ===== */
@keyframes ripple-qw {
  0% {
    box-shadow: 0 0 0 0 rgba(8, 145, 178, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(8, 145, 178, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(8, 145, 178, 0);
  }
}

.btn-copy-ripple:active {
  animation: ripple-qw 0.6s ease-out;
}

/* ===== HOVER CARD PREVIEWS ===== */
.card-preview-qw {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: white;
  border-radius: 8px;
  padding: 1rem;
  width: 250px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease-out;
}

.card-preview-qw.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(-15px);
}

/* ===== MODAL ANIMATIONS ===== */
@keyframes modalSlideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes modalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-overlay-qw {
  animation: modalFade 0.2s ease-out;
}

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

@media (max-width: 768px) {
  .modal-content-qw {
    animation: modalSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
}

/* ===== PAGE TRANSITIONS ===== */
@keyframes pageEnter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

body.page-transition {
  animation: pageEnter 0.3s ease-out;
}

/* ===== ANIMATED COUNTERS ===== */
.counter-qw {
  font-weight: 700;
  font-size: 32px;
  color: #0891b2;
}

/* ===== FORM ERROR ANIMATION ===== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.form-error-shake {
  animation: shake 0.4s ease-in-out;
}

input.error-qw,
textarea.error-qw {
  border-color: #ef4444 !important;
  background-color: #fef2f2;
}

.error-message-qw {
  color: #ef4444;
  font-size: 12px;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ===== CHEVRON ICONS ===== */
.chevron-qw::after {
  content: '›';
  display: inline-block;
  margin-left: 0.5rem;
  font-weight: bold;
}

.chevron-down-qw::after {
  content: '∨';
}

.chevron-up-qw::after {
  content: '∧';
}

/* ===== SPACING SYSTEM ===== */
.spacing-xs { padding: 0.5rem; margin-bottom: 0.5rem; }
.spacing-sm { padding: 0.75rem; margin-bottom: 0.75rem; }
.spacing-md { padding: 1rem; margin-bottom: 1rem; }
.spacing-lg { padding: 1.5rem; margin-bottom: 1.5rem; }
.spacing-xl { padding: 2rem; margin-bottom: 2rem; }

.gap-xs { gap: 0.5rem; }
.gap-sm { gap: 0.75rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.gap-xl { gap: 2rem; }

/* ===== SECTION SEPARATORS ===== */
.section-divider-qw {
  height: 1px;
  background: linear-gradient(90deg, transparent, #e5e7eb, transparent);
  margin: 2rem 0;
}

/* ===== TOUCH TARGET SIZES (40px minimum) ===== */
button, a.btn, input[type="button"], input[type="submit"] {
  min-height: 40px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===== MOBILE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
  /* Larger touch targets on mobile */
  button, a.btn {
    min-height: 48px;
    font-size: 16px;
  }

  /* Bottom sheet modals */
  .modal-content-qw {
    border-radius: 16px 16px 0 0;
    margin-top: auto;
  }

  /* Mobile-specific spacing */
  .spacing-mobile-lg {
    padding: 1.5rem 1rem !important;
  }
}

/* ===== ACCESSIBILITY - FOCUS STATES ===== */
button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.2);
  border-color: #0891b2;
}

/* High contrast mode */
@media (prefers-contrast: more) {
  :root {
    --text-primary: #000;
    --border-light: #333;
  }
}

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

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
  .tooltip-qw[title]:hover::after {
    background: #f9fafb;
    color: #1e293b;
  }

  .tooltip-qw[title]:hover::before {
    border-top-color: #f9fafb;
  }

  .card-preview-qw {
    background: #1e293b;
    color: #f9fafb;
  }

  .empty-state-icon {
    opacity: 0.3;
  }

  .section-divider-qw {
    background: linear-gradient(90deg, transparent, #334155, transparent);
  }
}

/* ===== SKIP NAVIGATION LINK ===== */
.skip-to-content-qw {
  position: absolute;
  top: -40px;
  left: 0;
  background: #0891b2;
  color: white;
  padding: 0.5rem 1rem;
  text-decoration: none;
  border-radius: 0 0 4px 0;
  z-index: 100;
}

.skip-to-content-qw:focus {
  top: 0;
}

/* ===== DATA QUALITY INDICATOR ===== */
.data-quality-qw {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: #f0fdf4;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  color: #166534;
}

.data-quality-qw.incomplete {
  background: #fef3c7;
  color: #92400e;
}

.data-quality-qw.partial {
  background: #fee2e2;
  color: #991b1b;
}

/* Progress indicator */
.progress-bar-qw {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-qw::after {
  content: '';
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: linear-gradient(90deg, #10b981, #0891b2);
  transition: width 0.3s ease;
}
