/* 
 * Borom Rack Editor - Responsive & Admin Styles (Phase 6)
 */

.borom-rack-editor-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    font-family: 'Inter', 'Noto Sans KR', sans-serif;
    background: #fdfdfd;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

/* 어드민 모드 전용 래퍼 스타일 */
.borom-rack-editor-wrapper.admin-mode {
    background: #fff;
    box-shadow: none;
    border: 1px solid #ccd0d4;
    padding: 2rem;
}

/* 1. Header & Materials Area */
.material-selection-header {
    background: #fff;
    padding: 1.2rem;
    border-bottom: 2px solid #f0f0f0;
    margin-bottom: 1.5rem;
    overflow: visible;
    /* 드래그 요소가 밖으로 나갈 수 있도록 보장 */
}

.custom-entry-bar {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: #f8fafc;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.product-selection-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0.5rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    /* 드래그 시 박스 밖으로 나갈 수 있도록 overflow 제한 제거 */
    overflow: visible;
}

.product-item.is-dragging {
    opacity: 0.8;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    cursor: grabbing;
}

.product-item {
    cursor: grab;
    transition: all 0.2s ease;
    user-select: none;
    min-width: 80px;
    text-align: center;
    white-space: nowrap;
}

.product-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 2. Responsive View Switcher (Admin) */
.view-switcher button {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bg-editor-bar {
    background: #fffbeb;
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    border-left: 4px solid #f59e0b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* 3. Main Editor Container */
.borom-rack-editor-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: #f1f5f9;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 1rem;
}

/* 4. Rack Nodes */
.rack-node {
    position: absolute;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.98);
    border: 2px solid #3b82f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    transform: translate(-50%, -50%);
    z-index: 100;
    /* 드롭존 인식을 위해 레이어 상향 */
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 0.65rem;
    font-weight: 800;
}

/* 관리자용 노드 스타일 (드래그 가능성 암시) */
.rack-node.admin-node {
    cursor: move;
    border-width: 3px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.rack-node.admin-node:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    z-index: 100;
}

.rack-node.assigned {
    background: #3b82f6;
    border-color: #fff;
    color: #fff;
    width: auto;
    height: auto;
    min-width: 50px;
    padding: 6px 10px;
    border-radius: 6px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.material-text {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.node-add-btn {
    font-size: 1.2rem;
    color: #3b82f6;
    line-height: 1;
    pointer-events: none;
    /* 클릭 이벤트가 부모(rack-node)에게 전달되도록 보장 */
}

.node-delete-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 20;
}

.rack-label {
    position: absolute;
    bottom: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-weight: 900;
    color: #475569;
    background: rgba(255, 255, 255, 0.9);
    padding: 1px 4px;
    border: 1px solid #e2e8f0;
    border-radius: 3px;
    white-space: nowrap;
}

.rack-label.admin-label {
    color: #1e3a8a;
    background: #dbeafe;
    border-color: #3b82f6;
    bottom: -20px;
    font-size: 10px;
}

/* 5. Drop Zone Animation */
.drop-target {
    background: #dcfce7 !important;
    border-style: dashed !important;
    transform: translate(-50%, -50%) scale(1.2) !important;
}

/* 6. Mobile Modal Styles */
/* [수정] p-dialog { display: none; } 제거 (컴포넌트 작동 방해) */

.material-grid-container {
    display: none;
    /* 기본적으로 숨김 (컴포넌트 로딩 실패 시 노출 방지) */
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0.5rem;
}

/* p-dialog가 정상 작동하여 visible 상태일 때만 내부 그리드 표시 */
.p-dialog-content .material-grid-container {
    display: grid;
}

.grid-item {
    border: 2px solid;
    border-radius: 12px;
    padding: 1.2rem 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

/* Responsive Overrides */
@media screen and (max-width: 1024px) {
    .borom-rack-editor-container {
        aspect-ratio: 4 / 3;
    }
}

@media screen and (max-width: 768px) {
    .borom-rack-editor-container {
        aspect-ratio: 1 / 1.3;
    }

    .rack-node {
        width: 36px;
        height: 36px;
    }
}