/* Skeleton Loader Styles - Unified & Complete */
/* Support both ID and class selectors for flexibility */
#skeleton-loader,
.skeleton-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: #fefefe;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
  overflow: hidden;
}

#skeleton-loader.hidden,
.skeleton-loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Loading Spinner */
.skeleton-spinner {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 10001 !important;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  pointer-events: none;
}

.skeleton-spinner-circle {
  width: 24px !important;
  height: 24px !important;
  border: 2px solid transparent !important;
  border-top: 2px solid #cbd5e1 !important;
  border-radius: 50% !important;
  animation: skeleton-spin 1s ease-in-out infinite !important;
  opacity: 0.8;
  will-change: transform;
  display: block !important;
}

.skeleton-spinner-text {
  color: #64748b;
  font-size: 12px;
  font-weight: 400;
  text-align: center;
  animation: gentle-pulse 2s ease-in-out infinite;
  opacity: 0.7;
}

/* Header Skeleton */
.skeleton-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: #ffffff;
  border-bottom: 1px solid #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(1rem, calc((100vw - 1200px) / 2));
  z-index: 10000;
  opacity: 0.6;
}

.skeleton-logo {
  width: 120px;
  height: 32px;
  background: linear-gradient(90deg, #f8fafc 25%, #f1f5f9 50%, #f8fafc 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 2.5s ease-in-out infinite;
  border-radius: 8px;
  opacity: 0.7;
}

.skeleton-nav {
  display: flex;
  gap: 2rem;
}

.skeleton-nav-item {
  width: 60px;
  height: 20px;
  background: linear-gradient(90deg, #f8fafc 25%, #f1f5f9 50%, #f8fafc 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 2.5s ease-in-out infinite;
  border-radius: 8px;
  opacity: 0.6;
}

/* Content Skeleton */
.skeleton-content {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 64px);
  margin-top: 64px;
  opacity: 0.3;
}

.skeleton-main {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.skeleton-breadcrumb {
  height: 16px;
  width: 200px;
  max-width: 100%;
  background: linear-gradient(90deg, #f8fafc 25%, #f1f5f9 50%, #f8fafc 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 2.5s ease-in-out infinite;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  align-self: flex-start;
  opacity: 0.5;
}

.skeleton-title {
  height: 32px;
  width: 60%;
  max-width: 600px;
  min-width: 200px;
  background: linear-gradient(90deg, #f8fafc 25%, #f1f5f9 50%, #f8fafc 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 2.5s ease-in-out infinite;
  border-radius: 10px;
  margin-bottom: 1rem;
  align-self: center;
  opacity: 0.6;
}

.skeleton-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  justify-content: center;
  flex-wrap: wrap;
}

.skeleton-meta-item {
  height: 20px;
  width: 80px;
  background: linear-gradient(90deg, #f8fafc 25%, #f1f5f9 50%, #f8fafc 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 2.5s ease-in-out infinite;
  border-radius: 10px;
  opacity: 0.5;
}

.skeleton-image {
  width: 100%;
  max-width: 800px;
  height: 400px;
  background: linear-gradient(90deg, #f8fafc 25%, #f1f5f9 50%, #f8fafc 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 2.5s ease-in-out infinite;
  border-radius: 16px;
  margin-bottom: 2rem;
  opacity: 0.4;
}

.skeleton-text-lines {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 800px;
  align-items: center;
}

.skeleton-text-line {
  height: 16px;
  background: linear-gradient(90deg, #f8fafc 25%, #f1f5f9 50%, #f8fafc 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 2.5s ease-in-out infinite;
  border-radius: 10px;
  opacity: 0.4;
}

.skeleton-text-line:nth-child(1) { width: 100%; }
.skeleton-text-line:nth-child(2) { width: 95%; }
.skeleton-text-line:nth-child(3) { width: 88%; }
.skeleton-text-line:nth-child(4) { width: 92%; }
.skeleton-text-line:nth-child(5) { width: 75%; }

/* Sidebar Skeleton */
.skeleton-sidebar {
  width: 100%;
  max-width: 300px;
  margin-top: 2rem;
}

.skeleton-sidebar-block {
  background: #ffffff;
  border: 1px solid #f8fafc;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.skeleton-sidebar-title {
  height: 20px;
  width: 60%;
  background: linear-gradient(90deg, #f8fafc 25%, #f1f5f9 50%, #f8fafc 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 2.5s ease-in-out infinite;
  border-radius: 10px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.skeleton-sidebar-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.skeleton-sidebar-item {
  height: 16px;
  background: linear-gradient(90deg, #f8fafc 25%, #f1f5f9 50%, #f8fafc 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 2.5s ease-in-out infinite;
  border-radius: 10px;
  opacity: 0.4;
}

.skeleton-sidebar-item:nth-child(1) { width: 90%; }
.skeleton-sidebar-item:nth-child(2) { width: 75%; }
.skeleton-sidebar-item:nth-child(3) { width: 85%; }
.skeleton-sidebar-item:nth-child(4) { width: 70%; }

/* Legacy support for old skeleton styles */
.skeleton-hero {
  height: 200px;
  background: linear-gradient(90deg, #f8fafc 25%, #f1f5f9 50%, #f8fafc 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 2.5s ease-in-out infinite;
  border-radius: 20px;
  margin-bottom: 2rem;
  opacity: 0.4;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.skeleton-card {
  height: 250px;
  background: linear-gradient(90deg, #f8fafc 25%, #f1f5f9 50%, #f8fafc 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 2.5s ease-in-out infinite;
  border-radius: 20px;
  animation-delay: calc(var(--delay, 0) * 0.2s);
  opacity: 0.4;
}

.skeleton-text {
  height: 16px;
  background: linear-gradient(90deg, #f8fafc 25%, #f1f5f9 50%, #f8fafc 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 2.5s ease-in-out infinite;
  border-radius: 10px;
  margin-bottom: 0.75rem;
  opacity: 0.4;
}

.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }
.skeleton-text.long { width: 100%; }

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

@keyframes skeleton-spin {
  0% { 
    transform: rotate(0deg);
    opacity: 0.8;
  }
  50% {
    opacity: 1;
  }
  100% { 
    transform: rotate(360deg);
    opacity: 0.8;
  }
}

@keyframes gentle-pulse {
  0%, 100% { 
    opacity: 0.5;
    transform: scale(1);
  }
  50% { 
    opacity: 0.8;
    transform: scale(1.02);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Content Loading States */
body:not(.content-loaded) #main-content {
  opacity: 0;
}

body.content-loaded #main-content {
  opacity: 1;
  transition: opacity 0.3s ease-in;
}

.content-loaded .skeleton-loader,
.content-loaded #skeleton-loader {
  opacity: 0;
  visibility: hidden;
}

/* Responsive Design */
@media (min-width: 1024px) {
  .skeleton-content {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    align-items: start;
    justify-content: center;
  }
  
  .skeleton-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  .skeleton-sidebar {
    margin-top: 0;
  }
}

@media (max-width: 1023px) {
  .skeleton-content {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 3rem;
  }
  
  .skeleton-main {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  .skeleton-sidebar {
    width: 100%;
    max-width: 800px;
    margin-top: 2rem;
  }
}

@media (max-width: 768px) {
  .skeleton-content {
    padding: 1rem;
  }
  
  .skeleton-grid {
    grid-template-columns: 1fr;
  }
  
  .skeleton-hero {
    height: 150px;
  }
  
  .skeleton-card {
    height: 200px;
  }
}

@media (max-width: 640px) {
  .skeleton-nav {
    display: none;
  }
  
  .skeleton-header {
    padding: 0 1rem;
  }
  
  .skeleton-content {
    padding: 1rem;
    margin-top: 64px;
    min-height: calc(100vh - 64px);
  }
  
  .skeleton-image {
    height: 250px;
  }
  
  .skeleton-title {
    width: 90%;
    max-width: 400px;
  }
  
  .skeleton-breadcrumb {
    width: 150px;
  }
  
  .skeleton-main {
    width: 100%;
  }
  
  .skeleton-sidebar {
    width: 100%;
    max-width: none;
  }
}