/* ============================================
   Fennec360-v2 Loading Skeletons
   Modern placeholder loading states
   ============================================ */

/* ----------------------------------------
   1. BASE SKELETON STYLES
   ---------------------------------------- */

/* Shimmer animation */
@keyframes skeleton-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Pulse animation (alternative) */
@keyframes skeleton-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Base skeleton element */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--neutral-200) 0%,
    var(--neutral-100) 50%,
    var(--neutral-200) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-input);
  pointer-events: none;
  user-select: none;
}

/* Dark mode skeleton */
[data-theme="dark"] .skeleton {
  background: linear-gradient(
    90deg,
    var(--neutral-800) 0%,
    var(--neutral-700) 50%,
    var(--neutral-800) 100%
  );
  background-size: 200% 100%;
}

/* Pulse variant */
.skeleton-pulse {
  background: var(--neutral-200);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

[data-theme="dark"] .skeleton-pulse {
  background: var(--neutral-800);
}

/* ----------------------------------------
   2. SKELETON SHAPES
   ---------------------------------------- */

/* Text line */
.skeleton-text {
  height: 14px;
  width: 100%;
  margin-bottom: var(--space-2);
}

.skeleton-text:last-child {
  margin-bottom: 0;
}

.skeleton-text-sm {
  height: 12px;
}

.skeleton-text-xs {
  height: 10px;
}

.skeleton-text-lg {
  height: 18px;
}

/* Heading */
.skeleton-heading {
  height: 24px;
  width: 60%;
  margin-bottom: var(--space-3);
}

/* Circle (for avatars/icons) */
.skeleton-circle {
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-circle-sm {
  width: 32px;
  height: 32px;
}

.skeleton-circle-md {
  width: 40px;
  height: 40px;
}

.skeleton-circle-lg {
  width: 48px;
  height: 48px;
}

/* Square (for icons) */
.skeleton-square {
  border-radius: var(--radius-input);
  flex-shrink: 0;
}

.skeleton-square-sm {
  width: 24px;
  height: 24px;
}

.skeleton-square-md {
  width: 32px;
  height: 32px;
}

.skeleton-square-lg {
  width: 40px;
  height: 40px;
}

/* Rectangle */
.skeleton-rect {
  width: 100%;
}

.skeleton-rect-sm {
  height: 80px;
}

.skeleton-rect-md {
  height: 120px;
}

.skeleton-rect-lg {
  height: 200px;
}

/* ----------------------------------------
   3. STAT CARD SKELETON
   ---------------------------------------- */

.skeleton-stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
}

.skeleton-stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

.skeleton-stat-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.skeleton-stat-card-value {
  height: 28px;
  width: 50px;
}

.skeleton-stat-card-label {
  height: 14px;
  width: 80px;
}

/* Grid for stat cards */
.skeleton-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

/* ----------------------------------------
   4. TABLE ROW SKELETON
   ---------------------------------------- */

.skeleton-table {
  width: 100%;
  border-collapse: collapse;
}

.skeleton-table-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-default);
}

.skeleton-table-row:last-child {
  border-bottom: none;
}

.skeleton-table-cell {
  height: 16px;
}

.skeleton-table-cell-sm {
  width: 60px;
}

.skeleton-table-cell-md {
  width: 120px;
}

.skeleton-table-cell-lg {
  flex: 1;
  max-width: 200px;
}

.skeleton-table-cell-xl {
  flex: 2;
  max-width: 300px;
}

/* Staggered animation for rows */
.skeleton-table-row:nth-child(1) .skeleton { animation-delay: 0ms; }
.skeleton-table-row:nth-child(2) .skeleton { animation-delay: 100ms; }
.skeleton-table-row:nth-child(3) .skeleton { animation-delay: 200ms; }
.skeleton-table-row:nth-child(4) .skeleton { animation-delay: 300ms; }
.skeleton-table-row:nth-child(5) .skeleton { animation-delay: 400ms; }

/* DataTables skeleton rows */
.dt-skeleton-loading tbody {
  position: relative;
}

.dt-skeleton-row td {
  padding: 12px 10px !important;
  border-bottom: 1px solid var(--border-default);
}

.dt-skeleton-row .skeleton {
  height: 14px;
}

/* Staggered animation for DataTables skeleton rows */
.dt-skeleton-row:nth-child(1) .skeleton { animation-delay: 0ms; }
.dt-skeleton-row:nth-child(2) .skeleton { animation-delay: 100ms; }
.dt-skeleton-row:nth-child(3) .skeleton { animation-delay: 200ms; }
.dt-skeleton-row:nth-child(4) .skeleton { animation-delay: 300ms; }
.dt-skeleton-row:nth-child(5) .skeleton { animation-delay: 400ms; }

/* Loading state for subsequent AJAX calls */
.dt-loading {
  opacity: 0.6;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* ----------------------------------------
   5. CHART SKELETON
   ---------------------------------------- */

.skeleton-chart {
  position: relative;
  width: 100%;
  height: 300px;
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.skeleton-chart-bars {
  position: absolute;
  bottom: 40px;
  left: 60px;
  right: 20px;
  top: 20px;
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
}

.skeleton-chart-bar {
  flex: 1;
  border-radius: var(--radius-input) var(--radius-input) 0 0;
}

/* Varying heights for realistic appearance */
.skeleton-chart-bar:nth-child(1) { height: 60%; }
.skeleton-chart-bar:nth-child(2) { height: 80%; }
.skeleton-chart-bar:nth-child(3) { height: 45%; }
.skeleton-chart-bar:nth-child(4) { height: 70%; }
.skeleton-chart-bar:nth-child(5) { height: 55%; }
.skeleton-chart-bar:nth-child(6) { height: 90%; }
.skeleton-chart-bar:nth-child(7) { height: 40%; }
.skeleton-chart-bar:nth-child(8) { height: 65%; }

/* Chart axis lines */
.skeleton-chart-axis-y {
  position: absolute;
  left: 50px;
  top: 20px;
  bottom: 40px;
  width: 1px;
  background: var(--border-default);
}

.skeleton-chart-axis-x {
  position: absolute;
  left: 50px;
  right: 20px;
  bottom: 40px;
  height: 1px;
  background: var(--border-default);
}

/* ----------------------------------------
   6. CARD SKELETON
   ---------------------------------------- */

.skeleton-card {
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  padding: var(--space-4);
}

.skeleton-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.skeleton-card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.skeleton-card-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-default);
}

/* ----------------------------------------
   7. LIST SKELETON
   ---------------------------------------- */

.skeleton-list {
  display: flex;
  flex-direction: column;
}

.skeleton-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-default);
}

.skeleton-list-item:last-child {
  border-bottom: none;
}

.skeleton-list-item-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* ----------------------------------------
   8. NOTIFICATION SKELETON
   ---------------------------------------- */

.skeleton-notification {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
}

.skeleton-notification-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-notification-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.skeleton-notification-title {
  height: 14px;
  width: 70%;
}

.skeleton-notification-text {
  height: 12px;
  width: 100%;
}

.skeleton-notification-time {
  height: 10px;
  width: 60px;
}

/* ----------------------------------------
   9. ARTICLE/KB SKELETON
   ---------------------------------------- */

.skeleton-article {
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  padding: var(--space-4);
}

.skeleton-article-title {
  height: 20px;
  width: 80%;
  margin-bottom: var(--space-3);
}

.skeleton-article-meta {
  height: 12px;
  width: 120px;
  margin-bottom: var(--space-3);
}

.skeleton-article-excerpt {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.skeleton-article-link {
  height: 14px;
  width: 80px;
}

/* ----------------------------------------
   10. BUTTON SKELETON
   ---------------------------------------- */

.skeleton-button {
  height: 36px;
  width: 100px;
  border-radius: var(--radius-pill);
}

.skeleton-button-sm {
  height: 28px;
  width: 80px;
}

.skeleton-button-lg {
  height: 44px;
  width: 120px;
}

/* ----------------------------------------
   11. AVATAR GROUP SKELETON
   ---------------------------------------- */

.skeleton-avatar-group {
  display: flex;
  align-items: center;
}

.skeleton-avatar-group .skeleton-circle {
  margin-left: -8px;
  border: 2px solid var(--surface-raised);
}

.skeleton-avatar-group .skeleton-circle:first-child {
  margin-left: 0;
}

/* ----------------------------------------
   12. FORM SKELETON
   ---------------------------------------- */

.skeleton-form-group {
  margin-bottom: var(--space-4);
}

.skeleton-form-label {
  height: 14px;
  width: 100px;
  margin-bottom: var(--space-2);
}

.skeleton-form-input {
  height: 40px;
  width: 100%;
  border-radius: var(--radius-input);
}

.skeleton-form-textarea {
  height: 100px;
  width: 100%;
  border-radius: var(--radius-input);
}

/* ----------------------------------------
   13. PROFILE SKELETON
   ---------------------------------------- */

.skeleton-profile {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.skeleton-profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
}

.skeleton-profile-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.skeleton-profile-name {
  height: 20px;
  width: 150px;
}

.skeleton-profile-role {
  height: 14px;
  width: 100px;
}

/* ----------------------------------------
   14. UTILITY CLASSES
   ---------------------------------------- */

/* Width variants */
.skeleton-w-25 { width: 25%; }
.skeleton-w-50 { width: 50%; }
.skeleton-w-75 { width: 75%; }
.skeleton-w-100 { width: 100%; }

/* Inline skeleton container */
.skeleton-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* Hide actual content when loading */
.is-loading > *:not(.skeleton-container) {
  visibility: hidden;
}

.is-loading .skeleton-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Fade transition */
.skeleton-fade-enter {
  opacity: 0;
}

.skeleton-fade-enter-active {
  opacity: 1;
  transition: opacity 0.3s ease;
}

.skeleton-fade-exit {
  opacity: 1;
}

.skeleton-fade-exit-active {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* ----------------------------------------
   15. CALENDAR SKELETON
   ---------------------------------------- */

.calendar-skeleton {
  padding: var(--space-4);
}

.calendar-skeleton-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-default);
}

.calendar-skeleton-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  text-align: center;
}

.calendar-skeleton-weekdays .skeleton {
  margin: 0 auto;
  width: 30px;
}

.calendar-skeleton-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border-default);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-input);
  overflow: hidden;
}

.calendar-skeleton-day {
  background: var(--surface-raised);
  padding: var(--space-2);
  min-height: 80px;
}

.calendar-skeleton-day .skeleton {
  margin-bottom: 0;
}

/* Staggered animation for calendar days */
.calendar-skeleton-day:nth-child(7n+1) .skeleton { animation-delay: 0ms; }
.calendar-skeleton-day:nth-child(7n+2) .skeleton { animation-delay: 50ms; }
.calendar-skeleton-day:nth-child(7n+3) .skeleton { animation-delay: 100ms; }
.calendar-skeleton-day:nth-child(7n+4) .skeleton { animation-delay: 150ms; }
.calendar-skeleton-day:nth-child(7n+5) .skeleton { animation-delay: 200ms; }
.calendar-skeleton-day:nth-child(7n+6) .skeleton { animation-delay: 250ms; }
.calendar-skeleton-day:nth-child(7n) .skeleton { animation-delay: 300ms; }

/* Hide skeleton when calendar is rendered */
.calendar-skeleton.hidden {
  display: none;
}

/* ----------------------------------------
   16. AGENDA SIDEBAR SKELETON
   ---------------------------------------- */

.agenda-skeleton {
  padding: var(--space-4);
}

.agenda-skeleton-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
}

.agenda-skeleton-time {
  min-width: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.agenda-skeleton-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Staggered animation for agenda items */
.agenda-skeleton-item:nth-child(1) .skeleton { animation-delay: 0ms; }
.agenda-skeleton-item:nth-child(2) .skeleton { animation-delay: 75ms; }
.agenda-skeleton-item:nth-child(3) .skeleton { animation-delay: 150ms; }
.agenda-skeleton-item:nth-child(4) .skeleton { animation-delay: 225ms; }
.agenda-skeleton-item:nth-child(5) .skeleton { animation-delay: 300ms; }

/* ----------------------------------------
   17. REDUCED MOTION
   ---------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .skeleton-pulse {
    animation: none;
    background: var(--neutral-200);
  }

  [data-theme="dark"] .skeleton,
  [data-theme="dark"] .skeleton-pulse {
    background: var(--neutral-800);
  }
}

/* ----------------------------------------
   18. PRINT
   ---------------------------------------- */

@media print {
  .skeleton,
  .skeleton-container,
  [class*="skeleton-"] {
    display: none !important;
  }
}
