/**
 * WindWalker Block Library UI Styles
 * [의도] 381번 - Canva 스타일 블록 라이브러리 디자인
 * [책임] 좌측 패널 레이아웃, 블록 카드, 카테고리 스타일
 * [참조] 381번 문서 Part 4.3 (line 1247-1306)
 */

/* ==========================================================================
   Main Panel Layout
   ========================================================================== */

.block-library-panel {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  background: #F9FAFB;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Search Bar
   ========================================================================== */

.search-bar {
  padding: 16px;
  background: white;
  border-bottom: 1px solid #E5E7EB;
  position: sticky;
  top: 0;
  z-index: 10;
}

.block-search-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #E5E7EB;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s;
}

.block-search-input:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.block-search-input::placeholder {
  color: #9CA3AF;
}

/* ==========================================================================
   AI Recommended Section (381번 Week 7 - 나중에)
   ========================================================================== */

.ai-recommended-section {
  padding: 16px;
  background: #DBEAFE;
  border-bottom: 1px solid #93C5FD;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #1F2937;
}

.ai-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ==========================================================================
   Category Groups
   ========================================================================== */

.block-categories {
  padding: 8px 16px;
  flex: 1;
  overflow-y: auto;
}

.category-group {
  margin-bottom: 16px;
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  background: #F3F4F6;
  transition: background 0.2s;
  list-style: none;
}

.category-header::-webkit-details-marker {
  display: none;
}

.category-header:hover {
  background: #E5E7EB;
}

.category-icon {
  font-size: 18px;
  line-height: 1;
}

.category-label {
  flex: 1;
}

.category-count {
  font-size: 12px;
  color: #6B7280;
  font-weight: 500;
}

/* Chevron indicator */
.category-header::before {
  content: '▶';
  font-size: 10px;
  margin-left: auto;
  color: #9CA3AF;
  transition: transform 0.2s;
}

details[open] .category-header::before {
  transform: rotate(90deg);
}

/* ==========================================================================
   Block Grid
   ========================================================================== */

.block-grid {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* ==========================================================================
   Block Card
   ========================================================================== */

.block-card {
  position: relative;
  background: white;
  border: 2px solid #E5E7EB;
  border-radius: 8px;
  padding: 8px;
  cursor: grab;
  transition: all 0.2s;
  min-height: 100px;
  display: flex;
  flex-direction: column;
}

.block-card:hover {
  border-color: #3B82F6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
}

.block-card:active {
  cursor: grabbing;
  transform: translateY(0);
}

.block-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

/* Infrastructure blocks */
.block-card.infra-block {
  border-color: #8B5CF6;
  background: linear-gradient(135deg, #FFFFFF 0%, #F3E8FF 100%);
}

.block-card.infra-block:hover {
  border-color: #7C3AED;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* AI recommended blocks (381번 Week 7) */
.block-card.ai-recommended {
  border-color: #10B981;
  background: linear-gradient(135deg, #FFFFFF 0%, #D1FAE5 100%);
}

/* ==========================================================================
   Block Thumbnail
   ========================================================================== */

.block-thumbnail {
  width: 100%;
  height: 70px;
  background: #F3F4F6;
  border-radius: 6px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.block-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.block-icon {
  font-size: 32px;
  line-height: 1;
}

/* ==========================================================================
   Block Info
   ========================================================================== */

.block-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: auto;
}

.block-name {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  flex: 1;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.quality-badge {
  font-size: 10px;
  font-weight: 700;
  color: white;
  background: #10B981;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* ==========================================================================
   Special Badges
   ========================================================================== */

.infra-badge,
.ai-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 1;
}

.infra-badge {
  background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
  box-shadow: 0 2px 4px rgba(139, 92, 246, 0.3);
}

.ai-badge {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

/* ==========================================================================
   Scrollbar Styling (WebKit)
   ========================================================================== */

.block-library-panel::-webkit-scrollbar,
.block-categories::-webkit-scrollbar {
  width: 8px;
}

.block-library-panel::-webkit-scrollbar-track,
.block-categories::-webkit-scrollbar-track {
  background: #F3F4F6;
}

.block-library-panel::-webkit-scrollbar-thumb,
.block-categories::-webkit-scrollbar-thumb {
  background: #D1D5DB;
  border-radius: 4px;
}

.block-library-panel::-webkit-scrollbar-thumb:hover,
.block-categories::-webkit-scrollbar-thumb:hover {
  background: #9CA3AF;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 1024px) {
  .block-library-panel {
    width: 280px;
  }

  .block-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Animation & Transitions
   ========================================================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.block-card {
  animation: fadeIn 0.2s ease-out;
}

.category-group[open] .block-grid {
  animation: fadeIn 0.3s ease-out;
}
