/**
 * Tableberg Patterns Library - Frontend Styles
 */

/* Tableberg Brand Color */
:root {
  --tbpl-brand: #671feb;
  --tbpl-brand-dark: #4e16b3;
}

/* Accessibility Helpers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Enhanced Focus States */
.tbpl-pattern-card-link:focus {
  outline: 2px solid var(--tbpl-brand);
  outline-offset: 2px;
}

.tbpl-pattern-card-link:focus .tbpl-pattern-card {
  transform: translateY(-4px);
  box-shadow: 0 8px 32px rgba(103, 31, 235, 0.15);
  border-color: var(--tbpl-brand);
}

button:focus,
input:focus,
select:focus {
  outline: 2px solid var(--tbpl-brand);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .tbpl-pattern-card {
    border-width: 2px;
  }

  .tbpl-pattern-card:hover {
    border-width: 2px;
  }
}

/* Loading States */
.tbpl-loading {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

.tbpl-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  margin-left: -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid var(--tbpl-brand);
  border-radius: 50%;
  animation: tbpl-spin 1s linear infinite;
  z-index: 10;
}

@keyframes tbpl-spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Skeleton Loading for Cards */
.tbpl-pattern-card-skeleton {
  background: #f8f9fa;
  border: 1px solid #e1e5e9;
  border-radius: 16px;
  overflow: hidden;
  animation: tbpl-pulse 1.5s ease-in-out infinite;
}

.tbpl-pattern-card-skeleton .tbpl-skeleton-preview {
  height: 240px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: tbpl-shimmer 1.5s infinite;
}

.tbpl-pattern-card-skeleton .tbpl-skeleton-content {
  padding: 1.5rem;
}

.tbpl-pattern-card-skeleton .tbpl-skeleton-title {
  height: 20px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: tbpl-shimmer 1.5s infinite;
  margin-bottom: 0.5rem;
  border-radius: 4px;
}

.tbpl-pattern-card-skeleton .tbpl-skeleton-text {
  height: 16px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: tbpl-shimmer 1.5s infinite;
  margin-bottom: 0.5rem;
  border-radius: 4px;
}

.tbpl-pattern-card-skeleton .tbpl-skeleton-text:last-child {
  width: 70%;
}

@keyframes tbpl-shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

@keyframes tbpl-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.8;
  }
}

/* Error States */
.tbpl-error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 1rem;
  color: #dc2626;
  text-align: center;
  margin: 2rem 0;
}

.tbpl-error-message h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.tbpl-error-message p {
  margin: 0;
  font-size: 0.95rem;
}

/* Empty State Improvements */
.tbpl-no-patterns {
  text-align: center;
  padding: 4rem 2rem;
  background: #f8f9fa;
  border-radius: 16px;
  margin: 2rem 0;
}

.tbpl-no-patterns-content h2 {
  font-size: 1.5rem;
  color: #6b7280;
  margin-bottom: 1rem;
}

.tbpl-no-patterns-content p {
  color: #9ca3af;
  font-size: 1rem;
  margin-bottom: 2rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

/* Enhanced Header Styles */
.tbpl-pattern-library-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 4rem 2rem;
  border-radius: 16px;
  margin-bottom: 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.tbpl-pattern-library-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
  opacity: 0.3;
}

.tbpl-header-content {
  position: relative;
  z-index: 1;
}

.tbpl-page-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  letter-spacing: -0.5px;
}

.tbpl-page-description {
  font-size: 1.2rem;
  margin: 0 0 2rem 0;
  opacity: 0.95;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

.tbpl-header-stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  font-size: 1rem;
  opacity: 0.9;
}

.tbpl-stat-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: #000000;
}

.tbpl-stat-item strong {
  font-weight: 600;
  font-size: 1.1rem;
}

.tbpl-stat-divider {
  opacity: 0.6;
}

/* Header responsive styles */
@media (max-width: 768px) {
  .tbpl-pattern-library-header {
    padding: 2.5rem 1.5rem;
    margin-bottom: 2rem;
  }

  .tbpl-page-title {
    font-size: 2rem;
  }

  .tbpl-page-description {
    font-size: 1.1rem;
  }

  .tbpl-header-stats {
    flex-direction: column;
    gap: 0.5rem;
  }

  .tbpl-stat-divider {
    display: none;
  }
}

@media (max-width: 480px) {
  .tbpl-pattern-library-header {
    padding: 2rem 1rem;
  }

  .tbpl-page-title {
    font-size: 1.75rem;
  }

  .tbpl-page-description {
    font-size: 1rem;
  }
}

/* Pattern Library Container */
.tbpl-pattern-library {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Mobile and Tablet Responsive Improvements */
@media (max-width: 768px) {
  .tbpl-pattern-library {
    padding: 1rem 0.75rem;
  }

  .tbpl-pattern-card {
    min-height: 380px;
  }

  .tbpl-pattern-preview {
    min-height: 200px;
  }

  .tbpl-pattern-count-wrapper {
    text-align: center;
    margin-bottom: 1.5rem;
  }
}

@media (max-width: 480px) {
  .tbpl-pattern-library {
    padding: 0.75rem 0.5rem;
  }

  .tbpl-pattern-card {
    min-height: 360px;
  }

  .tbpl-pattern-preview {
    min-height: 180px;
  }

  .tbpl-pattern-info {
    padding: 1rem;
  }

  .tbpl-pattern-title {
    font-size: 1.125rem;
  }

  .tbpl-pattern-excerpt {
    font-size: 0.9rem;
  }
}

/* Ensure compatibility with common theme containers */
.content-area .tbpl-pattern-library,
.main-content .tbpl-pattern-library,
.entry-content .tbpl-pattern-library,
.container .tbpl-pattern-library {
  max-width: none;
  padding: 0;
}

/* Enhanced Responsive Pattern Grid */
.tbpl-pattern-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
  align-items: stretch;
}

/* Grid responsive breakpoints */
@media (max-width: 1400px) {
  .tbpl-pattern-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.75rem;
  }
}

@media (max-width: 1200px) {
  .tbpl-pattern-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
  }
}

@media (max-width: 768px) {
  .tbpl-pattern-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

@media (max-width: 480px) {
  .tbpl-pattern-grid {
    gap: 1rem;
  }
}

/* Enhanced Pattern Card */
.tbpl-pattern-card {
  background: #fff;
  border: 1px solid #e1e5e9;
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.tbpl-pattern-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(103, 31, 235, 0.02), rgba(118, 75, 162, 0.02));
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.tbpl-pattern-card:hover::before {
  opacity: 1;
}

.tbpl-pattern-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: rgba(103, 31, 235, 0.2);
}

/* Pattern Preview Area Improvements */
.tbpl-pattern-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  padding: 2rem 1rem;
  min-height: 240px;
  max-height: 320px;
  overflow: hidden;
  border-radius: 0;
  margin-bottom: 0;
  box-sizing: border-box;
  position: relative;
  flex-shrink: 0;
}

.tbpl-pattern-preview .wp-block-tableberg-table,
.tbpl-pattern-preview table {
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: 280px;
  object-fit: contain;
  margin: 0 auto;
  display: block;
  box-sizing: border-box;
}

.tbpl-preview-image img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.tbpl-preview-content {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pattern Info */
.tbpl-pattern-info {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex-grow: 1;
  position: relative;
  z-index: 1;
}

.tbpl-pattern-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: #1a1a1a;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.tbpl-pattern-title a {
  color: inherit;
  text-decoration: none;
}

.tbpl-pattern-title a:hover {
  color: var(--tbpl-brand);
}

.tbpl-pattern-excerpt {
  color: #6b7280;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Pattern Meta */
.tbpl-pattern-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}


.tbpl-difficulty-badge,
.tbpl-category-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tbpl-difficulty-badge {
  background: #00d084;
  color: white;
}

.tbpl-category-badge {
  background: var(--tbpl-brand);
  color: #fff;
}

/* Pattern Actions */
.tbpl-pattern-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tbpl-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.tbpl-btn-primary {
  background: var(--tbpl-brand);
  color: #fff;
}

.tbpl-btn-primary:hover {
  background: var(--tbpl-brand-dark);
  color: #fff;
}

.tbpl-btn-secondary {
  background: #f8f9fa;
  color: #666;
  border: 1px solid #e1e5e9;
}

.tbpl-btn-secondary:hover {
  background: #e9ecef;
  color: #333;
}

.tbpl-btn-copy {
  background: #00d084;
  color: white;
}

.tbpl-btn-copy:hover {
  background: #00b374;
  color: white;
}

.tbpl-btn-copy.copied {
  background: #28a745;
}

/* Single Pattern Page */
.tbpl-single-pattern {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Ensure compatibility with common theme containers */
.content-area .tbpl-single-pattern,
.main-content .tbpl-single-pattern,
.entry-content .tbpl-single-pattern,
.container .tbpl-single-pattern {
  max-width: none;
  padding: 0;
}

.tbpl-single-pattern-header {
  margin-bottom: 2rem;
  text-align: center;
}

.tbpl-single-pattern-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  color: #1a1a1a;
}

.tbpl-single-pattern-meta {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tbpl-single-pattern-description {
  font-size: 1.1rem;
  color: #666;
  line-height: 1.6;
  max-width: 600px;
  margin: 0 auto;
}

.tbpl-single-pattern-content {
  background: #fff;
  border: 1px solid #e1e5e9;
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tbpl-single-pattern-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.tbpl-single-pattern-info {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

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

.tbpl-info-item h4 {
  margin: 0 0 0.5rem 0;
  color: #1a1a1a;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tbpl-info-item p {
  margin: 0;
  color: #666;
  line-height: 1.5;
}

/* Tags */
.tbpl-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tbpl-tag {
  background: #e9ecef;
  color: #495057;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* Copy Button States */
.tbpl-copy-feedback {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #28a745;
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.tbpl-copy-feedback.show {
  transform: translateX(0);
}

/* Enhanced Filters */
.tbpl-filters {
  background: #fff;
  border: 1px solid #e1e5e9;
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 3rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.tbpl-filters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e1e5e9;
}

.tbpl-filters-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a1a1a;
}

.tbpl-filters-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(180px, 1fr) minmax(150px, 1fr) minmax(120px, 1fr);
  gap: 1rem;
}

@media (max-width: 1024px) {
  .tbpl-filters-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

.tbpl-filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tbpl-search-wrapper {
  position: relative;
}

.tbpl-search-wrapper input {
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.tbpl-search-wrapper input:focus {
  outline: none;
  border-color: var(--tbpl-brand);
  box-shadow: 0 0 0 3px rgba(103, 31, 235, 0.1);
}

.tbpl-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7280;
  pointer-events: none;
}

.tbpl-btn-text {
  background: none;
  border: none;
  color: var(--tbpl-brand);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.5rem 0;
  transition: color 0.2s;
}

.tbpl-btn-text:hover {
  color: var(--tbpl-brand-dark);
}

.tbpl-filter-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #374151;
}

.tbpl-filter-group select,
.tbpl-filter-group input:not(.tbpl-search-wrapper input) {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.95rem;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.tbpl-filter-group select:focus,
.tbpl-filter-group input:not(.tbpl-search-wrapper input):focus {
  outline: none;
  border-color: var(--tbpl-brand);
  box-shadow: 0 0 0 3px rgba(103, 31, 235, 0.1);
}

/* Filters responsive styles */
@media (max-width: 768px) {
  .tbpl-filters {
    padding: 1.5rem;
    margin-bottom: 2rem;
  }

  .tbpl-filters-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .tbpl-filters-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .tbpl-filters {
    padding: 1rem;
  }

  .tbpl-filters-header h3 {
    font-size: 1.125rem;
  }
}

/* Pagination */
.tbpl-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 3rem;
  margin-bottom: 3rem;
  flex-wrap: wrap;
}

/* All pagination links and spans */
.tbpl-pagination a,
.tbpl-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #e1e5e9;
  border-radius: 8px;
  text-decoration: none;
  color: #666;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s ease;
  background: #fff;
}

/* Number links specific styling */
.tbpl-pagination .page-numbers:not(.prev):not(.next):not(.dots) {
  width: 40px;
  padding: 0;
}

/* Current page styling */
.tbpl-pagination .current {
  background: var(--tbpl-brand);
  color: #fff;
  border-color: var(--tbpl-brand);
  cursor: default;
}

/* Hover states for clickable links */
.tbpl-pagination a:hover {
  background: var(--tbpl-brand);
  color: #fff;
  border-color: var(--tbpl-brand);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(103, 31, 235, 0.2);
}

/* Previous and Next link styling */
.tbpl-pagination .prev,
.tbpl-pagination .next {
  font-weight: 600;
  padding: 0 16px;
  gap: 4px;
}

/* Dots/ellipsis styling */
.tbpl-pagination .dots {
  border: none;
  background: transparent;
  cursor: default;
  padding: 0 8px;
}

.tbpl-pagination .dots:hover {
  background: transparent;
  color: #666;
  transform: none;
  box-shadow: none;
}

/* Focus states for accessibility */
.tbpl-pagination a:focus {
  outline: 2px solid var(--tbpl-brand);
  outline-offset: 2px;
}

/* Disabled state */
.tbpl-pagination .disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Mobile responsive pagination */
@media (max-width: 576px) {
  .tbpl-pagination {
    gap: 0.25rem;
  }

  .tbpl-pagination a,
  .tbpl-pagination span {
    min-width: 36px;
    height: 36px;
    font-size: 13px;
    padding: 0 10px;
  }

  .tbpl-pagination .page-numbers:not(.prev):not(.next):not(.dots) {
    width: 36px;
  }

  .tbpl-pagination .prev,
  .tbpl-pagination .next {
    padding: 0 12px;
  }
}

/* Theme Integration Helpers */
.tbpl-pattern-library,
.tbpl-single-pattern {
  /* Ensure proper spacing within theme content areas */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Common theme content area adjustments */
.entry-content .tbpl-pattern-library,
.entry-content .tbpl-single-pattern {
  /* Remove default entry content margins if needed */
  margin: 0;
}

/* Ensure proper display within theme containers */
.site-content .tbpl-pattern-library,
.site-content .tbpl-single-pattern,
.main .tbpl-pattern-library,
.main .tbpl-single-pattern {
  /* Allow theme to control max-width */
  max-width: none;
}

/* Responsive Design */
@media (max-width: 768px) {
  .tbpl-pattern-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .tbpl-single-pattern-title {
    font-size: 2rem;
  }

  .tbpl-single-pattern-actions {
    flex-direction: column;
    align-items: center;
  }

  .tbpl-btn {
    width: 100%;
    max-width: 300px;
    justify-content: center;
  }

  .tbpl-filters-grid {
    grid-template-columns: 1fr;
  }

  .tbpl-info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {

  .tbpl-pattern-library,
  .tbpl-single-pattern {
    padding: 1rem 0.5rem;
  }

  .tbpl-single-pattern-content {
    padding: 1rem;
  }

  .tbpl-pattern-info {
    padding: 1rem;
  }
}

/* Loading States */
.tbpl-loading {
  opacity: 0.6;
  pointer-events: none;
}

.tbpl-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #2184f9;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  transform: translate(-50%, -50%);
}

@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Accessibility */
.tbpl-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus States */
.tbpl-btn:focus,
.tbpl-filter-group select:focus,
.tbpl-filter-group input:focus {
  outline: 2px solid #2184f9;
  outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .tbpl-pattern-preview {
    padding: 1rem 0.25rem;
    min-height: 120px;
    max-height: 180px;
  }

  .tbpl-pattern-preview .wp-block-tableberg-table,
  .tbpl-pattern-preview table {
    max-height: 120px;
  }
}

/* Preview Inner Wrapper for Archive Card */
.tbpl-preview-inner {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 280px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tbpl-preview-inner .wp-block-tableberg-table,
.tbpl-preview-inner table {
  max-width: 100%;
  max-height: 260px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  box-sizing: border-box;
}

.tbpl-preview-inner .wp-block-tableberg-table {
  overflow-x: auto;
  overflow-y: auto;
}

/* Zoomed Preview for Archive Card */
.tbpl-preview-zoom {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  /* Set a fixed scale for now; adjust as needed */
  transform: scale(0.6);
  transform-origin: top left;
}

.tbpl-preview-inner {
  width: 100%;
  height: 180px;
  max-width: 100%;
  max-height: 180px;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  position: relative;
}

.tbpl-preview-inner .wp-block-tableberg-table,
.tbpl-preview-inner table {
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0;
  box-sizing: border-box;
}

/* Center the preview image in the archive card */
.tbpl-preview-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 180px;
  min-height: 120px;
  max-height: 220px;
  overflow: hidden;
  background: #fff;
  border-radius: 8px;
  margin: 0 auto;
}

.tbpl-preview-image img {
  display: block;
  max-width: 95%;
  max-height: 95%;
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* Make the whole card clickable in the archive */
.tbpl-pattern-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.tbpl-pattern-card-link:focus .tbpl-pattern-card,
.tbpl-pattern-card-link:hover .tbpl-pattern-card {
  box-shadow: 0 4px 24px rgba(33, 132, 249, 0.10), 0 1.5px 6px rgba(33, 132, 249, 0.08);
  border-color: #2184f9;
  outline: none;
}

.tbpl-pattern-card {
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}

/* Make all pattern cards the same height and use flex layout */
.tbpl-pattern-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem;
  align-items: stretch;
}

.tbpl-pattern-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  height: 100%;
  min-height: 420px;
  max-height: 480px;
  box-sizing: border-box;
}

.tbpl-pattern-info {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.tbpl-pattern-excerpt {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  color: #444;
  font-size: 1rem;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  min-height: 3.6em;
  max-height: 3.6em;
}

/* Unified badge style for category and pro badges (global) */
.tbpl-category-badge,
.tbpl-pro-badge {
  display: inline-block;
  min-width: 0;
  background: var(--tbpl-brand);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 2px rgba(103, 31, 235, 0.08);
  vertical-align: middle;
  border: none;
  margin-right: 0.4em;
  margin-bottom: 0.2em;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.tbpl-category-badge {
  background: var(--tbpl-category-color, var(--tbpl-brand));
}

.tbpl-pro-badge-link {
  display: inline;
  text-decoration: none;
  cursor: pointer;
}

.tbpl-pro-badge-link:focus .tbpl-pro-badge,
.tbpl-pro-badge-link:hover .tbpl-pro-badge {
  background: var(--tbpl-brand-dark);
  color: #fff;
  text-decoration: none;
}

/* Unified badge meta row for archive and single */
.tbpl-pattern-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4em;
  margin-bottom: 1rem;
}

/* Single Pattern Page Styles */
.tbpl-single-pattern {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Breadcrumb Navigation */
.tbpl-breadcrumb {
  margin-bottom: 2rem;
}

.tbpl-breadcrumb-list {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
}

.tbpl-breadcrumb-item {
  color: #6b7280;
}

.tbpl-breadcrumb-item:not(:last-child)::after {
  content: '/';
  margin-left: 0.5rem;
  color: #d1d5db;
}

.tbpl-breadcrumb-item a {
  color: #6b7280;
  text-decoration: none;
  transition: color 0.2s;
}

.tbpl-breadcrumb-item a:hover {
  color: var(--tbpl-brand);
}

.tbpl-breadcrumb-current {
  color: #1f2937;
  font-weight: 500;
}

/* Enhanced Single Pattern Header */
.tbpl-single-pattern-header {
  background: #fff;
  border: 1px solid #e1e5e9;
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.tbpl-header-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  margin-bottom: 2rem;
}

.tbpl-header-content {
  flex: 1;
}

.tbpl-single-pattern-title {
  font-size: 2.25rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 1rem 0;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.tbpl-single-pattern-description {
  font-size: 1.125rem;
  color: #4b5563;
  line-height: 1.6;
  margin-top: 1rem;
  max-width: 600px;
}

.tbpl-header-actions {
  display: flex;
  gap: 1rem;
  flex-shrink: 0;
}

.tbpl-header-actions .tbpl-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.tbpl-pattern-stats {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 1.5rem;
}

.tbpl-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.tbpl-stat-item {
  text-align: center;
  padding: 1rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tbpl-stat-number {
  display: block;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--tbpl-brand);
  margin-bottom: 0.5rem;
}

.tbpl-stat-label {
  font-size: 0.875rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* Tabbed Interface */
.tbpl-pattern-tabs {
  background: #fff;
  border: 1px solid #e1e5e9;
  border-radius: 16px;
  margin-bottom: 2rem;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.tbpl-tabs-nav {
  display: flex;
  border-bottom: 1px solid #e1e5e9;
  background: #f8f9fa;
}

.tbpl-tab-button {
  flex: 1;
  padding: 1rem 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  color: #6b7280;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  position: relative;
}

.tbpl-tab-button:hover {
  color: var(--tbpl-brand);
  background: rgba(103, 31, 235, 0.05);
}

.tbpl-tab-button.active {
  color: var(--tbpl-brand);
  background: white;
  border-bottom: 2px solid var(--tbpl-brand);
}

.tbpl-tab-button:focus {
  outline: 2px solid var(--tbpl-brand);
  outline-offset: -2px;
}

.tbpl-tabs-content {
  padding: 2rem;
}

.tbpl-tab-panel {
  display: none;
}

.tbpl-tab-panel.active {
  display: block;
}

/* Pattern Preview Container */
.tbpl-pattern-preview-container {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 2rem;
  min-height: 400px;
}

.tbpl-pattern-render {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Code Container */
.tbpl-code-container {
  position: relative;
}

.tbpl-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.tbpl-code-header h3 {
  margin: 0;
  font-size: 1.125rem;
  color: #1f2937;
}

.tbpl-btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* Copy button states */
.tbpl-copy-success {
  background-color: #10b981 !important;
  border-color: #10b981 !important;
  color: white !important;
}

.tbpl-copy-error {
  background-color: #ef4444 !important;
  border-color: #ef4444 !important;
  color: white !important;
}

.tbpl-code-block {
  background: #1f2937;
  color: #e5e7eb;
  padding: 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.tbpl-code-block code {
  background-color: #3d3d3d !important;
}

/* Usage Container */
.tbpl-usage-container h3 {
  margin: 0 0 1rem 0;
  font-size: 1.125rem;
  color: #1f2937;
}

.tbpl-usage-content {
  font-size: 1rem;
  line-height: 1.6;
  color: #4b5563;
}

/* Pattern Tags */
.tbpl-pattern-tags {
  margin-bottom: 2rem;
}

.tbpl-pattern-tags h3 {
  margin: 0 0 1rem 0;
  font-size: 1.125rem;
  color: #1f2937;
}

.tbpl-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tbpl-tag {
  background: #f3f4f6;
  color: #374151;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.2s;
}

.tbpl-tag:hover {
  background: #e5e7eb;
}

/* Related Patterns */
.tbpl-related-patterns {
  margin-bottom: 2rem;
}

.tbpl-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.tbpl-section-header h3 {
  margin: 0;
  font-size: 1.5rem;
  color: #1f2937;
}

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

.tbpl-related-card {
  background: #fff;
  border: 1px solid #e1e5e9;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tbpl-related-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  border-color: rgba(103, 31, 235, 0.2);
}

.tbpl-related-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.tbpl-related-preview {
  height: 180px;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.tbpl-related-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.tbpl-related-card:hover .tbpl-related-preview img {
  transform: scale(1.05);
}

.tbpl-preview-placeholder {
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tbpl-related-info {
  padding: 1.25rem;
}

.tbpl-related-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 0.75rem 0;
  line-height: 1.4;
}

.tbpl-related-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* Responsive Design */
@media (max-width: 768px) {
  .tbpl-single-pattern {
    padding: 1rem 0.75rem;
  }

  .tbpl-single-pattern-header {
    padding: 1.5rem;
  }

  .tbpl-header-main {
    flex-direction: column;
    gap: 1.5rem;
  }

  .tbpl-single-pattern-title {
    font-size: 1.875rem;
  }

  .tbpl-header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .tbpl-stats-grid {
    grid-template-columns: 1fr;
  }

  .tbpl-tabs-nav {
    flex-wrap: wrap;
  }

  .tbpl-tab-button {
    flex: 1;
    min-width: 0;
    font-size: 0.875rem;
    padding: 0.875rem 1rem;
  }

  .tbpl-tabs-content {
    padding: 1.5rem;
  }

  .tbpl-pattern-preview-container {
    padding: 1.5rem;
  }

  .tbpl-code-block {
    font-size: 0.8rem;
    padding: 1rem;
  }

  .tbpl-related-grid {
    grid-template-columns: 1fr;
  }

  .tbpl-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .tbpl-single-pattern-title {
    font-size: 1.5rem;
  }

  .tbpl-header-actions {
    flex-direction: column;
    gap: 0.75rem;
  }

  .tbpl-tab-button {
    font-size: 0.8rem;
    padding: 0.75rem 0.5rem;
  }
}

.tbpl-info-vertical {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tbpl-info-item {
  padding: 1.25rem 0;
}

.tbpl-info-divider {
  border: none;
  border-top: 1px solid #e1e5e9;
  margin: 0;
}

.tbpl-info-text-limited {
  max-width: 600px;
  line-height: 1.7;
  font-size: 1.05rem;
  color: #444;
}

@media (max-width: 600px) {
  .tbpl-info-text-limited {
    max-width: 100%;
    font-size: 0.98rem;
  }
}