/* Pixabay Background Changer - Frontend Floating Panel */

/* 플러그인 배경 활성 시에만 body 배경을 투명하게 — 비활성 시 테마 배경 정상 출력 */
body.pbc-bg-active {
    background: transparent !important;
}

/* 테마 레이아웃 래퍼(main)가 불투명 배경으로 뷰포트를 덮으면
   z-index:-9999 배경 레이어가 가려지므로 활성 시 함께 투명 처리.
   (larapress: main.bg-white / main.bg-slate-50 / .nyt-skin main / .basic-skin main / .aj-main) */
body.pbc-bg-active main {
    background: transparent !important;
}

#pbc-float-btn {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 99999;
    background: #f5f5f5;
    color: #1a1a2e;
    border: 1px solid #e2e4e9;
    border-right: none;
    border-radius: 8px 0 0 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    box-shadow: -2px 2px 8px rgba(0,0,0,0.15);
}

#pbc-float-btn:hover {
    background: #e8e8e8;
    color: #0073aa;
    transform: translateY(-50%) translateX(-4px);
}

#pbc-panel {
    position: fixed;
    top: 0;
    right: -380px;
    width: 360px;
    height: 100vh;
    z-index: 99998;
    background: #ffffff;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#pbc-panel.open {
    right: 0;
}

#pbc-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: #f5f6f8;
    border-bottom: 1px solid #e2e4e9;
    flex-shrink: 0;
}

#pbc-panel-header h3 {
    margin: 0;
    color: #1a1a2e;
    font-size: 15px;
    font-weight: 600;
}

#pbc-panel-close {
    background: none;
    border: none;
    color: #888;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.2s;
}

#pbc-panel-close:hover {
    color: #1a1a2e;
}

#pbc-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
    scrollbar-color: #d0d3da #ffffff;
}

#pbc-panel-body::-webkit-scrollbar {
    width: 5px;
}

#pbc-panel-body::-webkit-scrollbar-track {
    background: #ffffff;
}

#pbc-panel-body::-webkit-scrollbar-thumb {
    background: #d0d3da;
    border-radius: 3px;
}

.pbc-front-search {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.pbc-front-search input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d0d3da;
    border-radius: 6px;
    background: #f5f6f8;
    color: #1a1a2e;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.pbc-front-search input::placeholder {
    color: #999;
}

.pbc-front-search input:focus {
    border-color: #0073aa;
}

.pbc-front-search button,
.pbc-front-action-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
}

.pbc-front-search button {
    background: #0073aa;
    color: #fff;
    white-space: nowrap;
}

.pbc-front-search button:hover {
    background: #005a87;
}

.pbc-front-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.pbc-front-action-btn {
    flex: 1;
    padding: 7px 10px;
    font-size: 12px;
}

.pbc-front-action-btn.refresh {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.pbc-front-action-btn.refresh:hover {
    background: #c8e6c9;
}

.pbc-front-action-btn.remove {
    background: #fdecea;
    color: #c62828;
    border: 1px solid #f5c6cb;
}

.pbc-front-action-btn.remove:hover {
    background: #f8d7da;
}

#pbc-front-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.pbc-front-img-item {
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    background: #eceef2;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.2s;
}

.pbc-front-img-item:hover {
    border-color: #0073aa;
    transform: scale(1.02);
}

.pbc-front-img-item.active {
    border-color: #46b450;
    box-shadow: 0 0 0 2px #46b450;
}

.pbc-front-img-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.2s;
}

.pbc-front-img-item .pbc-img-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 115, 170, 0.0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.pbc-front-img-item:hover .pbc-img-overlay {
    background: rgba(0, 115, 170, 0.4);
}

.pbc-front-img-item .pbc-img-overlay span {
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    opacity: 0;
    transition: opacity 0.2s;
    letter-spacing: 0.5px;
}

.pbc-front-img-item:hover .pbc-img-overlay span {
    opacity: 1;
}

.pbc-front-img-item.active .pbc-img-overlay {
    background: rgba(70, 180, 80, 0.25);
}

.pbc-front-img-item.active .pbc-img-overlay span {
    opacity: 1;
    color: #7dff85;
}

#pbc-front-loading {
    text-align: center;
    padding: 30px 0;
    color: #888;
    font-size: 13px;
    display: none;
}

#pbc-front-loading::after {
    content: '';
    display: block;
    width: 30px;
    height: 30px;
    border: 3px solid #e2e4e9;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: pbc-spin 0.8s linear infinite;
    margin: 12px auto 0;
}

@keyframes pbc-spin {
    to { transform: rotate(360deg); }
}

#pbc-front-msg {
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 5px;
    margin-bottom: 12px;
    display: none;
}

#pbc-front-msg.success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

#pbc-front-msg.error {
    background: #fdecea;
    color: #c62828;
    border: 1px solid #f5c6cb;
}

#pbc-panel-overlay {
    position: fixed;
    inset: 0;
    z-index: 99997;
    background: rgba(0,0,0,0.4);
    display: none;
    backdrop-filter: blur(2px);
}

#pbc-panel-overlay.open {
    display: block;
}
