/* Accordion styles */
.template-category-item {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: all 0.3s ease-in-out;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.5s forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.template-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    background-color: #fff;
    border-bottom: 1px solid #ddd;
}

.template-category-header h4 {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
}

.template-category-icon {
    transition: transform 0.3s ease;
}

.template-category-item.open .template-category-icon {
    transform: rotate(180deg);
}

.template-category-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-in-out;
    background-color: #fff;
}

.template-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    padding: 20px;
}

.odt-template-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background-color: #fff;
}

.odt-template-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

/* Styles for dual-side previews within template cards */
.odt-template-card .design-previews.preview-card {
  display: flex;
  flex-direction: column; /* Stack previews vertically in template cards */
  gap: 0.6rem;
  align-items: stretch;
  justify-content: center;
  padding: 0.5rem; /* Add padding to the preview-card container */
}

.odt-template-card .preview-box {
  width: 100%; /* Take full width in template cards */
  padding: 0.4rem; /* Slightly less padding for compactness */
  box-shadow: none; /* Remove shadow for nested previews */
  border-color: #eef2f7; /* Lighter border for nested previews */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 6px;
  min-height: 140px;
  overflow: hidden;
}

.odt-template-card .preview-box:hover {
  background: #f8fafc;
}

.odt-template-card .preview-box.active {
  border-color: #93c5fd; /* Lighter blue for active state in nested previews */
  box-shadow: 0 0 0 2px rgba(147,197,253,0.3); /* Subtle focus ring */
}

/* Hide the unused preview-content styles to avoid confusion, 
   or keep them if they might be used elsewhere, but .preview-box now handles the layout */
.odt-template-card .preview-box .preview-content {
  display: none; 
}

.odt-template-card .preview-box .preview-thumbnail {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 120px;
  object-fit: contain; /* ensure full design is visible without cropping */
  object-position: center;
  border-radius: 6px;
  background: #f1f5f9;
  border: 1px solid #eef2ff;
  flex: 1 1 auto;
  min-width: 0;
}

.odt-template-card.odt-template-card--single-side .preview-box {
  min-height: 220px;
}

.odt-template-card.odt-template-card--single-side .preview-box .preview-thumbnail {
  max-height: 200px;
}

.odt-template-card .preview-box .preview-label {
  font-size: 0.7rem; /* Smaller label in template cards */
  font-weight: 500;
  text-align: right; /* Align label to the right */
  flex-grow: 1;
  color: #0f172a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.odt-template-card .preview-box .no-preview {
  width: auto;
  min-width: 0;
  flex: 1 1 auto; /* Allow it to fill remaining space */
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  background: linear-gradient(180deg,#f8fafc,#f1f5f9);
  border-radius: 6px;
  border: 1px dashed #e5e7eb;
  font-size: 0.75rem;
  flex-shrink: 1;
}

.odt-template-card .preview-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 0;
  width: 100%;
  text-align: left;
  letter-spacing: 0.2px;
  flex-shrink: 0;
  min-width: 40px;
}

.odt-badge {
    background-color: #007bff;
    color: #fff;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
}

/* Styles for template filters */
.template-filters-bar {
    display: flex;
    gap: 10px;
    padding: 15px 20px 0;
    align-items: center;
    flex-wrap: wrap;
}

.template-search-input,
.template-filter-select {
    padding: 10px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 25px; /* Rounded corners */
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.template-search-input {
    flex: 1;
    min-width: 200px;
}

.template-filter-select {
    min-width: 120px;
    background-color: #fff;
    cursor: pointer;
    appearance: none; /* Remove default arrow */
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns=''http://www.w3.org/2000/svg'' viewBox=''0 0 24 24'' fill=''none'' stroke=''currentColor'' stroke-width=''2'' stroke-linecap=''round'' stroke-linejoin=''round''%3e%3cpolyline points=''6 9 12 15 18 9''%3e%3c/polyline%3e%3c/svg%3e');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 30px;
}

.template-search-input:hover,
.template-filter-select:hover {
    border-color: #b0b0b0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.template-search-input:focus,
.template-filter-select:focus {
    border-color: #007bff;
    box-shadow: 0 4px 12px rgba(0,123,255,0.2);
    transform: translateY(-2px);
}


.template-category-grid {
    min-height: 70vh; /* Ensure expanded height during loading */
    align-content: start; /* Keep items at the top */
}

/* Center loading text */
.template-category-grid:has(> *:not(.odt-template-card)) {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #64748b;
}
