/**
 * ✨ RB Editor - 워드프레스 Gutenberg 스타일 블록 사이드바
 * 왼쪽에서 슬라이드 인/아웃되는 블록 라이브러리
 */

/* ========================================
   블록 사이드바 기본 스타일
======================================== */

#block-sidebar {
    position: fixed;
    left: -360px; /* 기본 숨김 */
    top: 0;
    width: 360px;
    height: 100vh;
    background: #ffffff;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

#block-sidebar.active {
    left: 0; /* 활성화 시 표시 */
}

/* ========================================
   사이드바 헤더
======================================== */

.block-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.block-sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
}

.close-sidebar-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 20px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* ========================================
   검색창
======================================== */

.block-sidebar-search {
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
}

#block-search {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
}

#block-search:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ========================================
   블록 콘텐츠 영역
======================================== */

.block-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.block-sidebar-content::-webkit-scrollbar {
    width: 8px;
}

.block-sidebar-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.block-sidebar-content::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.block-sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

/* ========================================
   블록 카테고리
======================================== */

.block-category {
    margin-bottom: 24px;
}

.block-category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0f0f0;
}

.category-icon {
    font-size: 20px;
}

.category-name {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   블록 리스트
======================================== */

.block-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.block-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 90px;
    text-align: center;
}

.block-item:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.block-item:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.2);
}

.block-icon {
    font-size: 28px;
    line-height: 1;
}

.block-name {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

/* ========================================
   토글 버튼 (툴바)
======================================== */

#open-sidebar-btn {
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: #ffffff !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
    margin-right: 12px !important;
}

#open-sidebar-btn:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

#open-sidebar-btn svg {
    fill: #ffffff;
}

/* ========================================
   반응형 디자인
======================================== */

/* 태블릿 (768px ~ 1024px) */
@media screen and (max-width: 1024px) {
    #block-sidebar {
        width: 320px;
        left: -320px;
    }

    .block-list {
        grid-template-columns: 1fr;
    }
}

/* 모바일 (768px 이하) */
@media screen and (max-width: 768px) {
    #block-sidebar {
        width: 100%;
        left: -100%;
    }

    #block-sidebar.active {
        left: 0;
    }

    .block-sidebar-header {
        padding: 16px;
    }

    .block-sidebar-header h3 {
        font-size: 16px;
    }

    .block-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .block-item {
        min-height: 80px;
        padding: 12px 8px;
    }

    .block-icon {
        font-size: 24px;
    }

    .block-name {
        font-size: 11px;
    }
}

/* ========================================
   오버레이 (모바일)
======================================== */

#block-sidebar.active::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.3);
    z-index: -1;
    display: none;
}

@media screen and (max-width: 768px) {
    #block-sidebar.active::before {
        display: block;
    }
}

/* ========================================
   애니메이션
======================================== */

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.block-category {
    animation: slideIn 0.3s ease;
}

.block-category:nth-child(1) { animation-delay: 0.05s; }
.block-category:nth-child(2) { animation-delay: 0.1s; }
.block-category:nth-child(3) { animation-delay: 0.15s; }
.block-category:nth-child(4) { animation-delay: 0.2s; }

/* ========================================
   컬럼 블록 스타일 (에디터 내부)
======================================== */

.columns {
    display: flex;
    gap: 16px;
    margin: 16px 0;
}

.column-50 {
    flex: 1;
    padding: 16px;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    min-height: 100px;
}

.column-50:focus {
    border-color: #667eea;
    outline: none;
}

/* ========================================
   버튼 블록 스타일 (에디터 내부)
======================================== */

.rb-btn {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.rb-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ========================================
   갤러리 블록 스타일 (에디터 내부)
======================================== */

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin: 16px 0;
    padding: 16px;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    min-height: 150px;
}

.gallery:empty::before {
    content: '이미지를 드래그하여 추가하세요';
    color: #999;
    font-size: 14px;
    text-align: center;
    display: block;
}
